summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHubert Plociniczak <hubert.plociniczak@epfl.ch>2011-02-08 12:12:46 +0000
committerHubert Plociniczak <hubert.plociniczak@epfl.ch>2011-02-08 12:12:46 +0000
commitfa84b3319010c452d767351d72c7a4c962425fb4 (patch)
tree2e03b35f4c0db789793ca8a5bbe78d2118085b3d
parent496dc761189182e04c424750ba63077d62dcf78b (diff)
downloadscala-fa84b3319010c452d767351d72c7a4c962425fb4.tar.gz
scala-fa84b3319010c452d767351d72c7a4c962425fb4.tar.bz2
scala-fa84b3319010c452d767351d72c7a4c962425fb4.zip
Closes #4215. review by odersky
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Types.scala13
-rw-r--r--test/files/buildmanager/t4215/A.scala5
-rw-r--r--test/files/buildmanager/t4215/t4215.check6
-rw-r--r--test/files/buildmanager/t4215/t4215.test2
4 files changed, 24 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala
index c7e624d96e..54e5978e7b 100644
--- a/src/compiler/scala/tools/nsc/symtab/Types.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Types.scala
@@ -3810,8 +3810,17 @@ A type's typeSymbol should never be inspected directly.
} else if (sym.isModuleClass) {
val adaptedSym = adaptToNewRun(pre, sym.sourceModule)
// Handle nested objects properly
- val result = if (adaptedSym.isLazy) adaptedSym.lazyAccessor else adaptedSym.moduleClass
- assert(result != NoSymbol, sym+" "+adaptedSym+" "+adaptedSym.isLazy)
+ val result0 = if (adaptedSym.isLazy) adaptedSym.lazyAccessor else adaptedSym.moduleClass
+ val result = if (result0 == NoSymbol)
+ // The only possible way we got here is when
+ // object is defined inside the method and unfortunately
+ // we have no way of retrieving that information (and using it)
+ // at this point, so just use the old symbol.
+ // This also means that sym.sourceModule == adaptedSym since
+ // pre == NoPrefix. see #4215
+ sym
+ else result0
+
result
} else if ((pre eq NoPrefix) || (pre eq NoType) || sym.isPackageClass) {
sym
diff --git a/test/files/buildmanager/t4215/A.scala b/test/files/buildmanager/t4215/A.scala
new file mode 100644
index 0000000000..fbddd93afc
--- /dev/null
+++ b/test/files/buildmanager/t4215/A.scala
@@ -0,0 +1,5 @@
+class A {
+ def B {
+ object C
+ }
+}
diff --git a/test/files/buildmanager/t4215/t4215.check b/test/files/buildmanager/t4215/t4215.check
new file mode 100644
index 0000000000..d9ec9a743a
--- /dev/null
+++ b/test/files/buildmanager/t4215/t4215.check
@@ -0,0 +1,6 @@
+builder > A.scala
+compiling Set(A.scala)
+Changes: Map()
+builder > A.scala
+compiling Set(A.scala)
+Changes: Map(class A -> List(), object A$C$2 -> List())
diff --git a/test/files/buildmanager/t4215/t4215.test b/test/files/buildmanager/t4215/t4215.test
new file mode 100644
index 0000000000..392e0d365f
--- /dev/null
+++ b/test/files/buildmanager/t4215/t4215.test
@@ -0,0 +1,2 @@
+>>compile A.scala
+>>compile A.scala