scala/scala — pull request #1710 by retronym (2012-12-05 09:26:36+00:00)
Title: SI-4859 Don't rewrite CC().CC2() to new CC2

Where CC and CC2 are case classes. Attempting to do so leads to
a "no legal prefix" error.

Now, we restrict this optimization (living in RefChecks ?!) to
case class applies with a "safe to inline" qualifier.

Review by @paulp
- is `isExprSafeToInline` the right check here? I wasn't sure about that.
- I didn't go as far as adding a test to show that some rewriting still works. But via manual inspection: here's how the enclosed test case looks after `refchecks`.

```scala
object O extends scala.AnyRef {
def (): O.type = {
O.super.();
()
};
new C().CC.apply();
new D().DD.apply()
};
```