scala/scala — pull request #3375 by gzm0 (2014-01-16 14:16:34+00:00)
Title: Move check for undefined members in objects from Typer to RefCheck

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 Typer, 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 typer 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.

This commit moves the check to the RefCheck phase. Error messages remain the same, except for the additional "object creation impossible" message emitted from the RefCheck phase. The example code above will now emit the following errors:

test.scala:15: error: object creation impossible, since method x is not defined
object Foo {
^
test.scala:16: error: only classes can have declared but undefined members
def x: Int
^

There is no need for additional tests since `neg/nested-fn-print` and `neg/t565` already verify this behavior.