Skip to content

Second child of sealed trait in REPL on separate lines crashes #15629

Closed
@som-snytt

Description

@som-snytt

Compiler version

HEAD

Minimized code

./bin/scala
Welcome to Scala 3.2.1-RC1-bin-SNAPSHOT-git-baf21dd (18.0.1.1, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.

scala> sealed trait State
// defined trait State

scala> final class On extends State
-- [E112] Syntax Error: ------------------------------------------------------------------------------------------------
1 |final class On extends State
  |            ^
  |            Cannot extend sealed trait State in a different source file
  |
  | longer explanation available when compiling with `-explain`
1 error found

scala> final class Off extends State

Output (click arrow to expand)

Exception in thread "main" java.lang.AssertionError: assertion failed: duplicate child annotation class Off / class On
        at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
        at dotty.tools.dotc.typer.Namer.insertInto$1(Namer.scala:481)
        at dotty.tools.dotc.typer.Namer.addChild(Namer.scala:488)
        at dotty.tools.dotc.typer.Namer$Completer.register$1(Namer.scala:899)
        at dotty.tools.dotc.typer.Namer$Completer.registerIfChild$$anonfun$1(Namer.scala:908)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:333)
        at dotty.tools.dotc.typer.Namer$Completer.registerIfChild(Namer.scala:908)
        at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:811)
        at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:171)
        at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:187)
        at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:189)
        at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:373)
        at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:2822)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2847)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2943)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3009)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3013)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3035)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3085)
        at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2520)
        at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:2869)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2873)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2943)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3009)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3013)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3035)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3085)
        at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2651)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2914)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2944)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3009)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3013)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3129)
        at dotty.tools.dotc.typer.TyperPhase.typeCheck$$anonfun$1(TyperPhase.scala:44)
        at dotty.tools.dotc.typer.TyperPhase.typeCheck$$anonfun$adapted$1(TyperPhase.scala:51)
        at scala.Function0.apply$mcV$sp(Function0.scala:39)
        at dotty.tools.dotc.core.Phases$Phase.monitor(Phases.scala:417)
        at dotty.tools.dotc.typer.TyperPhase.typeCheck(TyperPhase.scala:51)
        at dotty.tools.dotc.typer.TyperPhase.runOn$$anonfun$3(TyperPhase.scala:85)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:333)
        at dotty.tools.dotc.typer.TyperPhase.runOn(TyperPhase.scala:85)
        at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:234)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1328)
        at dotty.tools.dotc.Run.runPhases$1(Run.scala:245)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:253)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:262)
        at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:68)
        at dotty.tools.dotc.Run.compileUnits(Run.scala:262)
        at dotty.tools.dotc.Run.compileUnits(Run.scala:192)
        at dotty.tools.repl.ReplCompiler.runCompilationUnit(ReplCompiler.scala:166)
        at dotty.tools.repl.ReplCompiler.compile(ReplCompiler.scala:177)
        at dotty.tools.repl.ReplDriver.compile(ReplDriver.scala:287)
        at dotty.tools.repl.ReplDriver.interpret(ReplDriver.scala:249)
        at dotty.tools.repl.ReplDriver.loop$1(ReplDriver.scala:168)
        at dotty.tools.repl.ReplDriver.runUntilQuit$$anonfun$1(ReplDriver.scala:171)
        at dotty.tools.repl.ReplDriver.withRedirectedOutput(ReplDriver.scala:192)
        at dotty.tools.repl.ReplDriver.runBody$$anonfun$1(ReplDriver.scala:180)
        at dotty.tools.runner.ScalaClassLoader$.asContext(ScalaClassLoader.scala:80)
        at dotty.tools.repl.ReplDriver.runBody(ReplDriver.scala:180)
        at dotty.tools.repl.ReplDriver.runUntilQuit(ReplDriver.scala:171)
        at dotty.tools.repl.ReplDriver.tryRunning(ReplDriver.scala:133)
        at dotty.tools.repl.Main$.main(Main.scala:7)
        at dotty.tools.MainGenericRunner$.run$1(MainGenericRunner.scala:193)
        at dotty.tools.MainGenericRunner$.main(MainGenericRunner.scala:268)
        at dotty.tools.MainGenericRunner.main(MainGenericRunner.scala)

I pasted a sealed trait from the erased defs docs. I thought JLine would take the paste as a unit. Was that just a pipe dream? It used to detect paste by how fast the characters arrived.

Anyway, I don't know what the error message means, but it probably shouldn't do that.

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