scala/scala — pull request #3626 by retronym (2014-03-13 10:25:24+00:00)
Title: SI-2458 Explicit import should shadow def in other comp. unit

Fixes the implementation of point 4. from SLS chapter 2:

> Definitions made available by a package clause not in the
> compilation unit where the definition occurs have lowest precedence.

We had code to deal with this:

if (defSym.exists && impSym.exists) {
if (isPackageOwnedInDifferentUnit(defSym))
defSym = NoSymbol

But, in the `pos/t2458a`, no `impSym` was around, due to filtering
in `depthOk`. The depth of the imported symbol was the same as the
depth of the defined symbol, which didn't pass:

imp.depth > symbolDepth

`depthOk` already had special handling for Java sources: if the
import is non-wildcard and depths are equal, retain the import.

This commit does the same thing for Scala sources, using the
`isPackageOwnedInDifferentUnit` as the criteria. It also makes
the check for the "imported ... is permanently hidden" warning
to avoid this spurious warning:

test/files/pos/t2458a/A.scala:3: warning: imported `BitSet' is permanently hidden by definition of class BitSet in package p
import scala.collection.BitSet
^

I have retained compatibiltiy with the bug under -Xsource:2.10

Review by @adriaanm. I'l trigger a dbuild of this one to check for fallout.