Add jvm-abi-gen test on inline class with private ctor

KT-54897
This commit is contained in:
Alexander Udalov
2022-11-11 12:52:40 +01:00
committed by Space Team
parent 89ba1b515e
commit beb3759f5a
8 changed files with 53 additions and 3 deletions
@@ -67,7 +67,7 @@ abstract class BaseJvmAbiTest : TestCase() {
dep.abiDir
}
val directives = if (compilation.directives.exists()) compilation.directives.readText() else null
val directives = if (compilation.directives.exists()) compilation.directives.readText() else ""
val messageCollector = LocationReportingTestMessageCollector()
val compiler = K2JVMCompiler()
@@ -80,8 +80,8 @@ abstract class BaseJvmAbiTest : TestCase() {
if (useLegacyAbiGen) abiOption("useLegacyAbiGen", "true") else null
).toTypedArray()
destination = compilation.destinationDir.canonicalPath
noSourceDebugExtension =
directives != null && InTextDirectivesUtils.findStringWithPrefixes(directives, "// NO_SOURCE_DEBUG_EXTENSION") != null
noSourceDebugExtension = InTextDirectivesUtils.findStringWithPrefixes(directives, "// NO_SOURCE_DEBUG_EXTENSION") != null
useK2 = InTextDirectivesUtils.findStringWithPrefixes(directives, "// USE_K2") != null
}
val exitCode = compiler.exec(messageCollector, Services.EMPTY, args)
if (exitCode != ExitCode.OK || messageCollector.errors.isNotEmpty()) {
@@ -60,6 +60,16 @@ public class CompileAgainstJvmAbiTestGenerated extends AbstractCompileAgainstJvm
runTest("plugins/jvm-abi-gen/testData/compile/inlineCapture/");
}
@TestMetadata("inlineClassWithPrivateConstructor")
public void testInlineClassWithPrivateConstructor() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compile/inlineClassWithPrivateConstructor/");
}
@TestMetadata("inlineClassWithPrivateConstructorK2")
public void testInlineClassWithPrivateConstructorK2() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compile/inlineClassWithPrivateConstructorK2/");
}
@TestMetadata("inlineNoRegeneration")
public void testInlineNoRegeneration() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compile/inlineNoRegeneration/");
@@ -60,6 +60,16 @@ public class LegacyCompileAgainstJvmAbiTestGenerated extends AbstractLegacyCompi
runTest("plugins/jvm-abi-gen/testData/compile/inlineCapture/");
}
@TestMetadata("inlineClassWithPrivateConstructor")
public void testInlineClassWithPrivateConstructor() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compile/inlineClassWithPrivateConstructor/");
}
@TestMetadata("inlineClassWithPrivateConstructorK2")
public void testInlineClassWithPrivateConstructorK2() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compile/inlineClassWithPrivateConstructorK2/");
}
@TestMetadata("inlineNoRegeneration")
public void testInlineNoRegeneration() throws Exception {
runTest("plugins/jvm-abi-gen/testData/compile/inlineNoRegeneration/");
@@ -0,0 +1,6 @@
package app
import lib.*
fun runAppAndReturnOk(): String =
IC.of("OK").value
@@ -0,0 +1,8 @@
package lib
@JvmInline
value class IC private constructor(val value: String) {
companion object {
fun of(value: String) = IC(value)
}
}
@@ -0,0 +1,6 @@
package app
import lib.*
fun runAppAndReturnOk(): String =
IC.of("OK").value
@@ -0,0 +1,2 @@
// USE_K2
// IGNORE_BACKEND_LEGACY: JVM_IR
@@ -0,0 +1,8 @@
package lib
@JvmInline
value class IC private constructor(val value: String) {
companion object {
fun of(value: String) = IC(value)
}
}