diff options
author | Paul Phillips <paulp@improving.org> | 2011-02-07 04:45:44 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-02-07 04:45:44 +0000 |
commit | 1065c911a1b896132b54d2573d80152b5fe7404f (patch) | |
tree | 38fe9db364b1b0102f1ff473e8bbc11ef0e5c904 /src | |
parent | fcc962b1973aedf1c892aac0d1fce7e5fa32fbc0 (diff) | |
download | scala-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.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/Symbols.scala | 27 |
1 files changed, 15 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: * |