Skip to content

Cyclic reference crashing compiler after emitted error #2533

Closed
@nicolasstucki

Description

@nicolasstucki
object Foo {
  def test(f: { type A = A }): Int = ???
}

crashes after emitting error

-- Error: foo.scala:4:21 -------------------------------------------------------
4 |  def test(f: { type A = A }): Int = ???
  |                     ^
  |illegal cyclic reference: alias <refinement>.this.A of type A refers back to the type itself

exception occurred while typechecking foo.scala

exception occurred while compiling foo.scala
Exception in thread "main" java.lang.AssertionError: assertion failed
	at scala.Predef$.assert(Predef.scala:156)
	at dotty.tools.dotc.core.Types$RefinedType.<init>(Types.scala:2159)
	at dotty.tools.dotc.core.Types$CachedRefinedType.<init>(Types.scala:2190)
	at dotty.tools.dotc.core.Uniques$RefinedUniques.newType$2(Uniques.scala:110)
	at dotty.tools.dotc.core.Uniques$RefinedUniques.enterIfNew(Uniques.scala:112)
	at dotty.tools.dotc.core.Types$RefinedType$.apply(Types.scala:2202)
	at dotty.tools.dotc.typer.TypeAssigner$class.addRefinement$1(TypeAssigner.scala:468)
	at dotty.tools.dotc.typer.TypeAssigner$$anonfun$19.apply(TypeAssigner.scala:470)
	at dotty.tools.dotc.typer.TypeAssigner$$anonfun$19.apply(TypeAssigner.scala:470)
	at scala.collection.LinearSeqOptimized$class.foldLeft(LinearSeqOptimized.scala:124)
	at scala.collection.immutable.List.foldLeft(List.scala:84)
	at scala.collection.TraversableOnce$class.$div$colon(TraversableOnce.scala:151)
	at scala.collection.AbstractTraversable.$div$colon(Traversable.scala:104)
	at dotty.tools.dotc.typer.TypeAssigner$class.assignType(TypeAssigner.scala:470)
	at dotty.tools.dotc.typer.Typer.assignType(Typer.scala:65)
	at dotty.tools.dotc.typer.Typer$$anonfun$typedRefinedTypeTree$1.apply(Typer.scala:1048)
	at dotty.tools.dotc.typer.Typer$$anonfun$typedRefinedTypeTree$1.apply(Typer.scala:1034)
	at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
	at dotty.tools.dotc.typer.Typer.typedRefinedTypeTree(Typer.scala:1034)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1550)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1572)
	at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1587)
	at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1585)
	at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:140)
	at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:57)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1585)
	at dotty.tools.dotc.typer.Namer$$anonfun$typedAheadType$1.apply(Namer.scala:931)
	at dotty.tools.dotc.typer.Namer$$anonfun$typedAheadType$1.apply(Namer.scala:931)
	at dotty.tools.dotc.typer.Namer.typedAheadImpl(Namer.scala:924)
	at dotty.tools.dotc.typer.Namer.typedAheadType(Namer.scala:931)
	at dotty.tools.dotc.typer.Namer.valOrDefDefSig(Namer.scala:1096)
	at dotty.tools.dotc.typer.Namer$Completer.typeSig(Namer.scala:729)
	at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:777)
	at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:755)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:219)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.info(SymDenotations.scala:197)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:336)
	at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:1479)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1504)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1571)
	at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1587)
	at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1585)
	at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:140)
	at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:57)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1585)
	at dotty.tools.dotc.typer.Namer$$anonfun$typedAheadExpr$1.apply(Namer.scala:934)
	at dotty.tools.dotc.typer.Namer$$anonfun$typedAheadExpr$1.apply(Namer.scala:934)
	at dotty.tools.dotc.typer.Namer.typedAheadImpl(Namer.scala:924)
	at dotty.tools.dotc.typer.Namer.typedAheadExpr(Namer.scala:934)
	at dotty.tools.dotc.typer.Namer$$anonfun$completeParams$1.apply(Namer.scala:946)
	at dotty.tools.dotc.typer.Namer$$anonfun$completeParams$1.apply(Namer.scala:946)
	at scala.collection.immutable.List.foreach(List.scala:392)
	at dotty.tools.dotc.typer.Namer.completeParams(Namer.scala:946)
	at dotty.tools.dotc.typer.Namer$$anonfun$defDefSig$3.apply(Namer.scala:1131)
	at dotty.tools.dotc.typer.Namer$$anonfun$defDefSig$3.apply(Namer.scala:1131)
	at scala.collection.immutable.List.foreach(List.scala:392)
	at dotty.tools.dotc.typer.Namer.defDefSig(Namer.scala:1131)
	at dotty.tools.dotc.typer.Namer$Completer.typeSig(Namer.scala:733)
	at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:777)
	at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:755)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:219)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.info(SymDenotations.scala:197)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:336)
	at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:1479)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1504)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1571)
	at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1587)
	at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1585)
	at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:140)
	at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:57)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1585)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:1609)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:1629)
	at dotty.tools.dotc.typer.Typer$$anonfun$typedClassDef$1.apply(Typer.scala:1319)
	at dotty.tools.dotc.typer.Typer$$anonfun$typedClassDef$1.apply(Typer.scala:1267)
	at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
	at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:1267)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1517)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1571)
	at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1587)
	at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1585)
	at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:140)
	at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:57)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1585)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:1609)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:1629)
	at dotty.tools.dotc.typer.Typer$$anonfun$typedPackageDef$1.apply(Typer.scala:1432)
	at dotty.tools.dotc.typer.Typer$$anonfun$typedPackageDef$1.apply(Typer.scala:1419)
	at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
	at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:1419)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1556)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1572)
	at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1587)
	at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1585)
	at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:140)
	at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:57)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1585)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:1641)
	at dotty.tools.dotc.typer.FrontEnd$$anonfun$typeCheck$1.apply$mcV$sp(FrontEnd.scala:64)
	at dotty.tools.dotc.typer.FrontEnd.monitor(FrontEnd.scala:32)
	at dotty.tools.dotc.typer.FrontEnd.typeCheck(FrontEnd.scala:62)
	at dotty.tools.dotc.typer.FrontEnd$$anonfun$runOn$3.apply(FrontEnd.scala:93)
	at dotty.tools.dotc.typer.FrontEnd$$anonfun$runOn$3.apply(FrontEnd.scala:93)
	at scala.collection.immutable.List.foreach(List.scala:392)
	at dotty.tools.dotc.typer.FrontEnd.runOn(FrontEnd.scala:93)
	at dotty.tools.dotc.Run$$anonfun$compileUnits$1$$anonfun$apply$mcV$sp$1.apply(Run.scala:82)
	at dotty.tools.dotc.Run$$anonfun$compileUnits$1$$anonfun$apply$mcV$sp$1.apply(Run.scala:79)
	at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)
	at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:186)
	at dotty.tools.dotc.Run$$anonfun$compileUnits$1.apply$mcV$sp(Run.scala:79)
	at dotty.tools.dotc.Run$$anonfun$compileUnits$1.apply(Run.scala:67)
	at dotty.tools.dotc.Run$$anonfun$compileUnits$1.apply(Run.scala:67)
	at dotty.tools.dotc.util.Stats$.monitorHeartBeat(Stats.scala:76)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:67)
	at dotty.tools.dotc.Run.compileSources(Run.scala:64)
	at dotty.tools.dotc.Run.compile(Run.scala:48)
	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

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions