J2K: inlining intermediate variable after removing type cast
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
import java.lang.String;
|
||||
|
||||
class C {
|
||||
void foo(Object o) {
|
||||
if (o instanceof String) {
|
||||
String s = (String) o;
|
||||
int l = s.length();
|
||||
String substring = s.substring(l - 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
class C {
|
||||
fun foo(o: Any) {
|
||||
if (o is String) {
|
||||
val l = o.length()
|
||||
val substring = o.substring(l - 2)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1005,6 +1005,12 @@ public class JavaToKotlinConverterForWebDemoTestGenerated extends AbstractJavaTo
|
||||
String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/codeSimplifications/RedundantTypeCast.java");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("RedundantTypeCastAndInline.java")
|
||||
public void testRedundantTypeCastAndInline() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/codeSimplifications/RedundantTypeCastAndInline.java");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("j2k/testData/fileOrElement/comments")
|
||||
|
||||
@@ -1005,6 +1005,12 @@ public class JavaToKotlinConverterSingleFileTestGenerated extends AbstractJavaTo
|
||||
String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/codeSimplifications/RedundantTypeCast.java");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("RedundantTypeCastAndInline.java")
|
||||
public void testRedundantTypeCastAndInline() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/codeSimplifications/RedundantTypeCastAndInline.java");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("j2k/testData/fileOrElement/comments")
|
||||
|
||||
Reference in New Issue
Block a user