summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala9
-rw-r--r--test/files/pos/t5957/T_1.scala6
-rw-r--r--test/files/pos/t5957/Test.java11
3 files changed, 25 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
index e6499c05a6..60e11291c1 100644
--- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
+++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
@@ -645,7 +645,14 @@ abstract class ClassfileParser {
// if this is a non-static inner class, remove the explicit outer parameter
val newParams = innerClasses.get(currentClass) match {
case Some(entry) if !isScalaRaw && !isStatic(entry.jflags) =>
- assert(params.head.tpe.typeSymbol == clazz.owner, params.head.tpe.typeSymbol + ": " + clazz.owner)
+ /* About `clazz.owner.isPackage` below: SI-5957
+ * For every nested java class A$B, there are two symbols in the scala compiler.
+ * 1. created by SymbolLoader, because of the existence of the A$B.class file, owner: package
+ * 2. created by ClassfileParser of A when reading the inner classes, owner: A
+ * If symbol 1 gets completed (e.g. because the compiled source mentions `A$B`, not `A#B`), the
+ * ClassfileParser for 1 executes, and clazz.owner is the package.
+ */
+ assert(params.head.tpe.typeSymbol == clazz.owner || clazz.owner.isPackage, params.head.tpe.typeSymbol + ": " + clazz.owner)
params.tail
case _ =>
params
diff --git a/test/files/pos/t5957/T_1.scala b/test/files/pos/t5957/T_1.scala
new file mode 100644
index 0000000000..1db5a3891f
--- /dev/null
+++ b/test/files/pos/t5957/T_1.scala
@@ -0,0 +1,6 @@
+abstract class T {
+ def t1: Test$Bar
+ def t2: Test#Bar
+ def t3: Test$Baz
+ def t4: Test.Baz
+}
diff --git a/test/files/pos/t5957/Test.java b/test/files/pos/t5957/Test.java
new file mode 100644
index 0000000000..4fbd257d95
--- /dev/null
+++ b/test/files/pos/t5957/Test.java
@@ -0,0 +1,11 @@
+public class Test {
+ public class Bar {
+ public Bar(int i) {
+ }
+ }
+
+ public static class Baz {
+ public Baz(int i) {
+ }
+ }
+}