Aladdin - Scala Bugtracking
[#629] project: compiler priority: low category: bug
submitter assigned to status date submitted
Nikolay Martin fixed 2006-06-19 15:26:43.0
subject [contrib #157] VerifyError: Illegal use of nonvirtual function call
code
object Test
{
    def main(args : Array[String]) : Unit = Console.println(new C(1))
}

abstract class A(val x : Int)

class C(x : Int) extends A(x)
{
    val v = new D
    class D { def value = x }
}
what happened
At runtime:

Exception in thread "main" java.lang.VerifyError: (class: C$D, method: value signature: ()I) Illegal use of nonv\
irtual function call
        at C.(test.scala:10)
        at Test$.main(test.scala:3)
        at Test.main(test.scala)
what expected Prints something like: C@b8df17
[back to overview]
Changes of this bug report
Nikolay  edited on  2006-06-19 15:27:15.0
Iulian  edited on  2006-06-19 17:41:46.0
It seems that an 'outer' reference is missing. Here's the output after mixin: class C$D { ... def value(): scala.Int = C.super[A].x(); .. } but C is the outer class of D (which indeed has A as ancestor). I think the code for 'value' should be: def value(): scala.Int = $outer.x(); In fact, this bug can be triggered by simply calling a method through 'super' on an outer class. To fix, it's needed both a super accessor in class A, and a proper 'outer' path in the inner class D.
Martin  edited on  2006-06-21 17:15:12.0
The problem was a wrong phase ordering. Fixed by moving some code from refchecks to superaccessors.
Martin  edited on  2006-06-21 17:15:44.0