Skip to content

isMatchTypeShaped does not handle cases using TypeTests #19692

Closed
@EugeneFlesselle

Description

@EugeneFlesselle

Compiler version

3.3.1

Minimized code

object Test:

  type B

  trait UsingTypeTest(using reflect.TypeTest[Int, B]):
    type M[U <: Int] = U match
      case B => String
    private def m(t: Int): M[Int] = t match
      case _: B => "hello"

Output (click arrow to expand)

  exception occurred while typechecking tests/pos/experimental-erased.scala

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

     while compiling: tests/pos/experimental-erased.scala
        during phase: typer
                mode: Mode(ImplicitsEnabled)
     library version: version 2.13.12
    compiler version: version 3.4.0-RC1-bin-SNAPSHOT-nonbootstrapped-git-7ef195e
            settings: -classpath /Users/eugeneflesselle/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.12/scala-library-2.13.12.jar:/Users/eugeneflesselle/Documents/dotty/library/../out/bootstrap/scala3-library-bootstrapped/scala-3.4.0-RC1-bin-SNAPSHOT-nonbootstrapped/scala3-library_3-3.4.0-RC1-bin-SNAPSHOT.jar -d /

Exception in thread "main" scala.MatchError: UnApply(Select(Select(This(Ident(UsingTypeTest)),x$1),unapply),List(),List(Ident(_))) (of class dotty.tools.dotc.ast.Trees$UnApply)
        at dotty.tools.dotc.typer.Typer.isMatchTypeShaped$1$$anonfun$3(Typer.scala:1813)
        at scala.collection.immutable.List.forall(List.scala:386)
        at dotty.tools.dotc.typer.Typer.isMatchTypeShaped$1(Typer.scala:1824)
        at dotty.tools.dotc.typer.Typer.typedMatch(Typer.scala:1829)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3175)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3244)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3321)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3325)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3437)
        at dotty.tools.dotc.typer.Typer.$anonfun$62(Typer.scala:2602)
        at dotty.tools.dotc.inlines.PrepareInlineable$.dropInlineIfError(PrepareInlineable.scala:256)
        at dotty.tools.dotc.typer.Typer.typedDefDef(Typer.scala:2602)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3136)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3243)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3321)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3325)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3347)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3393)
        at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2789)
        at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:3148)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3152)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3243)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3321)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3325)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3347)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3393)
        at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2789)
        at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:3148)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3152)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3243)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3321)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3325)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3347)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3393)
        at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2922)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3194)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3244)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3321)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3325)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3437)
        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:477)
        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:684)
        at scala.collection.immutable.List$.from(List.scala:681)
        at scala.collection.IterableOps$WithFilter.map(Iterable.scala:898)
        at dotty.tools.dotc.typer.TyperPhase.runOn(TyperPhase.scala:100)
        at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:315)
        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:337)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:348)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:357)
        at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:69)
        at dotty.tools.dotc.Run.compileUnits(Run.scala:357)
        at dotty.tools.dotc.Run.compileSources(Run.scala:261)
        at dotty.tools.dotc.Run.compile(Run.scala:246)
        at dotty.tools.dotc.Driver.doCompile(Driver.scala:37)
        at dotty.tools.dotc.Driver.process(Driver.scala:197)
        at dotty.tools.dotc.Driver.process(Driver.scala:165)
        at dotty.tools.dotc.Driver.process(Driver.scala:177)
        at dotty.tools.dotc.Driver.main(Driver.scala:207)
        at dotty.tools.dotc.Main.main(Main.scala)

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions