mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 21:11:28 +07:00
[java-highlighting] IDEA-308514 Incorrect Java error highlighting when accessing private method of var local variable
GitOrigin-RevId: 29c869bc79161b6adf24f0090ee591cb9abc1c6b
This commit is contained in:
committed by
intellij-monorepo-bot
parent
7a5fc9111f
commit
b65d25e4eb
@@ -170,7 +170,13 @@ public class PsiTypeElementImpl extends CompositePsiElement implements PsiTypeEl
|
||||
if (declarationScope instanceof PsiForeachStatement) {
|
||||
PsiExpression iteratedValue = ((PsiForeachStatement)declarationScope).getIteratedValue();
|
||||
if (iteratedValue != null) {
|
||||
return JavaGenericsUtil.getCollectionItemType(iteratedValue);
|
||||
PsiType type = JavaGenericsUtil.getCollectionItemType(iteratedValue);
|
||||
//Upward projection is applied to the type of the initializer when determining the type of the
|
||||
//variable
|
||||
if (type instanceof PsiCapturedWildcardType) {
|
||||
return ((PsiCapturedWildcardType)type).getUpperBound();
|
||||
}
|
||||
return type;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
public class VarCaptureForLoop {
|
||||
private void foo() {}
|
||||
public void bar(Iterable<? extends VarCaptureForLoop> data) {
|
||||
for (var it : data) it.foo();
|
||||
}
|
||||
}
|
||||
@@ -454,4 +454,5 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testOnlyUncheckedWarningCastWithInnerClasses(){doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, true);}
|
||||
public void testOnlyUncheckedWarningCastWithDuplicatedArguments(){doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, true);}
|
||||
public void testCastUnboxingConversionWithWidening(){doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, true);}
|
||||
public void testVarCaptureForLoop(){doTest(LanguageLevel.JDK_10, JavaSdkVersion.JDK_10, true);}
|
||||
}
|
||||
Reference in New Issue
Block a user