mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 21:55:01 +07:00
java 9: effectively final check fixed (IDEA-171152)
This commit is contained in:
+1
-7
@@ -1798,13 +1798,7 @@ public class HighlightUtil extends HighlightUtilBase {
|
||||
PsiModifierList modifierList = variable.getModifierList();
|
||||
if (modifierList != null && modifierList.hasModifierProperty(PsiModifier.FINAL)) return null;
|
||||
|
||||
PsiElement scope = null;
|
||||
if (variable instanceof PsiParameter) scope = ((PsiParameter)variable).getDeclarationScope();
|
||||
else if (variable instanceof PsiResourceVariable) scope = variable.getParent().getParent();
|
||||
else if (variable instanceof PsiLocalVariable) scope = PsiTreeUtil.getParentOfType(variable, PsiCodeBlock.class);
|
||||
if (scope != null) {
|
||||
if (HighlightControlFlowUtil.isEffectivelyFinal(variable, scope, null)) return null;
|
||||
}
|
||||
if (!(variable instanceof PsiField) && HighlightControlFlowUtil.isEffectivelyFinal(variable, resource, (PsiJavaCodeReferenceElement)expression)) return null;
|
||||
}
|
||||
|
||||
String text = JavaErrorMessages.message("resource.variable.must.be.final");
|
||||
|
||||
+2
-1
@@ -13,7 +13,8 @@ class TryWithResources {
|
||||
final AutoCloseable r1 = null;
|
||||
AutoCloseable r2 = null;
|
||||
AutoCloseable r3 = null;
|
||||
try (r1; r2; <error descr="Variable used as a try-with-resources resource should be final or effectively final">r3</error>) { }
|
||||
AutoCloseable r4; r4 = null;
|
||||
try (r1; r2; r4; <error descr="Variable used as a try-with-resources resource should be final or effectively final">r3</error>) { }
|
||||
r3 = null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user