summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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
+}