From dc656062c35040f28c8b7774710d899b79f2e401 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Sat, 15 Mar 2014 15:50:41 +0100 Subject: SI-7992 Fix super-accessor generation after a local class The transformer in the superaccessors phase uses the var `validCurrentOwner` to track whether we're in a part of the code that won't end up in the host method, and as such, will need to access super-method via a super-accessor. But, this bit of bookkeeping was not correctly reset after traversing out of a local class. A `VerifyError` ensued. This commit changes `atOwner` to save and restore that flag, rather than leaving it set to `true`. I've also added a test variation using a by-name argument. --- test/files/run/t7992.scala | 20 ++++++++++++++++++++ test/files/run/t7992b.scala | 18 ++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 test/files/run/t7992.scala create mode 100644 test/files/run/t7992b.scala (limited to 'test') diff --git a/test/files/run/t7992.scala b/test/files/run/t7992.scala new file mode 100644 index 0000000000..fde231b961 --- /dev/null +++ b/test/files/run/t7992.scala @@ -0,0 +1,20 @@ +class C { + def foo: Int = 0 +} + +class D extends C { + override def foo: Int = { + val f = () => { + class C // comment this line to fix. + D.super.foo // no super accessor generated here! + // java.lang.VerifyError: (class: D$$anonfun$1, method: apply$mcI$sp signature: ()I) Illegal use of nonvirtual function call + } + f() + } +} + +object Test { + def main(args: Array[String]) { + new D().foo + } +} diff --git a/test/files/run/t7992b.scala b/test/files/run/t7992b.scala new file mode 100644 index 0000000000..6fe1f990d5 --- /dev/null +++ b/test/files/run/t7992b.scala @@ -0,0 +1,18 @@ +class C { + def foo: Int = 0 +} + +class E extends C { + override def foo: Int = { + (None: Option[Int]).getOrElse { + class C + E.super.foo + } + } +} + +object Test { + def main(args: Array[String]) { + new E().foo + } +} -- cgit v1.2.3