Skip to content

Assertion error with curiously-indirect F-bound using match types #5735

@abgruszecki

Description

@abgruszecki

Below code triggers: denotation module class <empty> invalid in run 2. ValidFor: Period(1..66, run = 3)

scala> object Test {
     |   // The identity on types of the form N | P[a, P[b, ... P[z, N]]]
     |   type Nested[X, P[_, _], N] = X match {
     |     case N => N
     |     case P[a, b] => P[a, Nested[b, P, N]]
     |   }
     |
     |   class Foo[T] { def apply[Y >: T <: Nested[T, Tuple2, Unit]](t: T): T = t }
     |   def foo[T] = new Foo[T]
     | }
// defined object Test

scala> Test.foo.apply((21, ()))
assertion failure for (Int, Unit) <:< (Int, Unit) match {
  case Unit => Unit
  case [a, b] => ((a, b)) => (a, LazyRef(...))
}, frozen = false
assertion failure for (Int, Unit) <:< Test.Nested[(Int, Unit), Tuple2, Unit], frozen = false
assertion failure for (Int, Unit) <:< Test.Nested[(Int, Unit), Tuple2, Unit], frozen = false
error while transforming Test.foo[(Int, Unit)].apply[(Int, Unit)]
error while transforming Test.foo[(Int, Unit)].apply[(Int, Unit)](Tuple2.apply[Int, Unit](21, ()))
error while transforming val res0: (Int, Unit) =
  Test.foo[(Int, Unit)].apply[(Int, Unit)](Tuple2.apply[Int, Unit](21, ()))
error while transforming () extends Object() { this: rs$line$2.type =>
  val res0: (Int, Unit) =
    Test.foo[(Int, Unit)].apply[(Int, Unit)](Tuple2.apply[Int, Unit](21, ()))
}
error while transforming @scala.annotation.internal.SourceFile("rs$line$2") final module class rs$line$2(
  )
 extends Object() { this: rs$line$2.type =>
  val res0: (Int, Unit) =
    Test.foo[(Int, Unit)].apply[(Int, Unit)](Tuple2.apply[Int, Unit](21, ()))
}
error while transforming package <empty> {
  final lazy module val rs$line$2: rs$line$2 = new rs$line$2()
  @scala.annotation.internal.SourceFile("rs$line$2") final module class
    rs$line$2
  () extends Object() { this: rs$line$2.type =>
    val res0: (Int, Unit) =
      Test.foo[(Int, Unit)].apply[(Int, Unit)](Tuple2.apply[Int, Unit](21, ()))
  }
}
Exception in thread "main" java.lang.AssertionError: assertion failed: denotation module class <empty> invalid in run 2. ValidFor: Period(1..66, run = 3)
        at scala.Predef$.assert(Predef.scala:223)
        at dotty.tools.dotc.core.Denotations$SingleDenotation.updateValidity(Denotations.scala:824)
        at dotty.tools.dotc.core.Denotations$SingleDenotation.bringForward(Denotations.scala:847)
        at dotty.tools.dotc.core.Denotations$SingleDenotation.current(Denotations.scala:902)
        at dotty.tools.dotc.core.Symbols$Symbol.recomputeDenot(Symbols.scala:482)
        at dotty.tools.dotc.core.Symbols$Symbol.computeDenot(Symbols.scala:477)
        at dotty.tools.dotc.core.Symbols$Symbol.denot(Symbols.scala:471)
        at dotty.tools.dotc.core.SymDenotations.dotty$tools$dotc$core$SymDenotations$$stillValidInOwner(SymDenotations.scala:58)
        at dotty.tools.dotc.core.SymDenotations.dotty$tools$dotc$core$SymDenotations$$stillValidInOwner$(SymDenotations.scala:57)
        at dotty.tools.dotc.core.Contexts$Context.dotty$tools$dotc$core$SymDenotations$$stillValidInOwner(Contexts.scala:69)
        at dotty.tools.dotc.core.SymDenotations.stillValid(SymDenotations.scala:54)
        at dotty.tools.dotc.core.SymDenotations.stillValid$(SymDenotations.scala:46)
        at dotty.tools.dotc.core.Contexts$Context.stillValid(Contexts.scala:69)
        at dotty.tools.dotc.core.Denotations$SingleDenotation.bringForward(Denotations.scala:847)
        at dotty.tools.dotc.core.Denotations$SingleDenotation.current(Denotations.scala:902)
        at dotty.tools.dotc.core.Symbols$Symbol.recomputeDenot(Symbols.scala:482)
        at dotty.tools.dotc.core.Symbols$Symbol.computeDenot(Symbols.scala:477)
        at dotty.tools.dotc.core.Symbols$Symbol.denot(Symbols.scala:471)
        at dotty.tools.dotc.core.SymDenotations.dotty$tools$dotc$core$SymDenotations$$stillValidInOwner(SymDenotations.scala:58)
        at dotty.tools.dotc.core.SymDenotations.dotty$tools$dotc$core$SymDenotations$$stillValidInOwner$(SymDenotations.scala:57)
        at dotty.tools.dotc.core.Contexts$Context.dotty$tools$dotc$core$SymDenotations$$stillValidInOwner(Contexts.scala:69)
        at dotty.tools.dotc.core.SymDenotations.stillValid(SymDenotations.scala:54)
        at dotty.tools.dotc.core.SymDenotations.stillValid$(SymDenotations.scala:46)
        at dotty.tools.dotc.core.Contexts$Context.stillValid(Contexts.scala:69)
        at dotty.tools.dotc.core.Denotations$SingleDenotation.bringForward(Denotations.scala:847)
        at dotty.tools.dotc.core.Denotations$SingleDenotation.current(Denotations.scala:902)
        at dotty.tools.dotc.core.Symbols$Symbol.recomputeDenot(Symbols.scala:482)
        at dotty.tools.dotc.core.Symbols$Symbol.computeDenot(Symbols.scala:477)
        at dotty.tools.dotc.core.Symbols$Symbol.denot(Symbols.scala:471)
        at dotty.tools.dotc.core.SymDenotations.dotty$tools$dotc$core$SymDenotations$$stillValidInOwner(SymDenotations.scala:58)
        at dotty.tools.dotc.core.SymDenotations.dotty$tools$dotc$core$SymDenotations$$stillValidInOwner$(SymDenotations.scala:57)
        at dotty.tools.dotc.core.Contexts$Context.dotty$tools$dotc$core$SymDenotations$$stillValidInOwner(Contexts.scala:69)
        at dotty.tools.dotc.core.SymDenotations.stillValid(SymDenotations.scala:54)
        at dotty.tools.dotc.core.SymDenotations.stillValid$(SymDenotations.scala:46)
        at dotty.tools.dotc.core.Contexts$Context.stillValid(Contexts.scala:69)
        at dotty.tools.dotc.core.Symbols$Symbol.isValidInCurrentRun(Symbols.scala:507)
        at dotty.tools.dotc.core.Types$NamedType.computeSymbol(Types.scala:1749)
        at dotty.tools.dotc.core.Types$NamedType.symbol(Types.scala:1744)
        at dotty.tools.dotc.core.TypeApplications$.$anonfun$typeParams$extension$1(TypeApplications.scala:170)
        at dotty.tools.dotc.util.Stats$.track(Stats.scala:37)
        at dotty.tools.dotc.core.TypeApplications$.typeParams$extension(TypeApplications.scala:162)
        at dotty.tools.dotc.core.TypeApplications$.$anonfun$appliedTo$extension0$1(TypeApplications.scala:352)
        at dotty.tools.dotc.util.Stats$.track(Stats.scala:37)
        at dotty.tools.dotc.core.TypeApplications$.appliedTo$extension0(TypeApplications.scala:351)
        at dotty.tools.dotc.core.TypeApplications$.$anonfun$appliedTo$3(TypeApplications.scala:401)
        at dotty.tools.dotc.core.Types$LazyRef.ref(Types.scala:2416)
        at dotty.tools.dotc.core.Types$TypeMap.$anonfun$mapOver$8(Types.scala:4415)
        at dotty.tools.dotc.core.Types$LazyRef.ref(Types.scala:2416)
        at dotty.tools.dotc.core.Types$TypeMap.$anonfun$mapOver$8(Types.scala:4415)
        at dotty.tools.dotc.core.Types$LazyRef.ref(Types.scala:2416)
        at dotty.tools.dotc.core.Types$TypeMap.$anonfun$mapOver$8(Types.scala:4415)
        at dotty.tools.dotc.core.Types$LazyRef.ref(Types.scala:2416)
        at dotty.tools.dotc.core.Types$TypeMap.$anonfun$mapOver$8(Types.scala:4415)
        at dotty.tools.dotc.core.Types$LazyRef.ref(Types.scala:2416)
        at dotty.tools.dotc.core.Types$TypeMap.$anonfun$mapOver$8(Types.scala:4415)
        at dotty.tools.dotc.core.Types$LazyRef.ref(Types.scala:2416)
        at dotty.tools.dotc.core.Types$TypeMap.$anonfun$mapOver$8(Types.scala:4415)
        at dotty.tools.dotc.core.Types$LazyRef.ref(Types.scala:2416)
        at dotty.tools.dotc.core.Types$TypeMap.$anonfun$mapOver$8(Types.scala:4415)
        at dotty.tools.dotc.core.Types$LazyRef.ref(Types.scala:2416)
        at dotty.tools.dotc.core.Types$TypeMap.$anonfun$mapOver$8(Types.scala:4415)
        at dotty.tools.dotc.core.Types$LazyRef.ref(Types.scala:2416)
        at dotty.tools.dotc.core.Types$TypeMap.$anonfun$mapOver$8(Types.scala:4415)
        at dotty.tools.dotc.core.Types$LazyRef.ref(Types.scala:2416)
        at dotty.tools.dotc.core.TrackingTypeComparer$$anon$3.apply(TypeComparer.scala:1896)
        at dotty.tools.dotc.core.Types$TypeMap.$anonfun$mapOver$6(Types.scala:4370)
        at dotty.tools.dotc.core.Types$VariantTraversal.atVariance(Types.scala:4296)
        at dotty.tools.dotc.core.Types$TypeMap.mapArgs$1(Types.scala:4370)
        at dotty.tools.dotc.core.Types$TypeMap.mapArgs$1(Types.scala:4372)
        at dotty.tools.dotc.core.Types$TypeMap.mapOver(Types.scala:4378)
        at dotty.tools.dotc.core.TrackingTypeComparer$$anon$3.apply(TypeComparer.scala:1897)
        at dotty.tools.dotc.core.TrackingTypeComparer.$anonfun$matchCase$1(TypeComparer.scala:1916)
        at dotty.tools.dotc.core.ConstraintHandling.inFrozenConstraint(ConstraintHandling.scala:194)
        at dotty.tools.dotc.core.ConstraintHandling.inFrozenConstraint$(ConstraintHandling.scala:189)
        at dotty.tools.dotc.core.TypeComparer.inFrozenConstraint(TypeComparer.scala:27)
        at dotty.tools.dotc.core.TrackingTypeComparer.matchCase(TypeComparer.scala:1903)
        at dotty.tools.dotc.core.Types$MatchType.reduceSequential$1(Types.scala:3735)
        at dotty.tools.dotc.core.Types$MatchType.$anonfun$reduced$17(Types.scala:3792)
        at dotty.tools.dotc.reporting.trace$.apply(trace.scala:40)
        at dotty.tools.dotc.core.Types$MatchType.reduced(Types.scala:3788)
        at dotty.tools.dotc.core.TypeComparer.thirdTry$1(TypeComparer.scala:564)
        at dotty.tools.dotc.core.TypeComparer.secondTry$1(TypeComparer.scala:397)
        at dotty.tools.dotc.core.TypeComparer.firstTry$1(TypeComparer.scala:316)
        at dotty.tools.dotc.core.TypeComparer.$anonfun$recur$2(TypeComparer.scala:966)
        at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:23)
        at dotty.tools.dotc.reporting.trace$.apply(trace.scala:40)
        at dotty.tools.dotc.reporting.trace$.apply(trace.scala:44)
        at dotty.tools.dotc.core.TypeComparer.recur(TypeComparer.scala:148)
        at dotty.tools.dotc.core.TypeComparer.isSubType(TypeComparer.scala:139)
        at dotty.tools.dotc.core.TypeComparer.isSubApproxHi$1(TypeComparer.scala:955)
        at dotty.tools.dotc.core.TypeComparer.$anonfun$recur$24(TypeComparer.scala:851)
        at dotty.tools.dotc.core.TypeComparer.either(TypeComparer.scala:1123)
        at dotty.tools.dotc.core.TypeComparer.fallback$1(TypeComparer.scala:851)
        at dotty.tools.dotc.core.TypeComparer.compareLower$1(TypeComparer.scala:867)
        at dotty.tools.dotc.core.TypeComparer.compareAppliedType2$1(TypeComparer.scala:879)
        at dotty.tools.dotc.core.TypeComparer.thirdTry$1(TypeComparer.scala:438)
        at dotty.tools.dotc.core.TypeComparer.secondTry$1(TypeComparer.scala:397)
        at dotty.tools.dotc.core.TypeComparer.firstTry$1(TypeComparer.scala:316)
        at dotty.tools.dotc.core.TypeComparer.$anonfun$recur$2(TypeComparer.scala:966)
        at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:23)
        at dotty.tools.dotc.reporting.trace$.apply(trace.scala:40)
        at dotty.tools.dotc.reporting.trace$.apply(trace.scala:44)
        at dotty.tools.dotc.core.TypeComparer.recur(TypeComparer.scala:148)
        at dotty.tools.dotc.core.TypeComparer.secondTry$1(TypeComparer.scala:362)
        at dotty.tools.dotc.core.TypeComparer.firstTry$1(TypeComparer.scala:316)
        at dotty.tools.dotc.core.TypeComparer.$anonfun$recur$2(TypeComparer.scala:966)
        at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:23)
        at dotty.tools.dotc.reporting.trace$.apply(trace.scala:40)
        at dotty.tools.dotc.reporting.trace$.apply(trace.scala:44)
        at dotty.tools.dotc.core.TypeComparer.recur(TypeComparer.scala:148)
        at dotty.tools.dotc.core.TypeComparer.isSubType(TypeComparer.scala:139)
        at dotty.tools.dotc.core.TypeComparer.isSubType(TypeComparer.scala:146)
        at dotty.tools.dotc.core.TypeComparer.topLevelSubType(TypeComparer.scala:125)
        at dotty.tools.dotc.core.Types$Type.$anonfun$$less$colon$less$1(Types.scala:824)
        at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:23)
        at dotty.tools.dotc.util.Stats$.track(Stats.scala:37)
        at dotty.tools.dotc.core.Types$Type.$less$colon$less(Types.scala:824)
        at dotty.tools.dotc.core.TypeOps.checkOverlapsBounds$1(TypeOps.scala:265)
        at dotty.tools.dotc.core.TypeOps.$anonfun$boundsViolations$2(TypeOps.scala:270)
        at dotty.tools.dotc.core.TypeOps.$anonfun$boundsViolations$2$adapted(TypeOps.scala:257)
        at scala.collection.TraversableLike$WithFilter.$anonfun$foreach$1(TraversableLike.scala:792)
        at scala.collection.immutable.List.foreach(List.scala:392)
        at scala.collection.TraversableLike$WithFilter.foreach(TraversableLike.scala:791)
        at dotty.tools.dotc.core.TypeOps.boundsViolations(TypeOps.scala:257)
        at dotty.tools.dotc.core.TypeOps.boundsViolations$(TypeOps.scala:254)
        at dotty.tools.dotc.core.Contexts$Context.boundsViolations(Contexts.scala:69)
        at dotty.tools.dotc.typer.Checking$.checkBounds(Checking.scala:47)
        at dotty.tools.dotc.typer.Checking$.checkBounds(Checking.scala:58)
        at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:231)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1223)
        at dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:62)
        at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:225)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1290)
        at dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:54)
        at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:253)
        at dotty.tools.dotc.transform.MacroTransform$Transformer.transformStat$1(MacroTransform.scala:42)
        at dotty.tools.dotc.transform.MacroTransform$Transformer.$anonfun$transformStats$1(MacroTransform.scala:45)
        at dotty.tools.dotc.core.Decorators$ListDecorator$.loop$1(Decorators.scala:62)
        at dotty.tools.dotc.core.Decorators$ListDecorator$.mapconserve$extension(Decorators.scala:78)
        at dotty.tools.dotc.transform.MacroTransform$Transformer.transformStats(MacroTransform.scala:45)
        at dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:60)
        at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.super$transform(PostTyper.scala:223)
        at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.$anonfun$transform$5(PostTyper.scala:249)
        at dotty.tools.dotc.transform.SuperAccessors.wrapTemplate(SuperAccessors.scala:177)
        at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.$anonfun$transform$4(PostTyper.scala:248)
        at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.withNoCheckNews(PostTyper.scala:90)
        at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:245)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1297)
        at dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:54)
        at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:267)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.$anonfun$transform$6(Trees.scala:1317)
        at scala.collection.immutable.List.mapConserve(List.scala:179)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1317)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transformStats(Trees.scala:1315)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1303)
        at dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:54)
        at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:324)
        at dotty.tools.dotc.transform.MacroTransform.run(MacroTransform.scala:21)
        at dotty.tools.dotc.core.Phases$Phase.$anonfun$runOn$1(Phases.scala:297)
        at scala.collection.immutable.List.map(List.scala:286)
        at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:295)
        at dotty.tools.dotc.Run.$anonfun$compileUnits$3(Run.scala:172)
        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:169)
        at dotty.tools.dotc.Run.$anonfun$compileUnits$2$adapted(Run.scala:167)
        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:167)
        at dotty.tools.dotc.Run.$anonfun$compileUnits$1(Run.scala:192)
        at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
        at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:90)
        at dotty.tools.dotc.Run.compileUnits(Run.scala:147)
        at dotty.tools.dotc.Run.compileUnits(Run.scala:139)
        at dotty.tools.repl.ReplCompiler.runCompilationUnit(ReplCompiler.scala:151)
        at dotty.tools.repl.ReplCompiler.compile(ReplCompiler.scala:160)
        at dotty.tools.repl.ReplDriver.compile(ReplDriver.scala:213)
        at dotty.tools.repl.ReplDriver.interpret(ReplDriver.scala:182)
        at dotty.tools.repl.ReplDriver.loop$1(ReplDriver.scala:127)
        at dotty.tools.repl.ReplDriver.$anonfun$runUntilQuit$2(ReplDriver.scala:130)
        at scala.util.DynamicVariable.withValue(DynamicVariable.scala:62)
        at scala.Console$.withErr(Console.scala:196)
        at dotty.tools.repl.ReplDriver.$anonfun$withRedirectedOutput$1(ReplDriver.scala:143)
        at scala.util.DynamicVariable.withValue(DynamicVariable.scala:62)
        at scala.Console$.withOut(Console.scala:167)
        at dotty.tools.repl.ReplDriver.withRedirectedOutput(ReplDriver.scala:143)
        at dotty.tools.repl.ReplDriver.runUntilQuit(ReplDriver.scala:130)
        at dotty.tools.repl.Main$.main(Main.scala:6)
        at dotty.tools.repl.Main.main(Main.scala)

Note that Test.foo.apply(()) works.

/cc @smarter

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions