mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
method refs: inner classes from hierarchy availability
This commit is contained in:
@@ -581,6 +581,16 @@ public class LambdaUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isReceiverType(PsiType receiverType, PsiClass containingClass) {
|
||||
PsiClass aClass = PsiUtil.resolveClassInType(receiverType);
|
||||
while (containingClass != null) {
|
||||
if (InheritanceUtil.isInheritorOrSelf(aClass, containingClass, true)) return true;
|
||||
containingClass = containingClass.getContainingClass();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static boolean areAcceptable(MethodSignature signature1,
|
||||
MethodSignature signature2,
|
||||
PsiClass psiClass,
|
||||
@@ -594,7 +604,7 @@ public class LambdaUtil {
|
||||
final PsiClassType classType = JavaPsiFacade.getElementFactory(psiClass.getProject()).createType(psiClass, psiSubstitutor);
|
||||
final PsiType receiverType = signatureParameterTypes1[0];
|
||||
final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(receiverType);
|
||||
if (PsiTreeUtil.isAncestor(resolveResult.getElement(), psiClass, false) && resolveResult.getSubstitutor().equals(psiSubstitutor) ||
|
||||
if (isReceiverType(receiverType, psiClass) && resolveResult.getSubstitutor().equals(psiSubstitutor) ||
|
||||
(receiverType instanceof PsiClassType && ((PsiClassType)receiverType).isRaw() && receiverType.equals(TypeConversionUtil.erasure(classType)))) {
|
||||
offset++;
|
||||
}
|
||||
|
||||
@@ -279,7 +279,7 @@ public class PsiMethodReferenceExpressionImpl extends PsiReferenceExpressionBase
|
||||
final PsiType[] parameterTypes = mySignature.getParameterTypes();
|
||||
if (parameterTypes.length > 0) {
|
||||
final PsiClassType.ClassResolveResult classResolveResult = PsiUtil.resolveGenericsClassInType(parameterTypes[0]);
|
||||
if (PsiTreeUtil.isAncestor(classResolveResult.getElement(), myContainingClass, false) && classResolveResult.getSubstitutor().equals(mySubstitutor)) {
|
||||
if (LambdaUtil.isReceiverType(parameterTypes[0], myContainingClass) && classResolveResult.getSubstitutor().equals(mySubstitutor)) {
|
||||
hasReceiver = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
class MyTest {
|
||||
|
||||
static class Super {
|
||||
class Inner {
|
||||
Inner(int i){}
|
||||
}
|
||||
}
|
||||
|
||||
static class Child extends Super {
|
||||
|
||||
interface I {
|
||||
Inner m(Child child, int i);
|
||||
}
|
||||
|
||||
void test() {
|
||||
I var = Child.Inner::new;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -65,6 +65,10 @@ public class MethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testConstructorRefInnerFromSuper() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
doTest(BASE_PATH + "/" + getTestName(false) + ".java", false, false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user