summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Kossakowski <grzegorz.kossakowski@gmail.com>2015-02-03 12:09:57 +0100
committerGrzegorz Kossakowski <grzegorz.kossakowski@gmail.com>2015-02-03 12:09:57 +0100
commitc52083b9332e37ccd6cc82cd43928f06a24b124f (patch)
tree38cc29a7cdbb1fe03d7feaaa4d0dccf9945c4cde
parentf79b40e08c141ae63585c5ea2fd13374bf1a0bd3 (diff)
parent41dbde91f6e68a20619c8e9247577ef0ed6d4da6 (diff)
downloadscala-c52083b9332e37ccd6cc82cd43928f06a24b124f.tar.gz
scala-c52083b9332e37ccd6cc82cd43928f06a24b124f.tar.bz2
scala-c52083b9332e37ccd6cc82cd43928f06a24b124f.zip
Merge pull request #4292 from retronym/ticket/9133
SI-9133 Harden against infinite loop in NoSymbol.owner
-rw-r--r--src/reflect/scala/reflect/internal/Symbols.scala6
-rw-r--r--test/junit/scala/collection/IterableViewLikeTest.scala1
-rw-r--r--test/junit/scala/tools/nsc/symtab/SymbolTableTest.scala5
3 files changed, 11 insertions, 1 deletions
diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala
index e91bfadc85..d5fc52abbf 100644
--- a/src/reflect/scala/reflect/internal/Symbols.scala
+++ b/src/reflect/scala/reflect/internal/Symbols.scala
@@ -2054,7 +2054,11 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
* where it is the outer class of the enclosing class.
*/
final def outerClass: Symbol =
- if (owner.isClass) owner
+ if (this == NoSymbol) {
+ // ideally we shouldn't get here, but its better to harden against this than suffer the infinite loop in SI-9133
+ devWarningDumpStack("NoSymbol.outerClass", 15)
+ NoSymbol
+ } else if (owner.isClass) owner
else if (isClassLocalToConstructor) owner.enclClass.outerClass
else owner.outerClass
diff --git a/test/junit/scala/collection/IterableViewLikeTest.scala b/test/junit/scala/collection/IterableViewLikeTest.scala
index 55da02744b..ab09c4930b 100644
--- a/test/junit/scala/collection/IterableViewLikeTest.scala
+++ b/test/junit/scala/collection/IterableViewLikeTest.scala
@@ -4,6 +4,7 @@ import org.junit.Assert._
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
+import language.postfixOps
@RunWith(classOf[JUnit4])
class IterableViewLikeTest {
diff --git a/test/junit/scala/tools/nsc/symtab/SymbolTableTest.scala b/test/junit/scala/tools/nsc/symtab/SymbolTableTest.scala
index 11e955a4bb..895ad9d683 100644
--- a/test/junit/scala/tools/nsc/symtab/SymbolTableTest.scala
+++ b/test/junit/scala/tools/nsc/symtab/SymbolTableTest.scala
@@ -44,4 +44,9 @@ class SymbolTableTest {
assertFalse("Foo should be a superclass of Foo", fooSymbol.tpe <:< barSymbol.tpe)
}
+ @Test
+ def noSymbolOuterClass_t9133: Unit = {
+ import symbolTable._
+ assert(NoSymbol.outerClass == NoSymbol)
+ }
}