mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
error highlighting: fix accessibility for diamond constructors (IDEA-212188)
GitOrigin-RevId: 7193877427e50351a1171df12a431effc89b6bfd
This commit is contained in:
committed by
intellij-monorepo-bot
parent
2f4b69a198
commit
f2014af32f
+3
-1
@@ -1709,7 +1709,9 @@ public class HighlightMethodUtil {
|
||||
if (staticFactory instanceof MethodCandidateInfo) {
|
||||
if (((MethodCandidateInfo)staticFactory).isApplicable()) {
|
||||
result = (MethodCandidateInfo)staticFactory;
|
||||
constructor = ((MethodCandidateInfo)staticFactory).getElement();
|
||||
if (constructor == null) {
|
||||
constructor = ((MethodCandidateInfo)staticFactory).getElement();
|
||||
}
|
||||
}
|
||||
else {
|
||||
applicable = false;
|
||||
|
||||
@@ -249,14 +249,14 @@ public class PsiDiamondTypeImpl extends PsiDiamondType {
|
||||
return JavaResolveResult.EMPTY;
|
||||
}
|
||||
|
||||
final MethodCandidateInfo staticFactoryCandidateInfo = createMethodCandidate(staticFactory, context, false, argumentList);
|
||||
final MethodCandidateInfo staticFactoryCandidateInfo = createMethodCandidate((MethodCandidateInfo)result, context, false, argumentList);
|
||||
if (!staticFactory.isVarArgs()) {
|
||||
return staticFactoryCandidateInfo;
|
||||
}
|
||||
|
||||
final ArrayList<CandidateInfo> conflicts = new ArrayList<>();
|
||||
conflicts.add(staticFactoryCandidateInfo);
|
||||
conflicts.add(createMethodCandidate(staticFactory, context, true, argumentList));
|
||||
conflicts.add(createMethodCandidate((MethodCandidateInfo)result, context, true, argumentList));
|
||||
return resolver.resolveConflict(conflicts);
|
||||
});
|
||||
}
|
||||
@@ -438,11 +438,11 @@ public class PsiDiamondTypeImpl extends PsiDiamondType {
|
||||
}
|
||||
|
||||
|
||||
private static MethodCandidateInfo createMethodCandidate(@NotNull final PsiMethod staticFactoryMethod,
|
||||
private static MethodCandidateInfo createMethodCandidate(@NotNull final MethodCandidateInfo staticFactoryMethod,
|
||||
final PsiElement parent,
|
||||
final boolean varargs,
|
||||
final PsiExpressionList argumentList) {
|
||||
return new MethodCandidateInfo(staticFactoryMethod, PsiSubstitutor.EMPTY, false, false, argumentList, parent, null, null) {
|
||||
return new MethodCandidateInfo(staticFactoryMethod.getElement(), PsiSubstitutor.EMPTY, !staticFactoryMethod.isAccessible(), false, argumentList, parent, null, null) {
|
||||
private PsiType[] myExpressionTypes;
|
||||
|
||||
@Override
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
interface Either {
|
||||
public static final class Left<L> {
|
||||
private final L value;
|
||||
|
||||
private Left(L value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Main {
|
||||
{
|
||||
new <error descr="'Left(L)' has private access in 'Either.Left'">Either.Left<></error>("");
|
||||
}
|
||||
}
|
||||
+4
@@ -29,6 +29,10 @@ public class Diamond8HighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testConstructorAccessibility() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testOuterClass() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user