mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-05 01:50:56 +07:00
check access class for super expressions referenced to interfaces
This commit is contained in:
@@ -439,9 +439,15 @@ public class PsiScopesUtil {
|
||||
}
|
||||
else if (resolve instanceof PsiClass) {
|
||||
PsiExpression qualifier = methodCall.getMethodExpression().getQualifierExpression();
|
||||
if (!(qualifier instanceof PsiSuperExpression) || ((PsiSuperExpression)qualifier).getQualifier() != null && PsiUtil.isLanguageLevel8OrHigher(methodCall)) {
|
||||
if (!(qualifier instanceof PsiSuperExpression)) {
|
||||
processor.setAccessClass((PsiClass)PsiUtil.getAccessObjectClass(qualifier).getElement());
|
||||
}
|
||||
else if (((PsiSuperExpression)qualifier).getQualifier() != null && PsiUtil.isLanguageLevel8OrHigher(qualifier)) {
|
||||
final PsiClass accessClass = (PsiClass)PsiUtil.getAccessObjectClass(qualifier).getElement();
|
||||
if (accessClass != null && accessClass.isInterface()) {
|
||||
processor.setAccessClass(accessClass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
processor.setIsConstructor(false);
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package p2;
|
||||
|
||||
import p.*;
|
||||
|
||||
class Test extends Foo {
|
||||
{
|
||||
Test.super.foo();
|
||||
}
|
||||
}
|
||||
@@ -15,10 +15,13 @@
|
||||
*/
|
||||
package com.intellij.codeInsight.daemon.lambda;
|
||||
|
||||
import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class Interface8MethodsHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public class Interface8MethodsHighlightingTest extends LightCodeInsightFixtureTestCase {
|
||||
@NonNls static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/lambda/interfaceMethods";
|
||||
|
||||
public void testStaticMethod() { doTest(); }
|
||||
@@ -39,6 +42,13 @@ public class Interface8MethodsHighlightingTest extends LightDaemonAnalyzerTestCa
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testSuperProtectedCalls() throws Exception {
|
||||
myFixture.addClass("package p; public class Foo {" +
|
||||
" protected void foo(){}" +
|
||||
"}");
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEA120498() { doTest(false, false); }
|
||||
|
||||
private void doTest() {
|
||||
@@ -46,6 +56,19 @@ public class Interface8MethodsHighlightingTest extends LightDaemonAnalyzerTestCa
|
||||
}
|
||||
|
||||
private void doTest(boolean checkWarnings, boolean checkInfos) {
|
||||
doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, checkInfos);
|
||||
String filePath = BASE_PATH + "/" + getTestName(false) + ".java";
|
||||
myFixture.configureByFile(filePath);
|
||||
myFixture.checkHighlighting(checkWarnings, checkInfos, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return JavaTestUtil.getJavaTestDataPath();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected LightProjectDescriptor getProjectDescriptor() {
|
||||
return JAVA_8;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user