Skip to content

Cyclic reference when using -Ycheck-init flag #9229

Closed
@flomebul

Description

@flomebul

Minimized code

package queries

class ABug2 {
  class Link
  object Link
  def Link(tag: String): Link = ???
}
import queries.ABug2

object ABug3 {
  val bug2 = new ABug2 // No crash with check-init
  object graph extends ABug2 // <<= crach with check-init
}

Output (click arrow to expand)

same behavior with 0.24-RC1 and 0.25-RC2

Command line for compilation
/cygdrive/c/scala/dotty-0.24/bin/dotc -classpath ../../bin -extdirs ../../lib -indent -new-syntax -migration -d ../../bin -deprecation -feature -unchecked -Xfatal-warnings -Yexplicit-nulls -Ycheck-init ABug3.scala

error while transforming module class Link$
exception occurred while compiling ABug3.scala
Cyclic reference involving class Link while compiling ABug3.scala
Exception in thread "main" dotty.tools.dotc.core.CyclicReference: 
	at dotty.tools.dotc.core.CyclicReference$.apply(TypeErrors.scala:156)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:257)
	at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:186)
	at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:188)
	at dotty.tools.dotc.core.Types$NamedType.info(Types.scala:1958)
	at dotty.tools.dotc.core.Types$$anon$5.apply(Types.scala:3249)
	at dotty.tools.dotc.core.Types$$anon$5.apply(Types.scala:3242)
	at dotty.tools.dotc.core.Types$TermLambda.dotty$tools$dotc$core$Types$TermLambda$$depStatus(Types.scala:3259)
	at dotty.tools.dotc.core.Types$TermLambda.dependencyStatus(Types.scala:3273)
	at dotty.tools.dotc.core.Types$TermLambda.resultType(Types.scala:3216)
	at dotty.tools.dotc.core.Types$MethodType.resultType(Types.scala:3318)
	at dotty.tools.dotc.printing.PlainPrinter.toText$$anonfun$14$$anonfun$12(PlainPrinter.scala:191)
	at dotty.tools.dotc.printing.Printer.atPrec(Printer.scala:42)
	at dotty.tools.dotc.printing.Printer.changePrec(Printer.scala:71)
	at dotty.tools.dotc.printing.PlainPrinter.toText$$anonfun$1(PlainPrinter.scala:193)
	at dotty.tools.dotc.printing.MessageLimiter.controlled(MessageLimiter.scala:23)
	at dotty.tools.dotc.printing.PlainPrinter.controlled(PlainPrinter.scala:31)
	at dotty.tools.dotc.printing.PlainPrinter.toText(PlainPrinter.scala:230)
	at dotty.tools.dotc.printing.RefinedPrinter.toText$$anonfun$1(RefinedPrinter.scala:256)
	at dotty.tools.dotc.printing.MessageLimiter.controlled(MessageLimiter.scala:23)
	at dotty.tools.dotc.printing.PlainPrinter.controlled(PlainPrinter.scala:31)
	at dotty.tools.dotc.printing.RefinedPrinter.toText(RefinedPrinter.scala:258)
	at dotty.tools.dotc.core.Types$Type.toText(Types.scala:1653)
	at dotty.tools.dotc.printing.Showable.show(Showable.scala:23)
	at dotty.tools.dotc.core.Types$Type.show(Types.scala:92)
	at dotty.tools.dotc.core.Denotations$SingleDenotation.signature$$anonfun$1(Denotations.scala:743)
	at dotty.tools.dotc.reporting.NoExplanation.msg(Message.scala:122)
	at dotty.tools.dotc.reporting.Message.message(Message.scala:80)
	at dotty.tools.dotc.reporting.Message.isNonSensical(Message.scala:92)
	at dotty.tools.dotc.reporting.HideNonSensicalMessages.isHidden(HideNonSensicalMessages.scala:16)
	at dotty.tools.dotc.reporting.AbstractReporter.isHidden(AbstractReporter.scala:8)
	at dotty.tools.dotc.reporting.Reporter.report(Reporter.scala:265)
	at dotty.tools.dotc.reporting.Reporting.echo(Reporter.scala:78)
	at dotty.tools.dotc.core.Contexts$Context.echo(Contexts.scala:78)
	at dotty.tools.dotc.core.Denotations$SingleDenotation.signature(Denotations.scala:743)
	at dotty.tools.dotc.core.Denotations$SingleDenotation.matches(Denotations.scala:1120)
	at dotty.tools.dotc.core.Denotations$MultiPreDenotation.matches(Denotations.scala:1264)
	at dotty.tools.dotc.core.Denotations$DenotUnion.matches(Denotations.scala:1280)
	at dotty.tools.dotc.core.Denotations$SingleDenotation.filterDisjoint(Denotations.scala:1137)
	at dotty.tools.dotc.core.Denotations$SingleDenotation.mapInherited(Denotations.scala:1132)
	at dotty.tools.dotc.core.Denotations$SingleDenotation.mapInherited(Denotations.scala:1129)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.collect$1(SymDenotations.scala:1915)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.computeNPMembersNamed(SymDenotations.scala:1923)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.nonPrivateMembersNamed(SymDenotations.scala:1890)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.membersNamed(SymDenotations.scala:1877)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.findMember(SymDenotations.scala:1927)
	at dotty.tools.dotc.core.Types$Type.go$1(Types.scala:582)
	at dotty.tools.dotc.core.Types$Type.goThis$1(Types.scala:696)
	at dotty.tools.dotc.core.Types$Type.go$1(Types.scala:599)
	at dotty.tools.dotc.core.Types$Type.findMember(Types.scala:750)
	at dotty.tools.dotc.core.Types$Type.memberBasedOnFlags(Types.scala:565)
	at dotty.tools.dotc.core.Types$Type.member(Types.scala:549)
	at dotty.tools.dotc.core.Types$NamedType.memberDenot(Types.scala:2046)
	at dotty.tools.dotc.core.Types$NamedType.memberDenot(Types.scala:2033)
	at dotty.tools.dotc.core.Types$NamedType.fromDesignator$1(Types.scala:1989)
	at dotty.tools.dotc.core.Types$NamedType.computeDenot(Types.scala:2013)
	at dotty.tools.dotc.core.Types$NamedType.denot(Types.scala:1969)
	at dotty.tools.dotc.core.Types$NamedType.computeSymbol(Types.scala:1927)
	at dotty.tools.dotc.core.Types$NamedType.symbol(Types.scala:1920)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.sourceOfSelf$1(SymDenotations.scala:1065)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.sourceModule(SymDenotations.scala:1069)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.scalacLinkedClass(SymDenotations.scala:1223)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readNewDef(TreeUnpickler.scala:827)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readIndexedDef(TreeUnpickler.scala:760)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$Completer.complete(TreeUnpickler.scala:118)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:259)
	at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:186)
	at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:188)
	at dotty.tools.dotc.core.Types$NamedType.info(Types.scala:1958)
	at dotty.tools.dotc.core.Types$$anon$5.apply(Types.scala:3249)
	at dotty.tools.dotc.core.Types$$anon$5.apply(Types.scala:3242)
	at dotty.tools.dotc.core.Types$TermLambda.dotty$tools$dotc$core$Types$TermLambda$$depStatus(Types.scala:3259)
	at dotty.tools.dotc.core.Types$TermLambda.dependencyStatus(Types.scala:3273)
	at dotty.tools.dotc.core.Types$TermLambda.resultType(Types.scala:3216)
	at dotty.tools.dotc.core.Types$MethodType.resultType(Types.scala:3318)
	at dotty.tools.dotc.core.Types$TypeMap.mapOverLambda$1(Types.scala:4918)
	at dotty.tools.dotc.core.Types$TypeMap.mapOver(Types.scala:4925)
	at dotty.tools.dotc.typer.Checking$NotPrivate$1.apply(Checking.scala:585)
	at dotty.tools.dotc.typer.Checking$.checkNoPrivateLeaks(Checking.scala:589)
	at dotty.tools.dotc.typer.TypeAssigner.avoidPrivateLeaks(TypeAssigner.scala:165)
	at dotty.tools.dotc.typer.Typer.avoidPrivateLeaks(Typer.scala:85)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readNewDef(TreeUnpickler.scala:871)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readIndexedDef(TreeUnpickler.scala:760)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$Completer.complete(TreeUnpickler.scala:118)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:259)
	at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:186)
	at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:188)
	at dotty.tools.dotc.core.Denotations$SingleDenotation.signature(Denotations.scala:738)
	at dotty.tools.dotc.core.Denotations$SingleDenotation.matches(Denotations.scala:1120)
	at dotty.tools.dotc.core.Denotations$MultiPreDenotation.matches(Denotations.scala:1264)
	at dotty.tools.dotc.core.Denotations$DenotUnion.matches(Denotations.scala:1280)
	at dotty.tools.dotc.core.Denotations$SingleDenotation.filterDisjoint(Denotations.scala:1137)
	at dotty.tools.dotc.core.Denotations$SingleDenotation.mapInherited(Denotations.scala:1132)
	at dotty.tools.dotc.core.Denotations$SingleDenotation.mapInherited(Denotations.scala:1129)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.collect$1(SymDenotations.scala:1915)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.computeNPMembersNamed(SymDenotations.scala:1923)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.nonPrivateMembersNamed(SymDenotations.scala:1890)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.membersNamed(SymDenotations.scala:1877)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.findMember(SymDenotations.scala:1927)
	at dotty.tools.dotc.core.Types$Type.go$1(Types.scala:582)
	at dotty.tools.dotc.core.Types$Type.goThis$1(Types.scala:696)
	at dotty.tools.dotc.core.Types$Type.go$1(Types.scala:599)
	at dotty.tools.dotc.core.Types$Type.findMember(Types.scala:750)
	at dotty.tools.dotc.core.tasty.TreeUnpickler.dotty$tools$dotc$core$tasty$TreeUnpickler$TreeReader$$_$accessibleDenot$1(TreeUnpickler.scala:1063)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.completeSelect$1(TreeUnpickler.scala:1046)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readSimpleTerm$1(TreeUnpickler.scala:1078)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTerm(TreeUnpickler.scala:1235)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readSimpleTerm$1(TreeUnpickler.scala:1091)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTerm(TreeUnpickler.scala:1235)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTpt(TreeUnpickler.scala:1265)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTemplate(TreeUnpickler.scala:917)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readNewDef(TreeUnpickler.scala:836)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readIndexedDef(TreeUnpickler.scala:760)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$Completer.complete(TreeUnpickler.scala:118)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:259)
	at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:186)
	at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:188)
	at dotty.tools.dotc.core.DenotTransformers$InfoTransformer.transform(DenotTransformers.scala:42)
	at dotty.tools.dotc.transform.FirstTransform.transform(FirstTransform.scala:36)
	at dotty.tools.dotc.core.Denotations$SingleDenotation.current(Denotations.scala:947)
	at dotty.tools.dotc.core.Denotations$SingleDenotation.current(Denotations.scala:968)
	at dotty.tools.dotc.core.Symbols$Symbol.recomputeDenot(Symbols.scala:495)
	at dotty.tools.dotc.core.Symbols$Symbol.computeDenot(Symbols.scala:490)
	at dotty.tools.dotc.core.Symbols$Symbol.denot(Symbols.scala:484)
	at dotty.tools.dotc.core.Symbols$.toDenot(Symbols.scala:856)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.paramAccessors$$anonfun$1(SymDenotations.scala:2134)
	at dotty.tools.dotc.core.Scopes$Scope.filter(Scopes.scala:102)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.paramAccessors(SymDenotations.scala:2134)
	at dotty.tools.dotc.transform.init.Checking$.checkClassBody$$anonfun$1(Checking.scala:93)
	at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.transform.init.Util$.traceOp(Util.scala:18)
	at dotty.tools.dotc.transform.init.Checking$.checkClassBody(Checking.scala:121)
	at dotty.tools.dotc.transform.init.Checking$.checkCtor$2(Checking.scala:86)
	at dotty.tools.dotc.transform.init.Checking$.checkClassBody$$anonfun$3$$anonfun$2(Checking.scala:111)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.immutable.List.foreach(List.scala:333)
	at dotty.tools.dotc.transform.init.Checking$.checkClassBody$$anonfun$1(Checking.scala:116)
	at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.transform.init.Util$.traceOp(Util.scala:18)
	at dotty.tools.dotc.transform.init.Checking$.checkClassBody(Checking.scala:121)
	at dotty.tools.dotc.transform.init.Checker.transformTypeDef(Checker.scala:58)
	at dotty.tools.dotc.transform.MegaPhase.goTypeDef(MegaPhase.scala:956)
	at dotty.tools.dotc.transform.MegaPhase.goTypeDef(MegaPhase.scala:957)
	at dotty.tools.dotc.transform.MegaPhase.transformNamed$1(MegaPhase.scala:252)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:394)
	at dotty.tools.dotc.transform.MegaPhase.transformStat$2(MegaPhase.scala:404)
	at dotty.tools.dotc.transform.MegaPhase.$anonfun$1(MegaPhase.scala:409)
	at scala.collection.immutable.List.mapConserve(List.scala:472)
	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$2(MegaPhase.scala:404)
	at dotty.tools.dotc.transform.MegaPhase.$anonfun$1(MegaPhase.scala:409)
	at scala.collection.immutable.List.mapConserve(List.scala:472)
	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.runOn$$anonfun$1(Phases.scala:318)
	at scala.collection.immutable.List.map(List.scala:246)
	at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:319)
	at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:165)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
	at dotty.tools.dotc.Run.runPhases$5(Run.scala:175)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:183)
	at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:64)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:190)
	at dotty.tools.dotc.Run.compileSources(Run.scala:127)
	at dotty.tools.dotc.Run.compile(Run.scala:110)
	at dotty.tools.dotc.Driver.doCompile(Driver.scala:38)
	at dotty.tools.dotc.Driver.process(Driver.scala:194)
	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:202)
	at dotty.tools.dotc.Main.main(Main.scala)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions