Skip to content

dotc -Ytest-pickler fails on cyclic reference in valid Scala 2.12 code #3479

Closed
@abgruszecki

Description

@abgruszecki

dotc -Ytest-pickler fails on the following code:

sealed trait TermConstraint {
  final def neg: TermConstraint = this match {
    case Neg(c) => c
    case c: PositiveTermConstraint => Neg(c)
  }
}
case class Neg(c: PositiveTermConstraint) extends TermConstraint
sealed trait PositiveTermConstraint extends TermConstraint

case object Dummy extends PositiveTermConstraint
Compiler output

cannot take signature of (c: PositiveTermConstraint): Neg

cannot take signature of (): PositiveTermConstraint

exception occurred while compiling sample/3
Exception in thread "main" dotty.tools.dotc.core.Types$CyclicReference: cyclic reference involving class PositiveTermConstraint
	at dotty.tools.dotc.core.Types$CyclicReference$.apply(Types.scala:4432)
	at dotty.tools.dotc.core.SymDenotations$BaseDataImpl.apply(SymDenotations.scala:2111)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.baseData(SymDenotations.scala:1418)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.baseClassSet(SymDenotations.scala:1429)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.derivesFrom(SymDenotations.scala:1448)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.isValueClass(SymDenotations.scala:650)
	at dotty.tools.dotc.transform.ValueClasses$.isDerivedValueClass(ValueClasses.scala:19)
	at dotty.tools.dotc.core.TypeErasure.dotty$tools$dotc$core$TypeErasure$$sigName(TypeErasure.scala:516)
	at dotty.tools.dotc.core.TypeErasure$.sigName(TypeErasure.scala:142)
	at dotty.tools.dotc.core.Signature$$anonfun$prepend$1.applyOrElse(Signature.scala:87)
	at dotty.tools.dotc.core.Signature$$anonfun$prepend$1.applyOrElse(Signature.scala:87)
	at scala.collection.immutable.List.collect(List.scala:305)
	at dotty.tools.dotc.core.Signature.prepend(Signature.scala:87)
	at dotty.tools.dotc.core.Types$MethodType.computeSignature(Types.scala:2746)
	at dotty.tools.dotc.core.Types$MethodicType.signature(Types.scala:2503)
	at dotty.tools.dotc.core.Types$MethodicType.signature$(Types.scala:2501)
	at dotty.tools.dotc.core.Types$MethodType.signature(Types.scala:2728)
	at dotty.tools.dotc.core.Denotations$SingleDenotation.signature(Denotations.scala:609)
	at dotty.tools.dotc.core.Types$TermRef$.apply(Types.scala:2056)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.termRef(SymDenotations.scala:1136)
	at dotty.tools.dotc.typer.TypeAssigner.$anonfun$assignType$31(TypeAssigner.scala:526)
	at dotty.tools.dotc.core.Types$Type.orElse(Types.scala:104)
	at dotty.tools.dotc.typer.TypeAssigner.assignType(TypeAssigner.scala:526)
	at dotty.tools.dotc.typer.TypeAssigner.assignType$(TypeAssigner.scala:525)
	at dotty.tools.dotc.typer.Typer.assignType(Typer.scala:69)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.DefDef$1(TreeUnpickler.scala:634)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readNewDef(TreeUnpickler.scala:661)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readIndexedDef(TreeUnpickler.scala:607)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTemplate(TreeUnpickler.scala:751)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readNewDef(TreeUnpickler.scala:680)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readIndexedDef(TreeUnpickler.scala:607)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$Completer.complete(TreeUnpickler.scala:85)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:241)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeInfo$1(SymDenotations.scala:204)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.info(SymDenotations.scala:206)
	at dotty.tools.dotc.core.Types$NamedType.info(Types.scala:1808)
	at dotty.tools.dotc.core.Types$Type.isRef(Types.scala:129)
	at dotty.tools.dotc.typer.Checking$.preCheckKind(Checking.scala:113)
	at dotty.tools.dotc.typer.Checking$.$anonfun$preCheckKinds$1(Checking.scala:117)
	at dotty.tools.dotc.core.Decorators$ListDecorator$.zipWithConserve$extension(Decorators.scala:108)
	at dotty.tools.dotc.typer.Checking$.preCheckKinds(Checking.scala:117)
	at dotty.tools.dotc.typer.TypeAssigner.assignType(TypeAssigner.scala:411)
	at dotty.tools.dotc.typer.TypeAssigner.assignType$(TypeAssigner.scala:363)
	at dotty.tools.dotc.typer.Typer.assignType(Typer.scala:69)
	at dotty.tools.dotc.ast.tpd$.TypeApply(tpd.scala:47)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readLengthTerm$1(TreeUnpickler.scala:947)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTerm(TreeUnpickler.scala:1038)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readLengthTerm$1(TreeUnpickler.scala:938)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTerm(TreeUnpickler.scala:1038)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.$anonfun$readModifiers$2(TreeUnpickler.scala:530)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$LazyReader.complete(TreeUnpickler.scala:1099)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.$anonfun$readModifiers$4(TreeUnpickler.scala:533)
	at dotty.tools.dotc.core.Annotations$Annotation$$anon$2.complete(Annotations.scala:132)
	at dotty.tools.dotc.core.Annotations$LazyAnnotation.tree(Annotations.scala:43)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.$anonfun$readNewDef$9(TreeUnpickler.scala:705)
	at scala.collection.immutable.List.map(List.scala:287)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readNewDef(TreeUnpickler.scala:705)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readIndexedDef(TreeUnpickler.scala:607)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$Completer.complete(TreeUnpickler.scala:85)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:241)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeInfo$1(SymDenotations.scala:204)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.info(SymDenotations.scala:206)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.classParents(SymDenotations.scala:1365)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.computeBaseData(SymDenotations.scala:1434)
	at dotty.tools.dotc.core.SymDenotations$BaseDataImpl.apply(SymDenotations.scala:2115)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.baseData(SymDenotations.scala:1418)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.baseClasses(SymDenotations.scala:1425)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.$anonfun$computeBaseData$1(SymDenotations.scala:1439)
	at scala.collection.immutable.List.foreach(List.scala:389)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.computeBaseData(SymDenotations.scala:1437)
	at dotty.tools.dotc.core.SymDenotations$BaseDataImpl.apply(SymDenotations.scala:2115)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.baseData(SymDenotations.scala:1418)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.baseClassSet(SymDenotations.scala:1429)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.derivesFrom(SymDenotations.scala:1448)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.isValueClass(SymDenotations.scala:650)
	at dotty.tools.dotc.transform.ValueClasses$.isDerivedValueClass(ValueClasses.scala:19)
	at dotty.tools.dotc.core.TypeErasure.dotty$tools$dotc$core$TypeErasure$$sigName(TypeErasure.scala:516)
	at dotty.tools.dotc.core.TypeErasure$.sigName(TypeErasure.scala:142)
	at dotty.tools.dotc.core.Signature$.apply(Signature.scala:117)
	at dotty.tools.dotc.core.Types$MethodicType.resultSignature(Types.scala:2493)
	at dotty.tools.dotc.core.Types$MethodicType.resultSignature$(Types.scala:2489)
	at dotty.tools.dotc.core.Types$MethodType.resultSignature(Types.scala:2728)
	at dotty.tools.dotc.core.Types$MethodType.computeSignature(Types.scala:2746)
	at dotty.tools.dotc.core.Types$MethodicType.signature(Types.scala:2503)
	at dotty.tools.dotc.core.Types$MethodicType.signature$(Types.scala:2501)
	at dotty.tools.dotc.core.Types$MethodType.signature(Types.scala:2728)
	at dotty.tools.dotc.core.Denotations$SingleDenotation.signature(Denotations.scala:609)
	at dotty.tools.dotc.core.Types$TermRef$.apply(Types.scala:2056)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.termRef(SymDenotations.scala:1136)
	at dotty.tools.dotc.typer.TypeAssigner.$anonfun$assignType$31(TypeAssigner.scala:526)
	at dotty.tools.dotc.core.Types$Type.orElse(Types.scala:104)
	at dotty.tools.dotc.typer.TypeAssigner.assignType(TypeAssigner.scala:526)
	at dotty.tools.dotc.typer.TypeAssigner.assignType$(TypeAssigner.scala:525)
	at dotty.tools.dotc.typer.Typer.assignType(Typer.scala:69)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.DefDef$1(TreeUnpickler.scala:634)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readNewDef(TreeUnpickler.scala:661)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readIndexedDef(TreeUnpickler.scala:607)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTemplate(TreeUnpickler.scala:751)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readNewDef(TreeUnpickler.scala:680)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readIndexedDef(TreeUnpickler.scala:607)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readIndexedStat(TreeUnpickler.scala:796)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.$anonfun$readIndexedStats$1(TreeUnpickler.scala:834)
	at dotty.tools.dotc.core.tasty.TastyReader.until(TastyReader.scala:125)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readIndexedStats(TreeUnpickler.scala:834)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.$anonfun$readIndexedStat$2(TreeUnpickler.scala:802)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.processPackage(TreeUnpickler.scala:580)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readIndexedStat(TreeUnpickler.scala:801)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.read$1(TreeUnpickler.scala:786)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTopLevel(TreeUnpickler.scala:791)
	at dotty.tools.dotc.core.tasty.TreeUnpickler.unpickle(TreeUnpickler.scala:77)
	at dotty.tools.dotc.core.tasty.DottyUnpickler.computeBody$1(DottyUnpickler.scala:53)
	at dotty.tools.dotc.core.tasty.DottyUnpickler.body(DottyUnpickler.scala:58)
	at dotty.tools.dotc.transform.Pickler.$anonfun$testUnpickler$6(Pickler.scala:98)
	at dotty.tools.dotc.transform.Pickler.$anonfun$testUnpickler$6$adapted(Pickler.scala:97)
	at scala.collection.TraversableLike$WithFilter.$anonfun$foreach$1(TraversableLike.scala:789)
	at scala.collection.mutable.HashMap.$anonfun$foreach$1(HashMap.scala:138)
	at scala.collection.mutable.HashTable.foreachEntry(HashTable.scala:236)
	at scala.collection.mutable.HashTable.foreachEntry$(HashTable.scala:229)
	at scala.collection.mutable.HashMap.foreachEntry(HashMap.scala:40)
	at scala.collection.mutable.HashMap.foreach(HashMap.scala:138)
	at scala.collection.TraversableLike$WithFilter.foreach(TraversableLike.scala:788)
	at dotty.tools.dotc.transform.Pickler.testUnpickler(Pickler.scala:97)
	at dotty.tools.dotc.transform.Pickler.runOn(Pickler.scala:83)
	at dotty.tools.dotc.Run.$anonfun$compileUnits$3(Run.scala:125)
	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.util.Stats$.trackTime(Stats.scala:47)
	at dotty.tools.dotc.Run.$anonfun$compileUnits$2(Run.scala:123)
	at dotty.tools.dotc.Run.$anonfun$compileUnits$2$adapted(Run.scala:121)
	at scala.collection.IndexedSeqOptimized.foreach(IndexedSeqOptimized.scala:32)
	at scala.collection.IndexedSeqOptimized.foreach$(IndexedSeqOptimized.scala:29)
	at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:191)
	at dotty.tools.dotc.Run.runPhases$1(Run.scala:121)
	at dotty.tools.dotc.Run.$anonfun$compileUnits$1(Run.scala:141)
	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:86)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:107)
	at dotty.tools.dotc.Run.compileSources(Run.scala:94)
	at dotty.tools.dotc.Run.compile(Run.scala:78)
	at dotty.tools.dotc.Driver.doCompile(Driver.scala:26)
	at dotty.tools.dotc.Driver.process(Driver.scala:124)
	at dotty.tools.dotc.Driver.process(Driver.scala:93)
	at dotty.tools.dotc.Driver.process(Driver.scala:105)
	at dotty.tools.dotc.Driver.main(Driver.scala:132)
	at dotty.tools.dotc.Main.main(Main.scala)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions