Fix and test case for #1286.

git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@17641 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
extempore 2009-05-04 21:28:24 +00:00
parent 7d6262d32e
commit 325d813d9a
4 changed files with 17 additions and 0 deletions

View File

@ -1045,6 +1045,15 @@ trait Symbols {
(that.sourceFile eq null) ||
(this.sourceFile eq that.sourceFile) ||
(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 (res == false) {
val (f1, f2) = (this.sourceFile, that.sourceFile)
if (f1 != null && f2 != null && f1 != f2)
throw FatalError("Companions '" + this + "' and '" + that + "' must be defined in same file.")
}
res
}

View File

@ -0,0 +1,2 @@
error: fatal error: Companions 'object Foo' and 'trait Foo' must be defined in same file.
one error found

View File

@ -0,0 +1,3 @@
trait Foo {
def jump = Foo.x
}

View File

@ -0,0 +1,3 @@
object Foo extends Foo {
val x = "x"
}