scala/scala — pull request #3407 by gzm0 (2014-01-24 12:20:43+00:00)
Title: Move check for undefined members in objects from Namer to RefCheck

Alternative to #3375

When writing an object (or an anonymous class) with declared but undefined members, the compiler complains specifically about the method which is not allowed:

object Foo {
def x: Int // will cause an error message
}

will emit

test.scala:16: error: only classes can have declared but undefined members
def x: Int
^

This check has been performed by the Namer, unlike other checks for completeness of classes that are performed in the RefCheck phase. There are two issues with that:

1. The test in the Namer is conceptually wrong and only shallow (it e.g. does not check for unimplemented inherited abstract methods)
2. This does not allow compiler plugins to generate such code in a post-Typer but pre-RefCheck phase.
3. The testing code exists twice. So this commit removes some duplicate code.

This commit moves the check to the RefCheck phase. The example code above will now emit the following error:

test.scala:15: error: object creation impossible, since method x is not defined
object Foo {
^

The new test `undefined-members` verifies that behavior stays the same.