mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
inline: don't insert cast to var (IDEA-192159)
This commit is contained in:
@@ -160,6 +160,9 @@ public class InlineUtil {
|
||||
if (typeElement == null) {
|
||||
typeElement = factory.createTypeElement(variable.getType());
|
||||
}
|
||||
else if (typeElement.isInferredType()) {
|
||||
return expr;
|
||||
}
|
||||
castTypeElement.replace(typeElement);
|
||||
final PsiExpression operand = cast.getOperand();
|
||||
assert operand != null;
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
class Main {
|
||||
public static void main(String[] args) {
|
||||
var stream1 = Stream.of(Arrays.asList("1"), Arrays.asList(1));
|
||||
var stream2 = stre<caret>am1.map(list -> list);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
class Main {
|
||||
public static void main(String[] args) {
|
||||
var stream2 = Stream.of(Arrays.asList("1"), Arrays.asList(1)).map(list -> list);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -189,40 +189,30 @@ public class InlineLocalTest extends LightCodeInsightTestCase {
|
||||
}
|
||||
|
||||
public void testLambdaExpr() {
|
||||
doTest(true);
|
||||
doTest(true, LanguageLevel.JDK_1_8);
|
||||
}
|
||||
|
||||
public void testLambdaExprAsRefQualifier() {
|
||||
doTest(true);
|
||||
doTest(true, LanguageLevel.JDK_1_8);
|
||||
}
|
||||
|
||||
public void testMethodRefAsRefQualifier() {
|
||||
doTest(true);
|
||||
doTest(true, LanguageLevel.JDK_1_8);
|
||||
}
|
||||
|
||||
public void testLocalVarInsideLambdaBody() {
|
||||
doTest(true);
|
||||
doTest(true, LanguageLevel.JDK_1_8);
|
||||
}
|
||||
|
||||
public void testLocalVarInsideLambdaBody1() {
|
||||
doTest(true);
|
||||
doTest(true, LanguageLevel.JDK_1_8);
|
||||
}
|
||||
|
||||
public void testLocalVarInsideLambdaBody2() {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
public void testLocalVarUsedInLambdaBody() {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
public void testCastAroundLambda() {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
public void testNoCastAroundLambda() {
|
||||
doTest(true);
|
||||
}
|
||||
public void testLocalVarInsideLambdaBody2() { doTest(true, LanguageLevel.JDK_1_8); }
|
||||
public void testLocalVarUsedInLambdaBody() { doTest(true, LanguageLevel.JDK_1_8); }
|
||||
public void testCastAroundLambda() { doTest(true, LanguageLevel.JDK_1_8); }
|
||||
public void testNoCastAroundLambda() { doTest(true, LanguageLevel.JDK_1_8); }
|
||||
public void testNoCastWithVar() { doTest(true, LanguageLevel.JDK_10); }
|
||||
|
||||
public void testUncheckedCast() {
|
||||
doTest(true);
|
||||
@@ -320,7 +310,11 @@ public class InlineLocalTest extends LightCodeInsightTestCase {
|
||||
}
|
||||
|
||||
private void doTest(final boolean inlineDef) {
|
||||
setLanguageLevel(LanguageLevel.JDK_1_7);
|
||||
doTest(inlineDef, LanguageLevel.JDK_1_7);
|
||||
}
|
||||
|
||||
private void doTest(final boolean inlineDef, LanguageLevel languageLevel) {
|
||||
setLanguageLevel(languageLevel);
|
||||
String name = getTestName(false);
|
||||
String fileName = "/refactoring/inlineLocal/" + name + ".java";
|
||||
configureByFile(fileName);
|
||||
|
||||
Reference in New Issue
Block a user