Skip to content

Crash in match type with wildcards when using -Xkind-projector:underscores #21400

Closed
@WojciechMazur

Description

@WojciechMazur

Compiler version

Works in 3.0.0
Fails in every other version

Minimized code

//> using options -Ykind-projector:underscores
import scala.compiletime.ops.int.S

type IndexOf[T <: Tuple, E] <: Int = T match
  case E *: _  => 0
  case _ *: es => 1 // S[IndexOf[es, E]]

Output (click arrow to expand)

  exception occurred while typechecking /Users/wmazur/projects/sandbox/test.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: /Users/wmazur/projects/sandbox/test.scala
        during phase: typer
                mode: Mode(ImplicitsEnabled)
     library version: version 2.13.14
    compiler version: version 3.6.0-RC1-bin-20240819-b64afad-NIGHTLY-git-b64afad
            settings: -Xkind-projector underscores -classpath /Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/3.6.0-RC1-bin-20240819-b64afad-NIGHTLY/scala3-library_3-3.6.0-RC1-bin-20240819-b64afad-NIGHTLY.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.14/scala-library-2.13.14.jar -d /Users/wmazur/projects/sandbox/.scala-build/sandbox_1f4505af95-92b0ef3e72/classes/main -java-output-version 17 -sourceroot /Users/wmazur/projects/sandbox

Exception in thread "main" java.lang.AssertionError: assertion failed
        at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:11)
        at dotty.tools.dotc.typer.Typer$$anon$5.transform(Typer.scala:2158)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform$$anonfun$1(Trees.scala:1643)
        at scala.collection.immutable.List.mapConserve(List.scala:473)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1643)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1579)
        at dotty.tools.dotc.typer.Typer$$anon$5.transform(Typer.scala:2155)
        at dotty.tools.dotc.typer.Typer.caseRest$2(Typer.scala:2229)
        at dotty.tools.dotc.typer.Typer.typedTypeCase(Typer.scala:2236)
        at dotty.tools.dotc.typer.Typer.$anonfun$56(Typer.scala:2606)
        at dotty.tools.dotc.core.Decorators$.loop$1(Decorators.scala:99)
        at dotty.tools.dotc.core.Decorators$.mapconserve(Decorators.scala:115)
        at dotty.tools.dotc.typer.Typer.typedMatchTypeTree(Typer.scala:2606)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3474)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3529)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3606)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3610)
        at dotty.tools.dotc.typer.Typer.typedType(Typer.scala:3724)
        at dotty.tools.dotc.typer.Namer.typedAheadType$$anonfun$1(Namer.scala:1761)
        at dotty.tools.dotc.typer.Namer.typedAhead(Namer.scala:1754)
        at dotty.tools.dotc.typer.Namer.typedAheadType(Namer.scala:1761)
        at dotty.tools.dotc.typer.Namer$TypeDefCompleter.typeSig(Namer.scala:1093)
        at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:990)
        at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:859)
        at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:175)
        at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:190)
        at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:192)
        at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:393)
        at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:3391)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3416)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3528)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3606)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3610)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3632)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3678)
        at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:3126)
        at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:3432)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3436)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3528)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3606)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3610)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3632)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3678)
        at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:3259)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3478)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3529)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3606)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3610)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3721)
        at dotty.tools.dotc.typer.TyperPhase.typeCheck$$anonfun$1(TyperPhase.scala:47)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at dotty.tools.dotc.core.Phases$Phase.monitor(Phases.scala:503)
        at dotty.tools.dotc.typer.TyperPhase.typeCheck(TyperPhase.scala:53)
        at dotty.tools.dotc.typer.TyperPhase.$anonfun$4(TyperPhase.scala:99)
        at scala.collection.Iterator$$anon$6.hasNext(Iterator.scala:479)
        at scala.collection.Iterator$$anon$9.hasNext(Iterator.scala:583)
        at scala.collection.immutable.List.prependedAll(List.scala:152)
        at scala.collection.immutable.List$.from(List.scala:685)
        at scala.collection.immutable.List$.from(List.scala:682)
        at scala.collection.IterableOps$WithFilter.map(Iterable.scala:900)
        at dotty.tools.dotc.typer.TyperPhase.runOn(TyperPhase.scala:98)
        at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:343)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
        at dotty.tools.dotc.Run.runPhases$1(Run.scala:336)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:384)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:396)
        at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:69)
        at dotty.tools.dotc.Run.compileUnits(Run.scala:396)
        at dotty.tools.dotc.Run.compileSources(Run.scala:282)
        at dotty.tools.dotc.Run.compile(Run.scala:267)
        at dotty.tools.dotc.Driver.doCompile(Driver.scala:37)
        at dotty.tools.dotc.Driver.process(Driver.scala:201)
        at dotty.tools.dotc.Driver.process(Driver.scala:169)
        at dotty.tools.dotc.Driver.process(Driver.scala:181)
        at dotty.tools.dotc.Driver.main(Driver.scala:211)
        at dotty.tools.dotc.Main.main(Main.scala)
Compilation failed

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions