Skip to content

MatchError in SymDenotation.opaqueAlias on hk opaque types #6225

Closed
@panacekcz

Description

@panacekcz

Test code 1:

object O1 {
  type A[X] = X
  opaque type T = A
}

Output:

exception occurred while compiling opaque-hk-1.scala
scala.MatchError: TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Any) (of class dotty.tools.dotc.core.Types$CachedTypeRef) while compiling opaque-hk-1.scala
Exception in thread "main" scala.MatchError: TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Any) (of class dotty.tools.dotc.core.Types$CachedTypeRef)
        at dotty.tools.dotc.core.SymDenotations$SymDenotation.extractAlias$1(SymDenotations.scala:1085)
        at dotty.tools.dotc.core.SymDenotations$SymDenotation.opaqueAlias(SymDenotations.scala:1089)
        at dotty.tools.dotc.transform.ElimOpaque.transformSym(ElimOpaque.scala:43)
        at dotty.tools.dotc.core.DenotTransformers$SymTransformer.transform(DenotTransformers.scala:66)
        at dotty.tools.dotc.core.DenotTransformers$SymTransformer.transform$(DenotTransformers.scala:65)
        at dotty.tools.dotc.transform.ElimOpaque.transform(ElimOpaque.scala:30)
        at dotty.tools.dotc.core.Denotations$SingleDenotation.current(Denotations.scala:921)
        at dotty.tools.dotc.core.Symbols$Symbol.recomputeDenot(Symbols.scala:483)
        at dotty.tools.dotc.core.Symbols$Symbol.computeDenot(Symbols.scala:478)
        at dotty.tools.dotc.core.Symbols$Symbol.denot(Symbols.scala:472)
        at dotty.tools.dotc.core.Symbols$.toDenot(Symbols.scala:824)
        at dotty.tools.dotc.core.SymDenotations$ClassDenotation.$anonfun$paramAccessors$1(SymDenotations.scala:1927)
        at dotty.tools.dotc.core.SymDenotations$ClassDenotation.$anonfun$paramAccessors$1$adapted(SymDenotations.scala:1927)
        at dotty.tools.dotc.core.Scopes$Scope.filter(Scopes.scala:102)
        at dotty.tools.dotc.core.SymDenotations$ClassDenotation.paramAccessors(SymDenotations.scala:1927)
        at dotty.tools.dotc.core.Contexts$Context.superCallContext(Contexts.scala:367)
        at dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:337)
        at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:396)
        at dotty.tools.dotc.transform.MegaPhase.transformNamed$1(MegaPhase.scala:251)
        at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:394)
        at dotty.tools.dotc.transform.MegaPhase.transformStat$1(MegaPhase.scala:404)
        at dotty.tools.dotc.transform.MegaPhase.$anonfun$transformStats$2(MegaPhase.scala:409)
        at scala.collection.immutable.List.mapConserve(List.scala:179)
        at dotty.tools.dotc.transform.MegaPhase.transformStats(MegaPhase.scala:409)
        at dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:339)
        at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:396)
        at dotty.tools.dotc.transform.MegaPhase.transformNamed$1(MegaPhase.scala:251)
        at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:394)
        at dotty.tools.dotc.transform.MegaPhase.transformStat$1(MegaPhase.scala:404)
        at dotty.tools.dotc.transform.MegaPhase.$anonfun$transformStats$2(MegaPhase.scala:409)
        at scala.collection.immutable.List.mapConserve(List.scala:179)
        at dotty.tools.dotc.transform.MegaPhase.transformStats(MegaPhase.scala:409)
        at dotty.tools.dotc.transform.MegaPhase.mapPackage$1(MegaPhase.scala:356)
        at dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:359)
        at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:396)
        at dotty.tools.dotc.transform.MegaPhase.transformUnit(MegaPhase.scala:415)
        at dotty.tools.dotc.transform.MegaPhase.run(MegaPhase.scala:427)
        at dotty.tools.dotc.core.Phases$Phase.$anonfun$runOn$1(Phases.scala:316)
        at scala.collection.immutable.List.map(List.scala:286)
        at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:314)
        at dotty.tools.dotc.Run.$anonfun$compileUnits$3(Run.scala:158)
        at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
        at dotty.tools.dotc.util.Stats$.trackTime(Stats.scala:49)
        at dotty.tools.dotc.Run.$anonfun$compileUnits$2(Run.scala:155)
        at dotty.tools.dotc.Run.$anonfun$compileUnits$2$adapted(Run.scala:153)
        at scala.collection.IndexedSeqOptimized.foreach(IndexedSeqOptimized.scala:36)
        at scala.collection.IndexedSeqOptimized.foreach$(IndexedSeqOptimized.scala:33)
        at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:198)
        at dotty.tools.dotc.Run.runPhases$1(Run.scala:153)
        at dotty.tools.dotc.Run.$anonfun$compileUnits$1(Run.scala:178)
        at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
        at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:102)
        at dotty.tools.dotc.Run.compileUnits(Run.scala:133)
        at dotty.tools.dotc.Run.compileSources(Run.scala:120)
        at dotty.tools.dotc.Run.compile(Run.scala:104)
        at dotty.tools.dotc.Driver.doCompile(Driver.scala:33)
        at dotty.tools.dotc.Driver.process(Driver.scala:170)
        at dotty.tools.dotc.Driver.process(Driver.scala:139)
        at dotty.tools.dotc.Driver.process(Driver.scala:151)
        at dotty.tools.dotc.Driver.main(Driver.scala:178)
        at dotty.tools.dotc.Main.main(Main.scala)

Test code 2:

object O2 {
  opaque type A[X] = X
  object A {
    opaque type T = A
  }
}

Output:

exception occurred while compiling opaque-hk-2.scala
scala.MatchError: AppliedType(TypeRef(ThisType(TypeRef(ThisType(TypeRef(ThisType(TypeRef(NoPrefix,module class <empty>)),module class O2$)),module class A$)),A),List(TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Any)))) (of class dotty.tools.dotc.core.Types$CachedAppliedType) while compiling opaque-hk-2.scala
Exception in thread "main" scala.MatchError: AppliedType(TypeRef(ThisType(TypeRef(ThisType(TypeRef(ThisType(TypeRef(NoPrefix,module class <empty>)),module class O2$)),module class A$)),A),List(TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Any)))) (of class dotty.tools.dotc.core.Types$CachedAppliedType)
        at dotty.tools.dotc.core.SymDenotations$SymDenotation.extractAlias$1(SymDenotations.scala:1085)
        at dotty.tools.dotc.core.SymDenotations$SymDenotation.opaqueAlias(SymDenotations.scala:1089)
        at dotty.tools.dotc.transform.ElimOpaque.transformSym(ElimOpaque.scala:43)
        at dotty.tools.dotc.core.DenotTransformers$SymTransformer.transform(DenotTransformers.scala:66)
        at dotty.tools.dotc.core.DenotTransformers$SymTransformer.transform$(DenotTransformers.scala:65)
        at dotty.tools.dotc.transform.ElimOpaque.transform(ElimOpaque.scala:30)
        at dotty.tools.dotc.core.Denotations$SingleDenotation.current(Denotations.scala:921)
        at dotty.tools.dotc.core.Symbols$Symbol.recomputeDenot(Symbols.scala:483)
        at dotty.tools.dotc.core.Symbols$Symbol.computeDenot(Symbols.scala:478)
        at dotty.tools.dotc.core.Symbols$Symbol.denot(Symbols.scala:472)
        at dotty.tools.dotc.core.Symbols$.toDenot(Symbols.scala:824)
        at dotty.tools.dotc.core.SymDenotations$ClassDenotation.$anonfun$paramAccessors$1(SymDenotations.scala:1927)
        at dotty.tools.dotc.core.SymDenotations$ClassDenotation.$anonfun$paramAccessors$1$adapted(SymDenotations.scala:1927)
        at dotty.tools.dotc.core.Scopes$Scope.filter(Scopes.scala:102)
        at dotty.tools.dotc.core.SymDenotations$ClassDenotation.paramAccessors(SymDenotations.scala:1927)
        at dotty.tools.dotc.core.Contexts$Context.superCallContext(Contexts.scala:367)
        at dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:337)
        at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:396)
        at dotty.tools.dotc.transform.MegaPhase.transformNamed$1(MegaPhase.scala:251)
        at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:394)
        at dotty.tools.dotc.transform.MegaPhase.transformStat$1(MegaPhase.scala:404)
        at dotty.tools.dotc.transform.MegaPhase.$anonfun$transformStats$2(MegaPhase.scala:409)
        at scala.collection.immutable.List.mapConserve(List.scala:179)
        at dotty.tools.dotc.transform.MegaPhase.transformStats(MegaPhase.scala:409)
        at dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:339)
        (... same as test 1)

Test code 3:

object O3 {
  opaque type R[X] = R[X]
}

Output:

exception occurred while compiling opaque-hk-3.scala
scala.MatchError: AppliedType(TypeRef(ThisType(TypeRef(ThisType(TypeRef(NoPrefix,module class <empty>)),module class O3$)),type R),List(TypeParamRef(X0))) (of class dotty.tools.dotc.core.Types$CachedAppliedType) while compiling opaque-hk-3.scala
Exception in thread "main" scala.MatchError: AppliedType(TypeRef(ThisType(TypeRef(ThisType(TypeRef(NoPrefix,module class <empty>)),module class O3$)),type R),List(TypeParamRef(X0))) (of class dotty.tools.dotc.core.Types$CachedAppliedType)
        at dotty.tools.dotc.core.SymDenotations$SymDenotation.extractAlias$1(SymDenotations.scala:1085)
        at dotty.tools.dotc.core.SymDenotations$SymDenotation.extractAlias$1(SymDenotations.scala:1087)
        (... same as test 1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions