Skip to content
Browse files

SI-6888 Loosen criteria for $outer search.

In order to cater for nested classes with names that end
with '$', which lead to ambiguity when unmangling expanded
names.

In:

    class X { object $ }

We end up with:

    orginalName(X$$$$$outer) = $$$outer

This change modifies `outerSource` to consider that to be
and outer accessor name. It is a piecemeal fix, and no doubt
there are other nasty surprises in store for those inclined to
flash their $$$ in identifier names, but the method changed is
not used widely and this solves the reported problem.

SI-2806 remains open to address the deeper problem.
  • Loading branch information...
1 parent 81d8f9d commit b579a42ee3c079e9acf53b74085ae01ac6c35f0f @retronym retronym committed Feb 5, 2013
Showing with 25 additions and 1 deletion.
  1. +3 −1 src/reflect/scala/reflect/internal/Symbols.scala
  2. +3 −0 test/files/run/t6888.check
  3. +19 −0 test/files/run/t6888.scala
View
4 src/reflect/scala/reflect/internal/Symbols.scala
@@ -2515,7 +2515,9 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
}
override def outerSource: Symbol =
- if (originalName == nme.OUTER) initialize.referenced
+ // SI-6888 Approximate the name to workaround the deficiencies in `nme.originalName`
+ // in the face of clases named '$'. SI-2806 remains open to address the deeper problem.
+ if (originalName endsWith (nme.OUTER)) initialize.referenced
else NoSymbol
def setModuleClass(clazz: Symbol): TermSymbol = {
View
3 test/files/run/t6888.check
@@ -0,0 +1,3 @@
+2
+3
+3
View
19 test/files/run/t6888.scala
@@ -0,0 +1,19 @@
+class C {
+ val x = 1
+ object $ {
+ val y = x + x
+ class abc$ {
+ def xy = x + y
+ }
+ object abc$ {
+ def xy = x + y
+ }
+ }
+}
+
+object Test extends App {
+ val c = new C()
+ println(c.$.y)
+ println(c.$.abc$.xy)
+ println(new c.$.abc$().xy)
+}

0 comments on commit b579a42

Please sign in to comment.
Something went wrong with that request. Please try again.