Skip to content

isMatchTypeShaped does not handle cases using TypeTests #19692

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
EugeneFlesselle opened this issue Feb 14, 2024 · 0 comments · Fixed by #19923
Closed

isMatchTypeShaped does not handle cases using TypeTests #19692

EugeneFlesselle opened this issue Feb 14, 2024 · 0 comments · Fixed by #19923

Comments

@EugeneFlesselle
Copy link
Contributor

EugeneFlesselle commented Feb 14, 2024

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)
@EugeneFlesselle EugeneFlesselle added itype:bug itype:crash stat:needs triage Every issue needs to have an "area" and "itype" label labels Feb 14, 2024
@EugeneFlesselle EugeneFlesselle changed the title `is isMatchTypeShaped does not handle cases using TypeTest Feb 14, 2024
@EugeneFlesselle EugeneFlesselle changed the title isMatchTypeShaped does not handle cases using TypeTest isMatchTypeShaped does not handle cases using TypeTests Feb 14, 2024
@Gedochao Gedochao removed the stat:needs triage Every issue needs to have an "area" and "itype" label label Mar 11, 2024
@EugeneFlesselle EugeneFlesselle self-assigned this Mar 11, 2024
@Kordyjan Kordyjan added this to the 3.4.2 milestone Mar 28, 2024
@Kordyjan Kordyjan modified the milestones: 3.4.2, 3.5.0 May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants