Aladdin - Scala Bugtracking
[#783] project: compiler priority: low category: bug
submitter assigned to status date submitted
Sean Martin fixed 2006-10-19 15:35:30.0
subject case method through method call ignores method call
code
package test;

object Main extends Application {
  class Global {
    case class Template(x : Int, y : Int) {
      Console.println("outer: " + Global.this);
    }
  }
  trait Contexts requires Analyzer {
    val xxx : global.Template = {
      assert(globalInit0 != null);
      globalInit0.Template(10, 20);
    }
  }
  abstract class Analyzer extends Contexts {
    type Global <: Main.Global;
    final val global : Global = globalInit;
    def globalInit : Global;
    final def globalInit0 = globalInit.asInstanceOf[global.type];
  }
  
  object global0 extends Global {
    object analyzer extends Analyzer {
      type Global = global0.type;
      override def globalInit = global0;
    }
  }
  Console.println(global0.analyzer.xxx);
}
what happened
Exception in thread "main" java.lang.ExceptionInInitializerError
	at test.Main$.(Main.scala:28)
	at test.Main$.(Main.scala)
	at test.Main.main(Main.scala)
Caused by: java.lang.NullPointerException
	at test.Main$Global$Template.(Main.scala:5)
	at test.Main$Contexts$class.$init$(Main.scala:12)
	at test.Main$Analyzer.(Main.scala:15)
	at test.Main$global0$analyzer$.(Main.scala:23)
	at test.Main$global0$analyzer$.(Main.scala)
	... 3 more
what expected No sure. Because new globalInit.Template(10, 20) would be rejected by the compiler (globalInit is not a stable identifier), I would guess that globalInit.Template(10, 20) should be rejected also.
[back to overview]
Changes of this bug report
Martin  edited on  2006-10-26 16:41:31.0