Aladdin - Scala Bugtracking
[#1123] project: compiler priority: low category: bug
submitter assigned to status date submitted
Sean Martin fixed 2007-05-21 12:43:55.0
subject Verify error with private objects (again...)
code
package test;
object Test {
  class Editor {
    private object extraListener {
      def h : AnyRef = (extraListener)
    }
    def f = extraListener.h
  }
  def main(args : Array[String]) : Unit = (new Editor).f    
}
what happened
Exception in thread "main" java.lang.VerifyError: (class: test/Test$Editor$extraListener$, method: h signat\
ure: ()Ljava/lang/Object;) Illegal use of nonvirtual function call
	at test.Test$Editor.extraListener(Test.scala:5)
	at test.Test$Editor.f(Test.scala:8)
	at test.Test$.main(Test.scala:10)
	at test.Test.main(Test.scala)
what expected
[back to overview]
Changes of this bug report
Iulian  edited on  2007-05-22 10:04:01.0
It seems the call to extraListener from inside private object extraListener is touching a private method of its outer class. def h: AnyRef = this.outer$1.extraListener() Explcit outer takes care of such cases by mangling and removing the private modifier, but specifically skips the case when it involves an inner private object. Since it's code written by Martin, I reassign this to him, as I don't know what would break if I remove that check.
Martin  edited on  2007-05-30 12:52:19.0
I can't see what's wrong here. Iulian, can you help?
Iulian  edited on  2007-05-30 14:34:18.0
The call to 'extraListener' from within private object is at fault here. Since 'extraListener' is private within class Editor, and the object itself is lifted outside, it's call to extraListner inside method 'h' is illegal. The general case is handled by removing the private modifier and name mangling, but explicitouter does not do this transformation for private objects (I don't know why, it's in ExplicitOuter.scala, line 368). The backend simply generates a call to a private method, which then fails verification.
Martin  edited on  2007-05-30 16:11:19.0
Thanks for the explanations, Iulian. I think it's fixed now.
Martin  edited on  2007-05-30 16:13:19.0