Skip to content

crash on compilable code: assertion failed: symbol (method companion$module) entered the scope of non-class owner type B #1771

Closed
@helloqirun

Description

@helloqirun

scalac compiles but dotc crashes.

$ cat abc.scala

class GBTree[B] {
  class Tree[A, B]; class Node[A, B](value: Node[A, B]) extends Tree[A, B]
  case class B[A, B]() extends Tree[A, B]
}

$ dotc abc.scala

-- Error: abc.scala ------------------------------------------------------------
3 |  case class B[A, B]() extends Tree[A, B]
  |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |  B is already defined as type B

exception occurred while typechecking abc.scala

exception occurred while compiling abc.scala
Exception in thread "main" java.lang.AssertionError: assertion failed: symbol (method companion$module) entered the scope of non-class owner type B
	at scala.Predef$.assert(Predef.scala:165)
	at dotty.tools.dotc.core.Symbols$Symbol.entered(Symbols.scala:429)
	at dotty.tools.dotc.typer.Namer.dotty$tools$dotc$typer$Namer$$createLinks$1(Namer.scala:518)
	at dotty.tools.dotc.typer.Namer$$anonfun$createCompanionLinks$1$2.apply(Namer.scala:525)
	at dotty.tools.dotc.typer.Namer$$anonfun$createCompanionLinks$1$2.apply(Namer.scala:522)
	at scala.collection.TraversableLike$WithFilter$$anonfun$foreach$1.apply(TraversableLike.scala:778)
	at scala.collection.mutable.HashMap$$anon$2$$anonfun$foreach$3.apply(HashMap.scala:108)
	at scala.collection.mutable.HashMap$$anon$2$$anonfun$foreach$3.apply(HashMap.scala:108)
<snipped>

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