mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java] inferred type accessibility (IDEA-293838)
ensure only inferred types (from method type parameters) are affected GitOrigin-RevId: 8eea25ebd9956b4b405c08a4396c6a4b79a3c952
This commit is contained in:
committed by
intellij-monorepo-bot
parent
5840073672
commit
4b5d4875a3
+3
-2
@@ -1852,8 +1852,9 @@ public final class HighlightMethodUtil {
|
||||
}
|
||||
|
||||
private static HighlightInfo checkInferredReturnTypeAccessible(@NotNull MethodCandidateInfo info, @NotNull PsiMethodCallExpression methodCall) {
|
||||
PsiClass targetClass = PsiUtil.resolveClassInClassTypeOnly(info.getElement().getReturnType());
|
||||
if (targetClass instanceof PsiTypeParameter) {
|
||||
PsiMethod method = info.getElement();
|
||||
PsiClass targetClass = PsiUtil.resolveClassInClassTypeOnly(method.getReturnType());
|
||||
if (targetClass instanceof PsiTypeParameter && ((PsiTypeParameter)targetClass).getOwner() == method) {
|
||||
PsiClass inferred = PsiUtil.resolveClassInClassTypeOnly(info.getSubstitutor().substitute((PsiTypeParameter)targetClass));
|
||||
if (inferred != null && !PsiUtil.isAccessible(inferred, methodCall, null)) {
|
||||
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR)
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package a.b;
|
||||
import a.*;
|
||||
class Foo {
|
||||
void m(Outer o){
|
||||
Object obj = o.getData();
|
||||
}
|
||||
}
|
||||
+12
@@ -266,6 +266,18 @@ public class LightAdvHighlightingFixtureTest extends LightJavaCodeInsightFixture
|
||||
"}");
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testProtectedInnerClass1() {
|
||||
myFixture.addClass("package a;\n" +
|
||||
"public class A<T> {\n" +
|
||||
" public T getData() {return null;}\n" +
|
||||
"}");
|
||||
myFixture.addClass("package a;\n" +
|
||||
"public class Outer extends A<Outer.Inner> {\n" +
|
||||
" protected class Inner {}\n" +
|
||||
"}");
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
myFixture.configureByFile(getTestName(false) + ".java");
|
||||
|
||||
Reference in New Issue
Block a user