Skip to content

Code using structural type does not print error, crashes at Erasure #1866

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 Jan 1, 2017 · 1 comment
Closed

Comments

@helloqirun
Copy link

helloqirun commented Jan 1, 2017

scalac compiles but dotc crashes.
In particular, scalac-2.11 gives one warning but 2.9 gives none.

$ cat abc.scala

object Test {
  def f(g: { val update: Unit }) = g.update
  def main(update: Array[String]) = {}
}

$ dotc abc.scala

exception while typing g.update of class class dotty.tools.dotc.ast.Trees$Select # 75
exception while typing def f(g: Object{update: Unit}): Unit = g.update of class class dotty.tools.dotc.ast.Trees$DefDef # 102
exception while typing @scala.annotation.internal.SourceFile("abc.scala") final module class Test$()
   extends
 Object() {
  def f(g: Object{update: Unit}): Unit = g.update
  def main(update: Array{scala$Array$$T = String}): Unit =
    {
      ()
    }
} of class class dotty.tools.dotc.ast.Trees$TypeDef # 115
exception while typing package <empty> {
  final lazy module val Test: Test$ = new Test$()
  @scala.annotation.internal.SourceFile("abc.scala") final module class Test$()
     extends
   Object() {
    def f(g: Object{update: Unit}): Unit = g.update
    def main(update: Array{scala$Array$$T = String}): Unit =
      {
        ()
      }
  }
} of class class dotty.tools.dotc.ast.Trees$PackageDef # 116

exception occurred while compiling abc.scala
Exception in thread "main" java.lang.AssertionError: NoDenotation.owner
	at dotty.tools.dotc.core.SymDenotations$NoDenotation.owner(SymDenotations.scala:1854)
	at dotty.tools.dotc.transform.Erasure$Typer.mapOwner$1(Erasure.scala:358)
	at dotty.tools.dotc.transform.Erasure$Typer.typedSelect(Erasure.scala:362)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1470)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1534)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:96)
	at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1553)
	at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1551)
	at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:136)
	at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:57)
<...>
@smarter smarter changed the title crash on compilable code: NoDenotation.owner Code using structural type does not print error, crashes at Erasure Jan 1, 2017
odersky added a commit to dotty-staging/dotty that referenced this issue Jan 10, 2017
The PR also fixes scala#1866, as shown by this test case.
@odersky
Copy link
Contributor

odersky commented Jan 10, 2017

Fixed by separate PR.

@odersky odersky closed this as completed Jan 10, 2017
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

3 participants