Don't remove nullability assertions of anonymous object transformation
#KT-19910 Fixed
This commit is contained in:
@@ -82,8 +82,12 @@ class MethodInliner(
|
|||||||
|
|
||||||
//substitute returns with "goto end" instruction to keep non local returns in lambdas
|
//substitute returns with "goto end" instruction to keep non local returns in lambdas
|
||||||
val end = Label()
|
val end = Label()
|
||||||
|
val isTransformingAnonymousObject = nodeRemapper is RegeneratedLambdaFieldRemapper
|
||||||
transformedNode = doInline(transformedNode)
|
transformedNode = doInline(transformedNode)
|
||||||
removeClosureAssertions(transformedNode)
|
if (!isTransformingAnonymousObject) {
|
||||||
|
//don't remove assertion in transformed anonymous object
|
||||||
|
removeClosureAssertions(transformedNode)
|
||||||
|
}
|
||||||
transformedNode.instructions.resetLabels()
|
transformedNode.instructions.resetLabels()
|
||||||
|
|
||||||
val resultNode = MethodNode(
|
val resultNode = MethodNode(
|
||||||
@@ -93,7 +97,7 @@ class MethodInliner(
|
|||||||
val visitor = RemapVisitor(
|
val visitor = RemapVisitor(
|
||||||
resultNode, remapper, nodeRemapper,
|
resultNode, remapper, nodeRemapper,
|
||||||
/*copy annotation and attributes*/
|
/*copy annotation and attributes*/
|
||||||
nodeRemapper is RegeneratedLambdaFieldRemapper
|
isTransformingAnonymousObject
|
||||||
)
|
)
|
||||||
try {
|
try {
|
||||||
transformedNode.accept(visitor)
|
transformedNode.accept(visitor)
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
// FILE: J.java
|
||||||
|
// FULL_JDK
|
||||||
|
// WITH_RUNTIME
|
||||||
|
// TARGET_BACKEND: JVM
|
||||||
|
public class J {
|
||||||
|
public interface Consumer {
|
||||||
|
void accept(String p);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void invokeWithNull(Consumer x) {
|
||||||
|
x.accept(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: Kotlin.kt
|
||||||
|
|
||||||
|
|
||||||
|
inline fun makeRunnable(crossinline lambda: () -> Unit) =
|
||||||
|
object : Runnable {
|
||||||
|
override fun run() {
|
||||||
|
lambda()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
try {
|
||||||
|
makeRunnable {
|
||||||
|
J.invokeWithNull(object : J.Consumer {
|
||||||
|
override fun accept(t: String) {
|
||||||
|
println(t)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}.run()
|
||||||
|
} catch (e: IllegalArgumentException) {
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
|
|
||||||
|
return "fail: exception expected"
|
||||||
|
}
|
||||||
@@ -124,7 +124,7 @@ object InlineTestUtil {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visitMethod(access: Int, name: String, desc: String, signature: String, exceptions: Array<String>): MethodVisitor? {
|
override fun visitMethod(access: Int, name: String, desc: String, signature: String?, exceptions: Array<String>?): MethodVisitor? {
|
||||||
if (skipMethodsOfThisClass) {
|
if (skipMethodsOfThisClass) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|||||||
+15
@@ -354,6 +354,21 @@ public class BlackBoxAgainstJavaCodegenTestGenerated extends AbstractBlackBoxAga
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("compiler/testData/codegen/boxAgainstJava/inline")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class Inline extends AbstractBlackBoxAgainstJavaCodegenTest {
|
||||||
|
public void testAllFilesPresentInInline() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxAgainstJava/inline"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt19910.kt")
|
||||||
|
public void testKt19910() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxAgainstJava/inline/kt19910.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/boxAgainstJava/innerClass")
|
@TestMetadata("compiler/testData/codegen/boxAgainstJava/innerClass")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
Reference in New Issue
Block a user