summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2016-08-12 22:04:26 +1000
committerJakob Odersky <jakob@odersky.com>2016-08-12 14:26:31 -0700
commit56e4402fc267dcd1957f0aee0c756e88ca569482 (patch)
tree9fb848898cfb4b11fb9a9fb595a523c10a5e57c3
parent708dd680b3e28c6344c3f45c2aea09cf1d3b5908 (diff)
downloadscala-56e4402fc267dcd1957f0aee0c756e88ca569482.tar.gz
scala-56e4402fc267dcd1957f0aee0c756e88ca569482.tar.bz2
scala-56e4402fc267dcd1957f0aee0c756e88ca569482.zip
Java joint compilation: tweak static lookup impl
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Contexts.scala11
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala6
-rw-r--r--test/files/pos/t2377b/Q.java5
-rw-r--r--test/files/pos/t2377b/a.scala4
4 files changed, 18 insertions, 8 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
index 16ef75c863..c73ea54c3d 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
@@ -1016,7 +1016,16 @@ trait Contexts { self: Analyzer =>
|| unit.exists && s.sourceFile != unit.source.file
)
)
- def lookupInPrefix(name: Name) = pre member name filter qualifies
+ def lookupInPrefix(name: Name) = {
+ val sym = pre.member(name).filter(qualifies)
+ def isNonPackageNoModuleClass(sym: Symbol) =
+ sym.isClass && !sym.isModuleClass && !sym.isPackageClass
+ if (!sym.exists && unit.isJava && isNonPackageNoModuleClass(pre.typeSymbol)) {
+ // TODO factor out duplication with Typer::inCompanionForJavaStatic
+ val pre1 = companionSymbolOf(pre.typeSymbol, this).typeOfThis
+ pre1.member(name).filter(qualifies).andAlso(_ => pre = pre1)
+ } else sym
+ }
def accessibleInPrefix(s: Symbol) = isAccessible(s, pre, superAccess = false)
def searchPrefix = {
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index ad58859f25..eabd35cd1f 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -4885,11 +4885,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
nameLookup match {
case LookupAmbiguous(msg) => issue(AmbiguousIdentError(tree, name, msg))
case LookupInaccessible(sym, msg) => issue(AccessError(tree, sym, context, msg))
- case LookupNotFound =>
- inCompanionForJavaStatic(NoPrefix, context.enclClass.owner, name) orElse inEmptyPackage orElse lookupInRoot(name) match {
- case NoSymbol => issue(SymbolNotFoundError(tree, name, context.owner, startContext))
- case sym => typed1(tree setSymbol sym, mode, pt)
- }
+ case LookupNotFound => issue(SymbolNotFoundError(tree, name, context.owner, startContext))
case LookupSucceeded(qual, sym) =>
(// this -> Foo.this
if (sym.isThisSym)
diff --git a/test/files/pos/t2377b/Q.java b/test/files/pos/t2377b/Q.java
index 1dfdd5991d..fbf9c776e9 100644
--- a/test/files/pos/t2377b/Q.java
+++ b/test/files/pos/t2377b/Q.java
@@ -3,8 +3,11 @@ public class Q {
public static class Builder {}
public static class Inner {
- public static class Builder {}
+ public static class Builder { public void innerMethod() {} }
public Builder foo() { return new Builder(); } // this line gives an error, that Builder is ambiguous
+
+ public Inner.Builder viaSelect() { return new Builder(); } // this line gives an error, that Builder is ambiguous
}
}
+
diff --git a/test/files/pos/t2377b/a.scala b/test/files/pos/t2377b/a.scala
index 14be23cfa2..3053841589 100644
--- a/test/files/pos/t2377b/a.scala
+++ b/test/files/pos/t2377b/a.scala
@@ -1,3 +1,5 @@
object Test {
- (new Q.Inner).foo // make sure foo's type is well-formed
+ (new Q.Inner).foo.innerMethod
+ (new Q.Inner).viaSelect.innerMethod
+
}