Skip to content

Crash with FlexibleTypes when nullifying classes with Higher-kinded Type Parameters #23908

@HarrisL2

Description

@HarrisL2

Compiler version

3.7.3-RC2

This bug was found while porting community build to compile with -Yexplicit-nulls and minimized.

Minimized code

package unsafe

class Foo[F[_]] {
  def accept[A](arg: F[A]): Nothing = ???
}

scalac local/unsafe.scala -d local/out -classpath "local/out"

import unsafe.*

val x: List[Map[String, Int]] = ???
val foo = Foo[List]()
val y = foo.accept[Any](x)

scalac local/safe.scala -Yexplicit-nulls -d local/out -classpath "local/out"

Output

Exception in thread "main" java.lang.AssertionError: assertion failed: Should not flexify HKTypeLambda(List(A), List(TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Any))), AppliedType(TypeRef(ThisType(TypeRef(NoPrefix,module class immutable)),class List),List(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Any))))

  exception occurred while typechecking local/safe.scala

  An unhandled exception was thrown in the compiler.
  Please file a crash report here:
  https://github.com/scala/scala3/issues/new/choose
  For non-enriched exceptions, compile with -Xno-enrich-error-messages.


     while compiling: local/safe.scala
        during phase: typer
                mode: Mode(ImplicitsEnabled,SafeNulls)
     library version: version 2.13.16
    compiler version: version 3.8.0-RC1-bin-SNAPSHOT-nonbootstrapped-git-f4df13e
            settings: -Yexplicit-nulls true 

Expectation

The compiler should be able to handle Higher Kinded Types in when nullifying unsafe files

Metadata

Metadata

Assignees

No one assigned

    Labels

    itype:bugstat:needs triageEvery issue needs to have an "area" and "itype" label

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions