jvm-abi-gen: Mark all anonymous objects in inline function scope as public

Anonymous objects inside of a private inline function nested in a public
inline function can still escape.
This commit is contained in:
Steven Schäfer
2021-06-29 16:43:45 +02:00
committed by Alexander Udalov
parent d94817cfb6
commit 3ffe495346
11 changed files with 115 additions and 15 deletions
@@ -55,11 +55,21 @@ public class CompileAgainstJvmAbiTestGenerated extends AbstractCompileAgainstJvm
runTest("plugins/jvm-abi-gen/testData/compile/inlineCapture/");
}
@TestMetadata("inlineNoRegeneration")
public void testInlineNoRegeneration() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compile/inlineNoRegeneration/");
}
@TestMetadata("inlineReifiedFunction")
public void testInlineReifiedFunction() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compile/inlineReifiedFunction/");
}
@TestMetadata("innerObjectRegeneration")
public void testInnerObjectRegeneration() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compile/innerObjectRegeneration/");
}
@TestMetadata("privateOnlyConstructors")
public void testPrivateOnlyConstructors() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compile/privateOnlyConstructors/");
@@ -55,11 +55,21 @@ public class IrCompileAgainstJvmAbiTestGenerated extends AbstractIrCompileAgains
runTest("plugins/jvm-abi-gen/testData/compile/inlineCapture/");
}
@TestMetadata("inlineNoRegeneration")
public void testInlineNoRegeneration() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compile/inlineNoRegeneration/");
}
@TestMetadata("inlineReifiedFunction")
public void testInlineReifiedFunction() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compile/inlineReifiedFunction/");
}
@TestMetadata("innerObjectRegeneration")
public void testInnerObjectRegeneration() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compile/innerObjectRegeneration/");
}
@TestMetadata("privateOnlyConstructors")
public void testPrivateOnlyConstructors() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compile/privateOnlyConstructors/");
@@ -55,11 +55,21 @@ public class LegacyCompileAgainstJvmAbiTestGenerated extends AbstractLegacyCompi
runTest("plugins/jvm-abi-gen/testData/compile/inlineCapture/");
}
@TestMetadata("inlineNoRegeneration")
public void testInlineNoRegeneration() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compile/inlineNoRegeneration/");
}
@TestMetadata("inlineReifiedFunction")
public void testInlineReifiedFunction() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compile/inlineReifiedFunction/");
}
@TestMetadata("innerObjectRegeneration")
public void testInnerObjectRegeneration() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compile/innerObjectRegeneration/");
}
@TestMetadata("privateOnlyConstructors")
public void testPrivateOnlyConstructors() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compile/privateOnlyConstructors/");
@@ -0,0 +1,10 @@
package app
import lib.*
fun runAppAndReturnOk(): String {
foo {
"K"
}
return result
}
@@ -0,0 +1,19 @@
package lib
var result = "fail"
inline fun foo(crossinline s: () -> String) {
object {
private inline fun test(crossinline z: () -> String) {
result = object { //should be marked as public abi as there is no regenerated abject on inline
fun run(): String {
return "O"
}
}.run() + z()
}
fun foo() {
test { s() }
}
}.foo()
}
@@ -0,0 +1,10 @@
package app
import lib.*
fun runAppAndReturnOk(): String {
foo {
"OK"
}
return result
}
@@ -0,0 +1 @@
// IGNORE_BACKEND_LEGACY: JVM
@@ -0,0 +1,19 @@
package lib
var result = "fail"
inline fun foo(crossinline s: () -> String) {
object {
private inline fun test(crossinline z: () -> String) {
object {
fun run() {
result = z()
}
}.run()
}
fun foo() {
test { s() } // regenerated object should be marked as public abi
}
}.foo()
}