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:
parent
7d6262d32e
commit
325d813d9a
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
error: fatal error: Companions 'object Foo' and 'trait Foo' must be defined in same file.
|
||||
one error found
|
|
@ -0,0 +1,3 @@
|
|||
trait Foo {
|
||||
def jump = Foo.x
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
object Foo extends Foo {
|
||||
val x = "x"
|
||||
}
|
Loading…
Reference in New Issue