SI-7232 Fix Java import vs defn. binding precendence

Java Spec:
> A single-type-import declaration d in a compilation unit c
> of package p that imports a type named n shadows, throughout
> c, the declarations of:
>   - any top level type named n declared in another compilation
>     unit of p
>   - any type named n imported by a type-import-on-demand
>     declaration in c
>   - any type named n imported by a static-import-on-demand
>     declaration in c

Scala Spec:
> Bindings of different kinds have a precedence deﬁned on them:
>   1. Deﬁnitions and declarations that are local, inherited, or made
>      available by a package clause in the same compilation unit where
>      the deﬁnition occurs have highest precedence.
>   2. Explicit imports have next highest precedence.

This is a forward port of 6e79370, which did not merge cleanly
and was omitted in the regular merge from 2.10.x to master.

Conflicts:
	src/compiler/scala/tools/nsc/typechecker/Typers.scala
SI-7259 Fix detection of Java defined Selects

The fix for SI-3120, 3ff7743, introduced a fallback within
`typedSelect` that accounted for the ambiguity of a Java
selection syntax. Does `A.B` refer to a member of the type `A`
or of the companion object `A`? (The companion object here is a
fiction used by scalac to group the static members of a Java
class.)

The fallback in `typedSelect` was predicated on
`context.owner.enclosingTopLevelClass.isJavaDefined`.
However, this was incorrectly including Select-s in top-level
annotations in Scala files, which are owned by the enclosing
package class, which is considered to be Java defined. This
led to nonsensical error messages ("type scala not found.")

Instead, this commit checks the compilation unit of the context,
which is more direct and correct. (As I learned recently,
`currentUnit.isJavaDefined` would *not* be correct, as a lazy type
might complete a Java signature while compiling some other compilation
unit!)

A bonus post factum test case is included for SI-3120.

Manual forward port of f046853 which was not merged as
part of the routine 2.10.x to master merge. The test case
uncovered a NullPointerExceptiion crasher in annotation
typechecking introduced in 5878099c; this has been prevented
with a null check.

Conflicts:
	src/compiler/scala/tools/nsc/typechecker/Typers.scala
Merge pull request #2318 from retronym/ticket/7259-master

[forward port] SI-7259 Fix detection of Java defined Selects
Merge pull request #2317 from retronym/ticket/7232-master

[forward-port] SI-7232 Fix Java import vs defn. binding precendence