@Override public void visitReference(JCMemberReference tree) { if (types.isFunctionalInterface(t.tsym) && types.isFunctionalInterface(s.tsym)) { Type desc_t = types.findDescriptorType(t); Type desc_s = types.findDescriptorType(s); if (types.isSameTypes(desc_t.getParameterTypes(), inferenceContext().asFree(desc_s.getParameterTypes()))) { if (types.asSuper(t, s.tsym) != null || types.asSuper(s, t.tsym) != null) { result &= MostSpecificCheckContext.super.compatible(t, s, warn); } else if (!desc_s.getReturnType().hasTag(VOID)) { //perform structural comparison Type ret_t = desc_t.getReturnType(); Type ret_s = desc_s.getReturnType(); result &= ((tree.refPolyKind == PolyKind.STANDALONE) ? standaloneMostSpecific(ret_t, ret_s, tree.sym.type.getReturnType(), warn) : polyMostSpecific(ret_t, ret_s, warn)); } else { return; } } } else { result &= false; } }
public boolean compatible(Type found, Type req, Warner warn) { if (!allowStructuralMostSpecific || actual == null) { return super.compatible(found, req, warn); } else { switch (actual.getTag()) { case DEFERRED: DeferredType dt = (DeferredType) actual; DeferredType.SpeculativeCache.Entry e = dt.speculativeCache.get(deferredAttrContext.msym, deferredAttrContext.phase); return (e == null || e.speculativeTree == deferredAttr.stuckTree) ? super.compatible(found, req, warn) : mostSpecific(found, req, e.speculativeTree, warn); default: return standaloneMostSpecific(found, req, actual, warn); } } }
@Override public void visitConditional(JCConditional tree) { if (tree.polyKind == PolyKind.STANDALONE) { result &= standaloneMostSpecific(t, s, tree.type, warn); } else { super.visitConditional(tree); } }
@Override void skip(JCTree tree) { result &= standaloneMostSpecific(t, s, tree.type, warn); }
@Override public void visitNewClass(JCNewClass tree) { result &= (tree.polyKind == PolyKind.STANDALONE) ? standaloneMostSpecific(t, s, tree.type, warn) : polyMostSpecific(t, s, warn); }
@Override public void visitApply(JCMethodInvocation tree) { result &= (tree.polyKind == PolyKind.STANDALONE) ? standaloneMostSpecific(t, s, tree.type, warn) : polyMostSpecific(t, s, warn); }