summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala10
-rw-r--r--test/files/jvm/nest.check1
-rw-r--r--test/files/jvm/nest.java21
-rw-r--r--test/files/jvm/nest.scala10
-rw-r--r--test/files/jvm5/OuterTParams.java (renamed from test/files/jvm/OuterTParams.java)0
-rw-r--r--test/files/jvm5/genericNest.scala13
-rw-r--r--test/files/lib/genericNest.jar.desired.sha11
-rw-r--r--test/files/lib/nest.jar.desired.sha12
8 files changed, 50 insertions, 8 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
index 92e4f910ed..aa6a13ebc4 100644
--- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
+++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
@@ -477,7 +477,15 @@ abstract class ClassfileParser {
info match {
case MethodType(formals, restpe) =>
assert(restpe.typeSymbol == definitions.UnitClass)
- info = MethodType(formals, clazz.tpe)
+ // if this is a non-static inner class, remove the explicit outer parameter
+ val newFormals = innerClasses.get(externalName) match {
+ case Some(entry) if (entry.jflags & JAVA_ACC_STATIC) == 0 =>
+ assert(formals.head.typeSymbol == clazz.owner, formals.head.typeSymbol + ": " + clazz.owner)
+ formals.tail
+ case _ =>
+ formals
+ }
+ info = MethodType(newFormals, clazz.tpe)
}
val sym = getOwner(jflags)
.newMethod(NoPosition, name).setFlag(sflags).setInfo(info)
diff --git a/test/files/jvm/nest.check b/test/files/jvm/nest.check
index 445369969e..dc63855b14 100644
--- a/test/files/jvm/nest.check
+++ b/test/files/jvm/nest.check
@@ -1,3 +1,4 @@
2
3
10
+Instantiating public inner class: Inn Outer name x: 42
diff --git a/test/files/jvm/nest.java b/test/files/jvm/nest.java
index 581eaa4972..3f6f0bebbd 100644
--- a/test/files/jvm/nest.java
+++ b/test/files/jvm/nest.java
@@ -14,4 +14,25 @@ public class nest {
}
}
}
+
+
+ String name = "Outer name";
+
+ public class Inn {
+ int x;
+
+ public Inn(int x) {
+ this.x = x;
+ }
+
+ public void doSomething() {
+ System.out.println("Inn " + name + " x: " + x);
+ }
+ }
+
+ protected class ProtInn {
+ public void doSomething() {
+ System.out.println("ProtInn " + name);
+ }
+ }
}
diff --git a/test/files/jvm/nest.scala b/test/files/jvm/nest.scala
index 71f6064f31..60f3a3155f 100644
--- a/test/files/jvm/nest.scala
+++ b/test/files/jvm/nest.scala
@@ -14,11 +14,9 @@ object Test extends Application {
val r = new nest.best.rest;
Console.println(nest.best.rest.test.inc(2))
Console.println(nest.best.rest.x)
-}
-// bug #695
-object ForceParse extends OuterTParams[AnyRef] {
- // Force import of HarderToParse<A>.InnerClass,
- // which has confusing method signature.
- var field: InnerClass = null
+ print("Instantiating public inner class: ")
+ val outer = new nest
+ val inn = new outer.Inn(42)
+ inn.doSomething
}
diff --git a/test/files/jvm/OuterTParams.java b/test/files/jvm5/OuterTParams.java
index 1d3db49fcf..1d3db49fcf 100644
--- a/test/files/jvm/OuterTParams.java
+++ b/test/files/jvm5/OuterTParams.java
diff --git a/test/files/jvm5/genericNest.scala b/test/files/jvm5/genericNest.scala
new file mode 100644
index 0000000000..c1b0210117
--- /dev/null
+++ b/test/files/jvm5/genericNest.scala
@@ -0,0 +1,13 @@
+/** found in genericNest.jar, compiled from OuterTParams.java */
+import nestpkg._;
+
+// bug #695
+object ForceParse extends OuterTParams[AnyRef] {
+ // Force import of HarderToParse<A>.InnerClass,
+ // which has confusing method signature.
+ var field: InnerClass = null
+}
+
+object Test extends Application {
+ ForceParse
+}
diff --git a/test/files/lib/genericNest.jar.desired.sha1 b/test/files/lib/genericNest.jar.desired.sha1
new file mode 100644
index 0000000000..e9321262f2
--- /dev/null
+++ b/test/files/lib/genericNest.jar.desired.sha1
@@ -0,0 +1 @@
+b1ec8a095cec4902b3609d74d274c04365c59c04 ?genericNest.jar
diff --git a/test/files/lib/nest.jar.desired.sha1 b/test/files/lib/nest.jar.desired.sha1
index 02b9867d48..674ca79a5b 100644
--- a/test/files/lib/nest.jar.desired.sha1
+++ b/test/files/lib/nest.jar.desired.sha1
@@ -1 +1 @@
-0a3f0201e670f6063095e0fc33602afb5f1c1b07 ?nest.jar
+cd33e0a0ea249eb42363a2f8ba531186345ff68c ?nest.jar