From cca4d51dbf3f8478cb338e6d53e34003e9a3fa45 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Wed, 27 Nov 2013 15:13:50 +0100 Subject: SI-5508 Fix crasher with private[this] in nested traits Currently, accessors for private local trait fields are added very late in the game when the `Mixin` tree transformer treats the trait. By contrast, fields with weaker access have accessors created eagerly in `Namers`. // Mixin#addLateInterfaceMembers val getter = member.getter(clazz) if (getter == NoSymbol) addMember(clazz, newGetter(member)) `addMember` mutates the type of the interface to add the getter. (This seems like a pretty poor design: usually if a phase changes types, it should do in an `InfoTransformer`.) However, if an inner class or anonymous function of the trait has been flattened to a spot where it precedes the trait in the enclosing packages info, this code hasn't had a chance to run, and the lookup of the getter crashes as mixins `postTransform` runs over a selection of the not-yet-materialized getter. // Mixin#postTransform case Select(qual, name) if sym.owner.isImplClass && !isStaticOnly(sym) => val iface = toInterface(sym.owner.tpe).typeSymbol val ifaceGetter = sym getter iface This commit ensures that `Flatten` lifts inner classes to a position *after* the enclosing class in the stats of the enclosing package. Bonus fix: SI-7012 (the followup ticket to SI-6231 / SI-2897) --- test/files/pos/t5508-min-okay.scala | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 test/files/pos/t5508-min-okay.scala (limited to 'test/files/pos/t5508-min-okay.scala') diff --git a/test/files/pos/t5508-min-okay.scala b/test/files/pos/t5508-min-okay.scala new file mode 100644 index 0000000000..3a38b9c5ea --- /dev/null +++ b/test/files/pos/t5508-min-okay.scala @@ -0,0 +1,6 @@ +object Test { + trait NestedTrait { // must be nested and a trait + private val _st : Int = 0 // crashes if changed to private[this] + val escape = { () => _st } + } +} -- cgit v1.2.3