Skip to content

Compiler crash with repeated enum #4470

Closed
@Blaisorblade

Description

@Blaisorblade

Source:

enum Maybe[A] {
  case Foo
}

enum Maybe[A] {
  case Foo
}

gives

-- Error: /Users/pgiarrusso/git/dotty-example-project/src/main/scala/playground/IDETest.scala:5:5
5 |enum Maybe[A] {
  |^
  |class Maybe has already been compiled once during this run
6 |  case Foo
7 |}
-- Error: /Users/pgiarrusso/git/dotty-example-project/src/main/scala/playground/IDETest.scala:2:7
2 |  case Foo
  |  ^^^^^^^^
  |  cannot determine type argument for enum parent class Maybe,
  |  type parameter type A is non variant
exception occurred while typechecking /Users/pgiarrusso/git/dotty-example-project/src/main/scala/playground/IDETest.scala
exception occurred while compiling /Users/pgiarrusso/git/dotty-example-project/src/main/scala/playground/IDETest.scala
Exception in thread "main" java.lang.AssertionError: NoDenotation.owner
	at dotty.tools.dotc.core.SymDenotations$NoDenotation$.owner(SymDenotations.scala:1899)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.typeRef(SymDenotations.scala:1164)
	at dotty.tools.dotc.ast.DesugarEnums$.enumScaffolding(DesugarEnums.scala:92)
	at dotty.tools.dotc.ast.DesugarEnums$.nextEnumTag(DesugarEnums.scala:182)
	at dotty.tools.dotc.ast.DesugarEnums$.expandSimpleEnumCase(DesugarEnums.scala:219)
	at dotty.tools.dotc.ast.DesugarEnums$.expandEnumModule(DesugarEnums.scala:199)
	at dotty.tools.dotc.ast.desugar$.moduleDef(Desugar.scala:654)
	at dotty.tools.dotc.ast.desugar$.defTree(Desugar.scala:773)
	at dotty.tools.dotc.typer.Namer.expand(Namer.scala:419)
	at dotty.tools.dotc.typer.Namer.$anonfun$index$18(Namer.scala:683)
	at dotty.tools.dotc.typer.Namer.$anonfun$index$18$adapted(Namer.scala:683)
	at scala.collection.immutable.List.foreach(List.scala:389)
	at dotty.tools.dotc.typer.Namer.index(Namer.scala:683)
	at dotty.tools.dotc.typer.Namer.indexAndAnnotate(Namer.scala:760)
	at dotty.tools.dotc.typer.Namer$ClassCompleter.completeInCreationContext(Namer.scala:982)
	at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:821)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:248)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeInfo$1(SymDenotations.scala:211)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.info(SymDenotations.scala:213)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:354)
	at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:1727)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1752)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1824)
	at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:1856)
	at dotty.tools.dotc.reporting.trace$.op1$3(trace.scala:32)
	at dotty.tools.dotc.reporting.trace$.apply(trace.scala:33)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1852)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1864)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:1883)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:1912)
	at dotty.tools.dotc.typer.Typer.$anonfun$typedPackageDef$1(Typer.scala:1631)
	at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
	at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:1624)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1804)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1825)
	at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:1856)
	at dotty.tools.dotc.reporting.trace$.op1$3(trace.scala:32)
	at dotty.tools.dotc.reporting.trace$.apply(trace.scala:33)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1852)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1864)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:1924)
	at dotty.tools.dotc.typer.FrontEnd.$anonfun$typeCheck$1(FrontEnd.scala:66)
	at dotty.tools.dotc.typer.FrontEnd.monitor(FrontEnd.scala:34)
	at dotty.tools.dotc.typer.FrontEnd.typeCheck(FrontEnd.scala:64)
	at dotty.tools.dotc.typer.FrontEnd.$anonfun$runOn$7(FrontEnd.scala:95)
	at dotty.tools.dotc.typer.FrontEnd.$anonfun$runOn$7$adapted(FrontEnd.scala:95)
	at scala.collection.immutable.List.foreach(List.scala:389)
	at dotty.tools.dotc.typer.FrontEnd.runOn(FrontEnd.scala:95)
	at dotty.tools.dotc.Run.$anonfun$compileUnits$3(Run.scala:174)
	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:171)
	at dotty.tools.dotc.Run.$anonfun$compileUnits$2$adapted(Run.scala:169)
	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:169)
	at dotty.tools.dotc.Run.$anonfun$compileUnits$1(Run.scala:194)
	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:88)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:149)
	at dotty.tools.dotc.Run.compileSources(Run.scala:136)
	at dotty.tools.dotc.Run.compile(Run.scala:120)
	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)

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