1.1 --- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java Fri Jan 28 00:09:38 2011 -0800 1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java Fri Jan 28 12:01:07 2011 +0000 1.3 @@ -278,7 +278,7 @@ 1.4 return true; 1.5 else { 1.6 Symbol s2 = ((MethodSymbol)sym).implementation(site.tsym, types, true); 1.7 - return (s2 == null || s2 == sym || 1.8 + return (s2 == null || s2 == sym || sym.owner == s2.owner || 1.9 s2.isPolymorphicSignatureGeneric() || 1.10 !types.isSubSignature(types.memberType(site, s2), types.memberType(site, sym))); 1.11 } 1.12 @@ -712,13 +712,14 @@ 1.13 Type mt1 = types.memberType(site, m1); 1.14 Type mt2 = types.memberType(site, m2); 1.15 if (!types.overrideEquivalent(mt1, mt2)) 1.16 - return new AmbiguityError(m1, m2); 1.17 + return ambiguityError(m1, m2); 1.18 + 1.19 // same signature; select (a) the non-bridge method, or 1.20 // (b) the one that overrides the other, or (c) the concrete 1.21 // one, or (d) merge both abstract signatures 1.22 - if ((m1.flags() & BRIDGE) != (m2.flags() & BRIDGE)) { 1.23 + if ((m1.flags() & BRIDGE) != (m2.flags() & BRIDGE)) 1.24 return ((m1.flags() & BRIDGE) != 0) ? m2 : m1; 1.25 - } 1.26 + 1.27 // if one overrides or hides the other, use it 1.28 TypeSymbol m1Owner = (TypeSymbol)m1.owner; 1.29 TypeSymbol m2Owner = (TypeSymbol)m2.owner; 1.30 @@ -738,24 +739,24 @@ 1.31 if (m2Abstract && !m1Abstract) return m1; 1.32 // both abstract or both concrete 1.33 if (!m1Abstract && !m2Abstract) 1.34 - return new AmbiguityError(m1, m2); 1.35 + return ambiguityError(m1, m2); 1.36 // check that both signatures have the same erasure 1.37 if (!types.isSameTypes(m1.erasure(types).getParameterTypes(), 1.38 m2.erasure(types).getParameterTypes())) 1.39 - return new AmbiguityError(m1, m2); 1.40 + return ambiguityError(m1, m2); 1.41 // both abstract, neither overridden; merge throws clause and result type 1.42 Symbol mostSpecific; 1.43 Type result2 = mt2.getReturnType(); 1.44 if (mt2.tag == FORALL) 1.45 result2 = types.subst(result2, ((ForAll)mt2).tvars, ((ForAll)mt1).tvars); 1.46 - if (types.isSubtype(mt1.getReturnType(), result2)) { 1.47 + if (types.isSubtype(mt1.getReturnType(), result2)) 1.48 mostSpecific = m1; 1.49 - } else if (types.isSubtype(result2, mt1.getReturnType())) { 1.50 + else if (types.isSubtype(result2, mt1.getReturnType())) 1.51 mostSpecific = m2; 1.52 - } else { 1.53 + else { 1.54 // Theoretically, this can't happen, but it is possible 1.55 // due to error recovery or mixing incompatible class files 1.56 - return new AmbiguityError(m1, m2); 1.57 + return ambiguityError(m1, m2); 1.58 } 1.59 MethodSymbol result = new MethodSymbol( 1.60 mostSpecific.flags(), 1.61 @@ -777,7 +778,7 @@ 1.62 } 1.63 if (m1SignatureMoreSpecific) return m1; 1.64 if (m2SignatureMoreSpecific) return m2; 1.65 - return new AmbiguityError(m1, m2); 1.66 + return ambiguityError(m1, m2); 1.67 case AMBIGUOUS: 1.68 AmbiguityError e = (AmbiguityError)m2; 1.69 Symbol err1 = mostSpecific(m1, e.sym, env, site, allowBoxing, useVarargs); 1.70 @@ -787,9 +788,9 @@ 1.71 if (err1 instanceof AmbiguityError && 1.72 err2 instanceof AmbiguityError && 1.73 ((AmbiguityError)err1).sym == ((AmbiguityError)err2).sym) 1.74 - return new AmbiguityError(m1, m2); 1.75 + return ambiguityError(m1, m2); 1.76 else 1.77 - return new AmbiguityError(err1, err2); 1.78 + return ambiguityError(err1, err2); 1.79 default: 1.80 throw new AssertionError(); 1.81 } 1.82 @@ -844,6 +845,14 @@ 1.83 return to; 1.84 } 1.85 } 1.86 + //where 1.87 + Symbol ambiguityError(Symbol m1, Symbol m2) { 1.88 + if (((m1.flags() | m2.flags()) & CLASH) != 0) { 1.89 + return (m1.flags() & CLASH) == 0 ? m1 : m2; 1.90 + } else { 1.91 + return new AmbiguityError(m1, m2); 1.92 + } 1.93 + } 1.94 1.95 /** Find best qualified method matching given name, type and value 1.96 * arguments.