Skip to content
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

Crash when matching on Underlying type of a Type #17039

Closed
prolativ opened this issue Mar 3, 2023 · 0 comments · Fixed by #17048
Closed

Crash when matching on Underlying type of a Type #17039

prolativ opened this issue Mar 3, 2023 · 0 comments · Fixed by #17048
Assignees
Labels
Milestone

Comments

@prolativ
Copy link
Contributor

prolativ commented Mar 3, 2023

Compiler version

3.3.1-RC1-bin-20230301-0df5ae2-NIGHTLY and before

Minimized code

import scala.quoted.*

def macroImpl(using Quotes) =
  val t = summon[Type[Int]]
  Type.of[Int] match
    case '[t.Underlying] => '{true}
    case _ => '{false}

Output (click arrow to expand)

scala.MatchError: TypeTree[ClassInfo(ThisType(TypeRef(NoPrefix,module class scala)), class Int, List(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class AnyVal)))] (of class dotty.tools.dotc.ast.Trees$TypeTree) while running posttyper on Crash.scala
exception occurred while compiling Crash.scala
scala.MatchError: TypeTree[ClassInfo(ThisType(TypeRef(NoPrefix,module class scala)), class Int, List(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class AnyVal)))] (of class dotty.tools.dotc.ast.Trees$TypeTree) while compilingCrash.scala
Exception in thread "main" scala.MatchError: TypeTree[ClassInfo(ThisType(TypeRef(NoPrefix,module class scala)), class Int, List(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class AnyVal)))] (of class dotty.tools.dotc.ast.Trees$TypeTree)
        at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:400)
        at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.loop$2(tpd.scala:1238)
        at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformStats(tpd.scala:1238)
        at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transformStats(PostTyper.scala:488)
        at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformBlock(tpd.scala:1243)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1429)
        at dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:49)
        at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:479)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform$$anonfun$1(Trees.scala:1510)
        at scala.collection.immutable.List.mapConserve(List.scala:472)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1510)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1417)
        at dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:49)
        at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:353)
        at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.app1$1(PostTyper.scala:318)
        at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:331)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform$$anonfun$1(Trees.scala:1510)
        at scala.collection.immutable.List.mapConserve(List.scala:472)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1510)
        at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:335)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1437)
        at dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:49)
        at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:275)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform$$anonfun$1(Trees.scala:1510)
        at scala.collection.immutable.List.mapConserve(List.scala:472)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1510)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transformSub(Trees.scala:1514)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1435)
        at dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:49)
        at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:479)
        at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformBlock$$anonfun$1$$anonfun$1(tpd.scala:1243)
        at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.loop$2(tpd.scala:1225)
        at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformStats(tpd.scala:1238)
        at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transformStats(PostTyper.scala:488)
        at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformBlock(tpd.scala:1243)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1429)
        at dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:49)
        at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:479)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1481)
        at dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:40)
        at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform$$anonfun$5(PostTyper.scala:381)
        at dotty.tools.dotc.transform.SuperAccessors.wrapDefDef(SuperAccessors.scala:223)
        at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:381)
        at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.loop$2(tpd.scala:1238)
        at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformStats(tpd.scala:1238)
        at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transformStats(PostTyper.scala:488)
        at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformStats(tpd.scala:1240)
        at dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:47)
        at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform$$anonfun$4$$anonfun$1(PostTyper.scala:366)
        at dotty.tools.dotc.transform.SuperAccessors.wrapTemplate(SuperAccessors.scala:208)
        at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform$$anonfun$4(PostTyper.scala:366)
        at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.withNoCheckNews(PostTyper.scala:105)
        at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:368)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1483)
        at dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:40)
        at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:418)
        at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.loop$2(tpd.scala:1238)
        at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformStats(tpd.scala:1238)
        at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transformStats(PostTyper.scala:488)
        at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformStats(tpd.scala:1240)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1491)
        at dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:40)
        at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:479)
        at dotty.tools.dotc.transform.MacroTransform.run(MacroTransform.scala:18)
        at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:324)
        at scala.collection.immutable.List.map(List.scala:246)
        at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:328)
        at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:247)
        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:1321)
        at dotty.tools.dotc.Run.runPhases$1(Run.scala:263)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:271)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:280)
        at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:67)
        at dotty.tools.dotc.Run.compileUnits(Run.scala:280)
        at dotty.tools.dotc.Run.compileSources(Run.scala:195)
        at dotty.tools.dotc.Run.compile(Run.scala:179)
        at dotty.tools.dotc.Driver.doCompile(Driver.scala:35)
        at dotty.tools.dotc.Driver.process(Driver.scala:195)
        at dotty.tools.dotc.Driver.process(Driver.scala:163)
        at dotty.tools.dotc.Driver.process(Driver.scala:175)
        at dotty.tools.dotc.Driver.main(Driver.scala:205)
        at dotty.tools.dotc.Main.main(Main.scala)

This might be related to #17037

@prolativ prolativ added itype:bug itype:crash area:metaprogramming:quotes Issues related to quotes and splices labels Mar 3, 2023
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Mar 6, 2023
Dedelweiss pushed a commit to Dedelweiss/dotty that referenced this issue Apr 17, 2023
@Kordyjan Kordyjan added this to the 3.3.1 milestone Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants