mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
method refs: is exact should check super methods for this/super qualifiers only (IDEA-124507)
This commit is contained in:
@@ -136,7 +136,8 @@ public class PsiMethodReferenceExpressionImpl extends PsiReferenceExpressionBase
|
||||
if (containingClass != null) {
|
||||
PsiMethod[] methods = null;
|
||||
if (element instanceof PsiIdentifier) {
|
||||
methods = containingClass.findMethodsByName(element.getText(), !qualifierResolveResult.isReferenceTypeQualified());
|
||||
final PsiExpression qualifierExpression = getQualifierExpression();
|
||||
methods = containingClass.findMethodsByName(element.getText(), qualifierExpression instanceof PsiThisExpression || qualifierExpression instanceof PsiSuperExpression);
|
||||
}
|
||||
else if (isConstructor()) {
|
||||
final PsiElementFactory factory = JavaPsiFacade.getElementFactory(getProject());
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
class Test {
|
||||
private static void <warning descr="Private method 'foo(java.lang.Runnable)' is never used">foo</warning>(Runnable runnable) {
|
||||
System.out.println(runnable);
|
||||
}
|
||||
|
||||
private static void foo(Callable<Iterator<?>> callable) {
|
||||
System.out.println(callable);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
final Collection<Void> collection = new ArrayList<>();
|
||||
final Iterable<Void> iterable = collection;
|
||||
foo(iterable::iterator);
|
||||
foo(collection::iterator);
|
||||
}
|
||||
}
|
||||
@@ -95,6 +95,10 @@ public class MostSpecificResolutionTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testSuperMethodsInExactCheck() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user