Aladdin - Scala Bugtracking
[#582] project: compiler priority: medium category: bug
submitter assigned to status date submitted
Stephane Martin fixed 2006-04-28 16:25:25.0
subject NullPointerException in Erasure phase
code
// File: myjava/test4.java
package myjava;
public class test4 {
    public int x = 2;
    public class inner4 {
        public int y = 3;
    }
}

// File: myscala/test4.scala
package myscala
object test4 {
  def main(args: Array[String]): Unit = {
    val m = new myjava.test4
    val n = new myjava.test4#inner4(m)
    Console.println("test4: " + m.x)
    Console.println("test4: " + n.y)
  }
}
what happened
Exception in thread "main" java.lang.NullPointerException
        at scala.tools.nsc.transform.Erasure$Eraser.adaptMember(Erasure.scala:305)
        at scala.tools.nsc.transform.Erasure$Eraser.typed1(Erasure.scala:363)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:1625)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:1655)
[..]
what expected Compiled code displays values "2" and "3"
[back to overview]
Changes of this bug report
Martin  edited on  2006-08-20 19:01:35.0
Since Iulian has now taken the lead to make Scala compatible with Java's inner classes, I reassign this to him.
Iulian  edited on  2006-08-23 15:41:08.0
This is not related to Java inner classes. Here's a simpler way to reproduce it:
class B;
class O {
  type I = B;
  val n = new O#I;
}
Apparently the 'SelectFromTypeTree' node has a null 'tpe' when it reaches adaptMember (which matches on this node and uses an if guard on it). I couldn't figure out why it's null (it's correct when reaching phase erasure, so it's nullified during this phase). I reassign this to Martin since I am lost in the mixin code.
Martin  edited on  2006-10-26 16:44:15.0
Fixed by Iulians changes to outer pointers, I guess.