Skip to content

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

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

Closed
abgruszecki opened this issue Nov 15, 2017 · 10 comments
Closed

Comments

@abgruszecki
Copy link
Contributor

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)

@odersky
Copy link
Contributor

odersky commented Nov 16, 2017

I could not reproduce it. It seems to work fine for me.

@odersky odersky closed this as completed Nov 16, 2017
@abgruszecki
Copy link
Contributor Author

Confirmed - it works for me on master as well. Closest commit I've tested where it still breaks is 253f505.

@abgruszecki
Copy link
Contributor Author

abgruszecki commented Nov 16, 2017

@odersky @smarter reopen? The exception still happens if a package is added:

package dotty.tools.dotc.transform.patmat

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
Exception

cannot take signature of (c: dotty.tools.dotc.transform.patmat.PositiveTermConstraint):
  dotty.tools.dotc.transform.patmat.Neg

cannot take signature of (): dotty.tools.dotc.transform.patmat.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:4435)
	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:29)
	at dotty.tools.dotc.Driver.process(Driver.scala:127)
	at dotty.tools.dotc.Driver.process(Driver.scala:96)
	at dotty.tools.dotc.Driver.process(Driver.scala:108)
	at dotty.tools.dotc.Driver.main(Driver.scala:135)
	at dotty.tools.dotc.Main.main(Main.scala)

Note the stacktrace is slightly different this time.

The file on which this occurs is this. I'll try to rewrite the code to not trigger this and see if an exception doesn't happen somewhere else on that branch.

EDIT: tested on f16f71a.

@smarter smarter reopened this Nov 16, 2017
@abgruszecki
Copy link
Contributor Author

After testing, it appears that neg method is actually irrelevant. The smallest file with which I've triggered the exception is:

package dotty.tools
sealed trait TermConstraint
case class Neg(c: PositiveTermConstraint) extends TermConstraint
trait PositiveTermConstraint extends TermConstraint

Removing anything will stop triggering the problem, including removing either package name.

@allanrenucci
Copy link
Contributor

Inverting the last two definitions also solves the issue.

@abgruszecki
Copy link
Contributor Author

abgruszecki commented Nov 20, 2017

I've been to apply the above workaround to #3454 after rebasing it, without any success. While inverting the definitions works for the minimal example, it doesn't work for the original file. For instance, on current master cc43c34, running dotc -classpath interfaces/target/dotty-interfaces-0.5.0-bin-SNAPSHOT.jar -Ytest-pickler sample/3a, where sample/3a is:

package dotty.tools.dotc.transform.patmat
sealed trait TermConstraint
sealed trait PositiveTermConstraint extends TermConstraint
case class Neg(c: PositiveTermConstraint) extends TermConstraint
case object Dummy extends PositiveTermConstraint
case object AlwaysSatisfied extends PositiveTermConstraint

emits the same error. This time, commenting out either Dummy or AlwaysSatisfied works, but commenting out Dummy (almost unused) in the real file doesn't.

I've uploaded the rebased PR at AleksanderBG/dotty@04b6d5c7172b4b75e471c06aa092c3b885d99bfb - original file is compiler/src/dotty/tools/dotc/transform/patmat/Spaces.scala. If that's relevant, I've been running the pickler tests with testOnly dotty.tools.dotc.CompilationTests -- --tests=testPickling.

@allanrenucci
Copy link
Contributor

This issue seems to be a duplicate of #1932

@abgruszecki
Copy link
Contributor Author

@allanrenucci That's actually very helpful, thanks! I just quickly checked and removing sealed from TermConstraint works on the rebased PR - I should've tried that from the beginning. If this issue is a duplicate, then I guess it can be closed now.

@odersky
Copy link
Contributor

odersky commented Jan 2, 2018

#1932 works OK for me now. Can someone check whether the issue here is also fixed?

@abgruszecki
Copy link
Contributor Author

Work OK for me too on latest master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants