scala/scala — pull request #1864 by retronym (2013-01-08 13:32:59+00:00)
Title: SI-4859 Step back from mis-optimizations in qualifiers

Retargetting #1710 to master.

Widespread, invalid qualifier discarding in the apparent name of performance led to a variety of problems:

The compiler would crash in case of:

OuterCaseClass().InnerCaseClass()

And the side effect would be elided in:

{ println("!!"); Outer}.Inner

This change fixes these problems but stops short of fixing the last problem:

Outer.Inner.foo // module load of Outer is still elided.

This could be fixed use a stronger condition than `isExprSafeToInline` throughout this patch. (It would be `isExprSafeToElide` or `isPure`.)

Thoughts? Should that change be tackled in this ticket or separately?

Last time, @paulp [opined](https://github.com/scala/scala/pull/1710#discussion_r2458429):

> I don't see how we can fail to initialize Outer here if we wish to have at all predictable semantics.

Review by @paulp @magarcia