mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
method references: allow access to protected methods through super (IDEA-217862)
GitOrigin-RevId: f1d86f6127a64146e87998423f3034e38a46409c
This commit is contained in:
committed by
intellij-monorepo-bot
parent
186dadfbac
commit
616e3ca030
@@ -144,7 +144,7 @@ public class MethodReferenceResolver implements ResolveCache.PolyVariantContextR
|
||||
processor.setIsConstructor(isConstructor);
|
||||
processor.setName(isConstructor ? containingClass.getName() : element.getText());
|
||||
final PsiExpression expression = reference.getQualifierExpression();
|
||||
if (expression == null || !(expression.getType() instanceof PsiArrayType)) {
|
||||
if (expression == null || !(expression.getType() instanceof PsiArrayType) && !(expression instanceof PsiSuperExpression)) {
|
||||
processor.setAccessClass(containingClass);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package b;
|
||||
|
||||
import a.A;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
class B extends A {
|
||||
public Consumer<Integer> callFoo() {
|
||||
return super::foo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// "Replace lambda with method reference" "true"
|
||||
import java.util.Random;
|
||||
import java.util.function.Function;
|
||||
class Bar extends Random {
|
||||
Function<Integer, Integer> s = super::next;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
// "Replace lambda with method reference" "false"
|
||||
// "Replace lambda with method reference" "true"
|
||||
import java.util.Random;
|
||||
import java.util.function.Function;
|
||||
class Bar extends Random {
|
||||
Function<Integer , Integer> s = (i) -> super.ne<caret>xt(i);
|
||||
Function<Integer, Integer> s = (i) -> super.ne<caret>xt(i);
|
||||
}
|
||||
@@ -75,6 +75,16 @@ public class AdvHighlighting8Test extends LightJavaCodeInsightFixtureTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testPackagePrivateAndSuperMethodReference() {
|
||||
myFixture.addClass("package a;\n" +
|
||||
"public class A {\n" +
|
||||
" protected void foo(int a) {\n" +
|
||||
" System.out.println(a);\n" +
|
||||
" }\n" +
|
||||
"}");
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
myFixture.testHighlighting(false, false, false, getTestName(false) + ".java");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user