diff --git a/compiler/testData/checkLocalVariablesTable/destructuringInSuspendLambda/dataClass.kt b/compiler/testData/checkLocalVariablesTable/destructuringInSuspendLambda/dataClass.kt index f8b7b5bbf0d..69e06f580d0 100644 --- a/compiler/testData/checkLocalVariablesTable/destructuringInSuspendLambda/dataClass.kt +++ b/compiler/testData/checkLocalVariablesTable/destructuringInSuspendLambda/dataClass.kt @@ -1,4 +1,5 @@ // IGNORE_BACKEND: JVM_IR +// WITH_RUNTIME data class Data(val x: String, val y: Int) suspend fun test() { diff --git a/compiler/testData/checkLocalVariablesTable/destructuringInSuspendLambda/extensionComponents.kt b/compiler/testData/checkLocalVariablesTable/destructuringInSuspendLambda/extensionComponents.kt index efeb0db2432..5db4eb7f94f 100644 --- a/compiler/testData/checkLocalVariablesTable/destructuringInSuspendLambda/extensionComponents.kt +++ b/compiler/testData/checkLocalVariablesTable/destructuringInSuspendLambda/extensionComponents.kt @@ -1,4 +1,5 @@ // IGNORE_BACKEND: JVM_IR +// WITH_RUNTIME class A(val x: String, val y: String, val z: T) suspend fun foo(a: A, block: suspend (A) -> String): String = block(a) diff --git a/compiler/testData/checkLocalVariablesTable/destructuringInSuspendLambda/generic.kt b/compiler/testData/checkLocalVariablesTable/destructuringInSuspendLambda/generic.kt index 53c718e6ddb..b240fd96e44 100644 --- a/compiler/testData/checkLocalVariablesTable/destructuringInSuspendLambda/generic.kt +++ b/compiler/testData/checkLocalVariablesTable/destructuringInSuspendLambda/generic.kt @@ -1,4 +1,6 @@ // IGNORE_BACKEND: JVM_IR +// WITH_RUNTIME + data class A(val x: T, val y: F) suspend fun foo(a: A, block: suspend (A) -> String) = block(a) diff --git a/compiler/testData/checkLocalVariablesTable/destructuringInSuspendLambda/inline.kt b/compiler/testData/checkLocalVariablesTable/destructuringInSuspendLambda/inline.kt index 89e082c31a4..c906fd48cc3 100644 --- a/compiler/testData/checkLocalVariablesTable/destructuringInSuspendLambda/inline.kt +++ b/compiler/testData/checkLocalVariablesTable/destructuringInSuspendLambda/inline.kt @@ -1,4 +1,5 @@ // IGNORE_BACKEND: JVM_IR +// WITH_RUNTIME data class A(val x: String, val y: String) suspend inline fun foo(a: A, block: suspend (A) -> String): String = block(a) diff --git a/compiler/testData/checkLocalVariablesTable/destructuringInSuspendLambda/underscoreNames.kt b/compiler/testData/checkLocalVariablesTable/destructuringInSuspendLambda/underscoreNames.kt index 6d893ceedcb..bcf25d3b75a 100644 --- a/compiler/testData/checkLocalVariablesTable/destructuringInSuspendLambda/underscoreNames.kt +++ b/compiler/testData/checkLocalVariablesTable/destructuringInSuspendLambda/underscoreNames.kt @@ -1,4 +1,5 @@ // IGNORE_BACKEND: JVM_IR +// WITH_RUNTIME class A { operator fun component1() = "O" operator fun component2(): String = throw RuntimeException("fail 0") diff --git a/compiler/testData/checkLocalVariablesTable/jvmOverloads.kt b/compiler/testData/checkLocalVariablesTable/jvmOverloads.kt index 92522cfcb8d..7d13fec0ee0 100644 --- a/compiler/testData/checkLocalVariablesTable/jvmOverloads.kt +++ b/compiler/testData/checkLocalVariablesTable/jvmOverloads.kt @@ -1,4 +1,5 @@ // IGNORE_BACKEND: JVM_IR +// WITH_RUNTIME class C { @kotlin.jvm.JvmOverloads fun foo(firstParam: Int, secondParam: String = "") { } diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractCheckLocalVariablesTableTest.java b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractCheckLocalVariablesTableTest.java index 2a0e5ab48ae..a431e3be36a 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractCheckLocalVariablesTableTest.java +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractCheckLocalVariablesTableTest.java @@ -21,12 +21,10 @@ import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.backend.common.output.OutputFile; import org.jetbrains.kotlin.backend.common.output.OutputFileCollection; -import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment; -import org.jetbrains.kotlin.psi.KtFile; import org.jetbrains.kotlin.test.KotlinTestUtils; -import org.jetbrains.kotlin.test.TestCaseWithTmpdir; import org.jetbrains.org.objectweb.asm.*; import java.io.File; @@ -41,32 +39,14 @@ import java.util.regex.Pattern; * Test correctness of written local variables in class file for specified method */ -public abstract class AbstractCheckLocalVariablesTableTest extends TestCaseWithTmpdir { +public abstract class AbstractCheckLocalVariablesTableTest extends CodegenTestCase { protected File ktFile; - protected KotlinCoreEnvironment environment; - - public AbstractCheckLocalVariablesTableTest() { - } @Override - protected void setUp() throws Exception { - super.setUp(); - environment = KotlinTestUtils.createEnvironmentWithMockJdkAndIdeaAnnotations(myTestRootDisposable); - } - - @Override - protected void tearDown() throws Exception { - environment = null; - super.tearDown(); - } - - protected void doTest(@NotNull String ktFileName) throws Exception { - ktFile = new File(ktFileName); + protected void doMultiFileTest(@NotNull File wholeFile, @NotNull List files, @Nullable File javaFilesDir) throws Exception { + ktFile = wholeFile; String text = FileUtil.loadFile(ktFile, true); - - KtFile psiFile = KotlinTestUtils.createFile(ktFile.getName(), text, environment.getProject()); - - OutputFileCollection outputFiles = GenerationUtils.compileFile(psiFile, environment); + compile(files, javaFilesDir); String classAndMethod = parseClassAndMethodSignature(); String[] split = classAndMethod.split("\\."); @@ -74,9 +54,10 @@ public abstract class AbstractCheckLocalVariablesTableTest extends TestCaseWithT String classFileRegex = StringUtil.escapeToRegexp(split[0] + ".class").replace("\\*", ".+"); String methodName = split[1]; - OutputFile outputFile = ContainerUtil.find(outputFiles.asList(), file -> file.getRelativePath().matches(classFileRegex)); + List outputFiles = ((OutputFileCollection) classFileFactory).asList(); + OutputFile outputFile = ContainerUtil.find(outputFiles, file -> file.getRelativePath().matches(classFileRegex)); - String pathsString = StringUtil.join(outputFiles.asList(), OutputFile::getRelativePath, ", "); + String pathsString = StringUtil.join(outputFiles, OutputFile::getRelativePath, ", "); assertNotNull("Couldn't find class file for pattern " + classFileRegex + " in: " + pathsString, outputFile); ClassReader cr = new ClassReader(outputFile.asByteArray()); diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/ir/AbstractIrCheckLocalVariablesTableTest.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/ir/AbstractIrCheckLocalVariablesTableTest.kt index 3ec2f545cf9..c7183b1cd23 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/ir/AbstractIrCheckLocalVariablesTableTest.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/ir/AbstractIrCheckLocalVariablesTableTest.kt @@ -7,16 +7,20 @@ package org.jetbrains.kotlin.codegen.ir import com.intellij.openapi.util.Comparing import org.jetbrains.kotlin.codegen.AbstractCheckLocalVariablesTableTest +import org.jetbrains.kotlin.config.CompilerConfiguration import org.jetbrains.kotlin.config.JVMConfigurationKeys +import org.jetbrains.kotlin.test.ConfigurationKind import org.junit.ComparisonFailure import java.nio.charset.Charset abstract class AbstractIrCheckLocalVariablesTableTest : AbstractCheckLocalVariablesTableTest() { - @Throws(Exception::class) - override fun setUp() { - super.setUp() - assert(environment != null) - environment.configuration.put(JVMConfigurationKeys.IR, true) + + override fun updateConfiguration(configuration: CompilerConfiguration) { + configuration.put(JVMConfigurationKeys.IR, true) + } + + override fun extractConfigurationKind(files: MutableList): ConfigurationKind { + return ConfigurationKind.ALL; } override fun doCompare(text: String?, actualLocalVariables: MutableList) {