mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
disable surroundWith fix for var typed locals with non-denotable inferred types
IDEA-CR-33936
This commit is contained in:
+11
@@ -0,0 +1,11 @@
|
||||
// "Surround with try/catch" "false"
|
||||
class Test {
|
||||
public static void main(String[] args) {
|
||||
var foo = new T<caret>est() {
|
||||
int x = 2;
|
||||
};
|
||||
System.out.println(foo.x);
|
||||
}
|
||||
|
||||
Test() throws Exception {}
|
||||
}
|
||||
+6
-1
@@ -20,6 +20,7 @@ import com.intellij.psi.controlFlow.*;
|
||||
import com.intellij.psi.search.searches.ReferencesSearch;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiTypesUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
@@ -948,7 +949,11 @@ public class ControlFlowUtils {
|
||||
if(parent instanceof PsiLocalVariable) {
|
||||
PsiElement grandParent = parent.getParent();
|
||||
if(grandParent instanceof PsiDeclarationStatement && ((PsiDeclarationStatement)grandParent).getDeclaredElements().length == 1) {
|
||||
return true;
|
||||
PsiTypeElement typeElement = ((PsiLocalVariable)parent).getTypeElement();
|
||||
if (!typeElement.isInferredType() ||
|
||||
PsiTypesUtil.replaceWithExplicitType(((PsiLocalVariable)parent.copy()).getTypeElement()) != null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (parent instanceof PsiField) {
|
||||
|
||||
Reference in New Issue
Block a user