mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-property-tests] IDEA-375027 incorrect var type when use var type is enabled
GitOrigin-RevId: a24859428c9fac54a2aa75eb0e82a2ac018114ce
This commit is contained in:
committed by
intellij-monorepo-bot
parent
1e629b4325
commit
5fc112fa77
+1
-1
@@ -345,7 +345,7 @@ public class JavaVariableInplaceIntroducer extends AbstractJavaInplaceIntroducer
|
||||
}
|
||||
}
|
||||
}
|
||||
if (psiVariable != null && psiVariable.isValid()) {
|
||||
if (psiVariable != null && psiVariable.isValid() && !PsiTypes.nullType().equals(psiVariable.getType())) {
|
||||
DumbService.getInstance(project).runWithAlternativeResolveEnabled(() -> createCastInVariableDeclaration(project, psiVariable));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
|
||||
class Test {
|
||||
void f(Object o) {
|
||||
System.out.println(((SomeUnresolved)o).doSomet<caret>hing());
|
||||
}
|
||||
|
||||
class SomeUnresolved{
|
||||
Test doSomething() {}
|
||||
}
|
||||
}
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
|
||||
class Test {
|
||||
void f(Object o) {
|
||||
var o = ((SomeUnresolved) o).doSomething();
|
||||
System.out.println(o);
|
||||
}
|
||||
|
||||
class SomeUnresolved{
|
||||
Test doSomething() {}
|
||||
}
|
||||
}
|
||||
|
||||
+14
@@ -20,6 +20,7 @@ import com.intellij.psi.codeStyle.JavaCodeStyleSettings;
|
||||
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.refactoring.IntroduceVariableUtil;
|
||||
import com.intellij.refactoring.JavaRefactoringSettings;
|
||||
import com.intellij.refactoring.introduce.inplace.AbstractInplaceIntroducer;
|
||||
import com.intellij.refactoring.introduceVariable.IntroduceVariableHandler;
|
||||
import com.intellij.refactoring.util.CommonRefactoringUtil;
|
||||
@@ -77,6 +78,19 @@ public class InplaceIntroduceVariableTest extends AbstractJavaInplaceIntroduceTe
|
||||
doTest(introducer -> type("constants"));
|
||||
}
|
||||
|
||||
public void testUnresolvedVariable() {
|
||||
JavaRefactoringSettings instance = JavaRefactoringSettings.getInstance();
|
||||
Boolean oldValue = instance.INTRODUCE_LOCAL_CREATE_VAR_TYPE;
|
||||
instance.INTRODUCE_LOCAL_CREATE_VAR_TYPE = true;
|
||||
try {
|
||||
doTest(introducer -> type("o"));
|
||||
}
|
||||
finally {
|
||||
instance.INTRODUCE_LOCAL_CREATE_VAR_TYPE = oldValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void testInsideInjectedString() {
|
||||
doTestInsideInjection(introducer -> type("expr"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user