summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-02-07 04:45:44 +0000
committerPaul Phillips <paulp@improving.org>2011-02-07 04:45:44 +0000
commit1065c911a1b896132b54d2573d80152b5fe7404f (patch)
tree38fe9db364b1b0102f1ff473e8bbc11ef0e5c904
parentfcc962b1973aedf1c892aac0d1fce7e5fa32fbc0 (diff)
downloadscala-1065c911a1b896132b54d2573d80152b5fe7404f.tar.gz
scala-1065c911a1b896132b54d2573d80152b5fe7404f.tar.bz2
scala-1065c911a1b896132b54d2573d80152b5fe7404f.zip
The comment for isCoDefinedWith has long said
Is this symbol defined in the same scope and compilation unit as `that' symbol? But "same scope" was never checked, only "same compilation unit." Presumably other layers of logic kept this from being noticed until now, but it has been crashing sbt. Added check to isCoDefinedWith. Closes #4220, review by odersky.
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Symbols.scala27
-rw-r--r--test/files/pos/bug4220.scala7
2 files changed, 22 insertions, 12 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Symbols.scala b/src/compiler/scala/tools/nsc/symtab/Symbols.scala
index 6a15c929b9..7aa15d2e42 100644
--- a/src/compiler/scala/tools/nsc/symtab/Symbols.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Symbols.scala
@@ -1224,19 +1224,22 @@ trait Symbols extends reflect.generic.Symbols { self: SymbolTable =>
/** Is this symbol defined in the same scope and compilation unit as `that' symbol?
*/
- def isCoDefinedWith(that: Symbol) = (this.rawInfo ne NoType) && {
- !this.owner.isPackageClass ||
- (this.sourceFile eq null) ||
- (that.sourceFile eq null) ||
- (this.sourceFile == that.sourceFile) || {
- // recognize companion object in separate file and fail, else compilation
- // appears to succeed but highly opaque errors come later: see bug #1286
- if (this.sourceFile.path != that.sourceFile.path)
- throw InvalidCompanions(this, that)
-
- false
+ def isCoDefinedWith(that: Symbol) = (
+ (this.rawInfo ne NoType) &&
+ (this.owner == that.owner) && {
+ !this.owner.isPackageClass ||
+ (this.sourceFile eq null) ||
+ (that.sourceFile eq null) ||
+ (this.sourceFile == that.sourceFile) || {
+ // recognize companion object in separate file and fail, else compilation
+ // appears to succeed but highly opaque errors come later: see bug #1286
+ if (this.sourceFile.path != that.sourceFile.path)
+ throw InvalidCompanions(this, that)
+
+ false
+ }
}
- }
+ )
/** The internal representation of classes and objects:
*
diff --git a/test/files/pos/bug4220.scala b/test/files/pos/bug4220.scala
new file mode 100644
index 0000000000..98f2649767
--- /dev/null
+++ b/test/files/pos/bug4220.scala
@@ -0,0 +1,7 @@
+// don't know if our half-working sbt build is meaningfully
+// tested for #4220 with this, but it can't hurt.
+class Boo(a: Int = 0)
+
+object test {
+ class Boo
+}