Shortcut equivalence check if ctdecl is unresolved
This commit is contained in:
2 files changed
+5
-10
No files matched your search
+2
-10
@@ -133,16 +133,8 @@ public class UseDiamondOperatorRule extends AbstractJavaRulechainRule {
|
||||
MethodCallSite fakeCallSite = infer.newCallSite(mirror, targetType);
|
||||
infer.inferInvocationRecursively(fakeCallSite);
|
||||
|
||||
try {
|
||||
return mirror.isEquivalentToUnderlyingAst()
|
||||
&& topmostContext.acceptsType(mirror.getInferredType());
|
||||
} catch (IllegalStateException e) {
|
||||
/*
|
||||
* overload resolution may complaint it's incomplete if there are missing types.
|
||||
* The missing type info may be relevant to the user, but this exception is not, swallow it
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
return mirror.isEquivalentToUnderlyingAst()
|
||||
&& topmostContext.acceptsType(mirror.getInferredType());
|
||||
}
|
||||
|
||||
|
||||
|
||||
+3
@@ -40,6 +40,9 @@ abstract class BaseInvocMirror<T extends InvocationNode> extends BasePolyMirror<
|
||||
public boolean isEquivalentToUnderlyingAst() {
|
||||
MethodCtDecl ctDecl = getCtDecl();
|
||||
AssertionUtil.validateState(ctDecl != null, "overload resolution is not complete");
|
||||
if (ctDecl.isFailed()) {
|
||||
return false; // be conservative
|
||||
}
|
||||
if (!myNode.getMethodType().getSymbol().equals(ctDecl.getMethodType().getSymbol())) {
|
||||
return false;
|
||||
} else if (myNode instanceof ASTConstructorCall && ((ASTConstructorCall) myNode).isAnonymousClass()
|
||||
|
||||
Reference in new issue
Block a user