Skip to content

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

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
helloqirun opened this issue Dec 4, 2016 · 1 comment

Comments

@helloqirun
Copy link

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>
@odersky
Copy link
Contributor

odersky commented Dec 4, 2016

I think this one is as intended, but we need to spec it. It's clearly very dubious code to have a parameter of a class with the same name as a type member.

But of course there should be no crash.

odersky added a commit that referenced this issue Jan 26, 2018
Fix #1771: Harden namer in the presence of double definitions
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

2 participants