case MTH:
if (m1 == m2) return m1;
boolean m1SignatureMoreSpecific = signatureMoreSpecific(env, site, m1, m2, allowBoxing, useVarargs);
boolean m2SignatureMoreSpecific = signatureMoreSpecific(env, site, m2, m1, allowBoxing, useVarargs);
if (m1SignatureMoreSpecific && m2SignatureMoreSpecific) {
Type mt1 = types.memberType(site, m1);
Type mt2 = types.memberType(site, m2);
if (!types.overrideEquivalent(mt1, mt2))
return ambiguityError(m1, m2);
// same signature; select (a) the non-bridge method, or
// (b) the one that overrides the other, or (c) the concrete
// one, or (d) merge both abstract signatures
if ((m1.flags() & BRIDGE) != (m2.flags() & BRIDGE))
return ((m1.flags() & BRIDGE) != 0) ? m2 : m1;
// if one overrides or hides the other, use it
TypeSymbol m1Owner = (TypeSymbol)m1.owner;
TypeSymbol m2Owner = (TypeSymbol)m2.owner;
if (types.asSuper(m1Owner.type, m2Owner) != null &&
((m1.owner.flags_field & INTERFACE) == 0 ||
(m2.owner.flags_field & INTERFACE) != 0) &&
m1.overrides(m2, m1Owner, types, false))
return m1;
if (types.asSuper(m2Owner.type, m1Owner) != null &&
((m2.owner.flags_field & INTERFACE) == 0 ||
(m1.owner.flags_field & INTERFACE) != 0) &&
m2.overrides(m1, m2Owner, types, false))
return m2;
boolean m1Abstract = (m1.flags() & ABSTRACT) != 0;
boolean m2Abstract = (m2.flags() & ABSTRACT) != 0;
if (m1Abstract && !m2Abstract) return m2;
if (m2Abstract && !m1Abstract) return m1;
// both abstract or both concrete
if (!m1Abstract && !m2Abstract)
return ambiguityError(m1, m2);
// check that both signatures have the same erasure
if (!types.isSameTypes(m1.erasure(types).getParameterTypes(),
m2.erasure(types).getParameterTypes()))
return ambiguityError(m1, m2);
// both abstract, neither overridden; merge throws clause and result type
Symbol mostSpecific;
if (types.returnTypeSubstitutable(mt1, mt2))
mostSpecific = m1;
else if (types.returnTypeSubstitutable(mt2, mt1))
mostSpecific = m2;
else {
// Theoretically, this can't happen, but it is possible
// due to error recovery or mixing incompatible class files
return ambiguityError(m1, m2);
}
List<Type> allThrown = chk.intersect(mt1.getThrownTypes(), mt2.getThrownTypes());
Type newSig = types.createMethodTypeWithThrown(mostSpecific.type, allThrown);
MethodSymbol result = new MethodSymbol(
mostSpecific.flags(),
mostSpecific.name,
newSig,
mostSpecific.owner) {