summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2014-09-30 14:50:30 +1000
committerJason Zaugg <jzaugg@gmail.com>2014-09-30 14:58:55 +1000
commitbcd1e4f3a3c7a683bb7cf435ef8163ecaf90f126 (patch)
tree43fe4ac6958a20f6244e86609345443e99635cad
parent2cfac1a3516850a40728fefd8f808613d2e83f84 (diff)
downloadscala-bcd1e4f3a3c7a683bb7cf435ef8163ecaf90f126.tar.gz
scala-bcd1e4f3a3c7a683bb7cf435ef8163ecaf90f126.tar.bz2
scala-bcd1e4f3a3c7a683bb7cf435ef8163ecaf90f126.zip
SI-8868 Fix unpickling of local dummy symbols
These pop up as the owner of symbols in annotation arguments, such as the ones introduced by the names/defaults desugaring. The first two test cases here motivate the two patches to Unpicker. The third requires both fixes, but exploits the problem directly, without using `@deprecated` and named arguments. See also 14fa7be / SI-8708 for a recently remedied kindred bug.
-rw-r--r--src/reflect/scala/reflect/internal/pickling/UnPickler.scala12
-rw-r--r--test/files/pos/t8868a/Sub_2.scala1
-rw-r--r--test/files/pos/t8868a/T_1.scala6
-rw-r--r--test/files/pos/t8868b/Sub_2.scala2
-rw-r--r--test/files/pos/t8868b/T_1.scala4
-rw-r--r--test/files/pos/t8868c/Sub_2.scala2
-rw-r--r--test/files/pos/t8868c/T_1.scala9
7 files changed, 34 insertions, 2 deletions
diff --git a/src/reflect/scala/reflect/internal/pickling/UnPickler.scala b/src/reflect/scala/reflect/internal/pickling/UnPickler.scala
index 8d4c3f752f..5433bfad60 100644
--- a/src/reflect/scala/reflect/internal/pickling/UnPickler.scala
+++ b/src/reflect/scala/reflect/internal/pickling/UnPickler.scala
@@ -243,8 +243,14 @@ abstract class UnPickler {
} getOrElse "")
}
+ def localDummy = {
+ if (nme.isLocalDummyName(name))
+ owner.newLocalDummy(NoPosition)
+ else NoSymbol
+ }
+
// (1) Try name.
- fromName(name) orElse {
+ localDummy orElse fromName(name) orElse {
// (2) Try with expanded name. Can happen if references to private
// symbols are read from outside: for instance when checking the children
// of a class. See #1722.
@@ -298,6 +304,7 @@ abstract class UnPickler {
* (.) ...
* (1) `local child` represents local child classes, see comment in Pickler.putSymbol.
* Since it is not a member, it should not be entered in the owner's scope.
+ * (2) Similarly, we ignore local dummy symbols, as seen in SI-8868
*/
def shouldEnterInOwnerScope = {
sym.owner.isClass &&
@@ -307,7 +314,8 @@ abstract class UnPickler {
!sym.isRefinementClass &&
!sym.isTypeParameter &&
!sym.isExistentiallyBound &&
- sym.rawname != tpnme.LOCAL_CHILD // (1)
+ sym.rawname != tpnme.LOCAL_CHILD && // (1)
+ !nme.isLocalDummyName(sym.rawname) // (2)
}
markFlagsCompleted(sym)(mask = AllFlags)
diff --git a/test/files/pos/t8868a/Sub_2.scala b/test/files/pos/t8868a/Sub_2.scala
new file mode 100644
index 0000000000..a19b529c88
--- /dev/null
+++ b/test/files/pos/t8868a/Sub_2.scala
@@ -0,0 +1 @@
+class Sub extends T
diff --git a/test/files/pos/t8868a/T_1.scala b/test/files/pos/t8868a/T_1.scala
new file mode 100644
index 0000000000..9fb97b1413
--- /dev/null
+++ b/test/files/pos/t8868a/T_1.scala
@@ -0,0 +1,6 @@
+class C
+
+trait T {
+ @deprecated(since = "", message = "")
+ class X
+}
diff --git a/test/files/pos/t8868b/Sub_2.scala b/test/files/pos/t8868b/Sub_2.scala
new file mode 100644
index 0000000000..58b44db2b3
--- /dev/null
+++ b/test/files/pos/t8868b/Sub_2.scala
@@ -0,0 +1,2 @@
+class Sub extends T
+
diff --git a/test/files/pos/t8868b/T_1.scala b/test/files/pos/t8868b/T_1.scala
new file mode 100644
index 0000000000..0b71cfdaa3
--- /dev/null
+++ b/test/files/pos/t8868b/T_1.scala
@@ -0,0 +1,4 @@
+@deprecated(since = "2.4.0", message = "")
+trait T {
+ class X
+}
diff --git a/test/files/pos/t8868c/Sub_2.scala b/test/files/pos/t8868c/Sub_2.scala
new file mode 100644
index 0000000000..58b44db2b3
--- /dev/null
+++ b/test/files/pos/t8868c/Sub_2.scala
@@ -0,0 +1,2 @@
+class Sub extends T
+
diff --git a/test/files/pos/t8868c/T_1.scala b/test/files/pos/t8868c/T_1.scala
new file mode 100644
index 0000000000..dc541950d8
--- /dev/null
+++ b/test/files/pos/t8868c/T_1.scala
@@ -0,0 +1,9 @@
+class C(a: Any) extends annotation.StaticAnnotation
+
+@C({val x = 0; x})
+trait T {
+ class X
+
+ @C({val x = 0; x})
+ def foo = 42
+}