[Tests] FIR support in JUnit 3 tests, port necessary subclasses
^KT-64404 Fixed ^KT-64438 Fixed ^KT-64407 Fixed
This commit is contained in:
committed by
Space Team
parent
e69d6d2d05
commit
9a2e4c6b41
@@ -136,7 +136,8 @@ abstract class AbstractCustomScriptCodegenTest : CodegenTestCase() {
|
||||
}
|
||||
|
||||
abstract class AbstractIrCustomScriptCodegenTest : AbstractCustomScriptCodegenTest() {
|
||||
override val backend: TargetBackend = TargetBackend.JVM_IR
|
||||
override val backend: TargetBackend
|
||||
get() = TargetBackend.JVM_IR
|
||||
}
|
||||
|
||||
object TestScriptWithReceiversConfiguration : ScriptCompilationConfiguration(
|
||||
|
||||
@@ -82,7 +82,7 @@ public class ControlStructuresTest extends CodegenTestCase {
|
||||
public void testCompareToNonnullableNotEq() throws Exception {
|
||||
loadText("fun foo(a: String?, b: String): Boolean = a != b");
|
||||
String text = generateToText();
|
||||
assertTrue(text.contains("IXOR"));
|
||||
assertTrue(text, text.contains("IXOR"));
|
||||
Method main = generateFunction();
|
||||
assertEquals(true, main.invoke(null, null, "lala"));
|
||||
assertEquals(false, main.invoke(null, "papa", "papa"));
|
||||
|
||||
@@ -21,8 +21,8 @@ import org.jetbrains.kotlin.test.ConfigurationKind
|
||||
import org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase
|
||||
|
||||
@OptIn(ObsoleteTestInfrastructure::class)
|
||||
class CustomBytecodeTextTest : AbstractBytecodeTextTest() {
|
||||
fun testEnumMapping() {
|
||||
open class CustomBytecodeTextTest : AbstractBytecodeTextTest() {
|
||||
open fun testEnumMapping() {
|
||||
createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.ALL)
|
||||
myFiles = CodegenTestFiles.create(
|
||||
"whenMappingOrder.kt",
|
||||
@@ -46,13 +46,13 @@ class CustomBytecodeTextTest : AbstractBytecodeTextTest() {
|
||||
val text = generateToText()
|
||||
val getstatics = text.lines().filter { it.contains("GETSTATIC MyEnum.") }.map { it.trim() }
|
||||
KtUsefulTestCase.assertOrderedEquals(
|
||||
"actual bytecode:\n$text", listOf(
|
||||
"actual bytecode:\n$text", getstatics, listOf(
|
||||
"GETSTATIC MyEnum.${'$'}VALUES : [LMyEnum;",
|
||||
"GETSTATIC MyEnum.ENTRY4 : LMyEnum;",
|
||||
"GETSTATIC MyEnum.ENTRY3 : LMyEnum;",
|
||||
"GETSTATIC MyEnum.ENTRY2 : LMyEnum;",
|
||||
"GETSTATIC MyEnum.ENTRY1 : LMyEnum;"
|
||||
), getstatics
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,9 +25,8 @@ import kotlin.script.experimental.annotations.KotlinScript
|
||||
import kotlin.script.experimental.jvm.defaultJvmScriptingHostConfiguration
|
||||
import kotlin.script.experimental.jvm.util.scriptCompilationClasspathFromContextOrStdlib
|
||||
|
||||
class CustomScriptCodegenTest : CodegenTestCase() {
|
||||
|
||||
fun testAnnotatedDefinition() {
|
||||
open class CustomScriptCodegenTest : CodegenTestCase() {
|
||||
open fun testAnnotatedDefinition() {
|
||||
createScriptTestEnvironment("org.jetbrains.kotlin.codegen.TestScriptWithAnnotatedBaseClass")
|
||||
loadScript("val x = 1")
|
||||
val res = generateScriptClass()
|
||||
@@ -42,6 +41,9 @@ class CustomScriptCodegenTest : CodegenTestCase() {
|
||||
myFiles = CodegenTestFiles.create("scriptTest.kts", text, myEnvironment.project)
|
||||
}
|
||||
|
||||
override val backend: TargetBackend
|
||||
get() = TargetBackend.JVM
|
||||
|
||||
private fun createScriptTestEnvironment(vararg scriptDefinitions: String) {
|
||||
if (myEnvironment != null) {
|
||||
throw IllegalStateException("must not set up myEnvironment twice")
|
||||
@@ -60,7 +62,6 @@ class CustomScriptCodegenTest : CodegenTestCase() {
|
||||
val configuration = createConfiguration(
|
||||
ConfigurationKind.ALL,
|
||||
TestJdkKind.MOCK_JDK,
|
||||
TargetBackend.JVM,
|
||||
additionalDependencies,
|
||||
emptyList(),
|
||||
emptyList()
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.codegen;
|
||||
|
||||
public class GenerateNotNullAssertionsTest extends AbstractGenerateNotNullAssertionsTest {
|
||||
public void testNoAssertionsForKotlinFromBinary() {
|
||||
doTestNoAssertionsForKotlinFromBinary("noAssertionsForKotlin.kt", "noAssertionsForKotlinMain.kt");
|
||||
}
|
||||
}
|
||||
@@ -24,8 +24,8 @@ import org.jetbrains.org.objectweb.asm.MethodVisitor
|
||||
import org.jetbrains.org.objectweb.asm.Opcodes
|
||||
import java.util.*
|
||||
|
||||
class MethodOrderTest : CodegenTestCase() {
|
||||
fun testDelegatedMethod() {
|
||||
open class MethodOrderTest : CodegenTestCase() {
|
||||
open fun testDelegatedMethod() {
|
||||
doTest(
|
||||
"""
|
||||
interface Trait {
|
||||
@@ -48,7 +48,7 @@ class MethodOrderTest : CodegenTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
fun testLambdaClosureOrdering() {
|
||||
open fun testLambdaClosureOrdering() {
|
||||
doTest(
|
||||
"""
|
||||
class Klass {
|
||||
@@ -66,7 +66,7 @@ class MethodOrderTest : CodegenTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
fun testAnonymousObjectClosureOrdering() {
|
||||
open fun testAnonymousObjectClosureOrdering() {
|
||||
doTest(
|
||||
"""
|
||||
class Klass {
|
||||
@@ -84,7 +84,7 @@ class MethodOrderTest : CodegenTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
fun testMemberAccessor() {
|
||||
open fun testMemberAccessor() {
|
||||
doTest(
|
||||
"""
|
||||
class Outer(private val a: Int, private var b: String) {
|
||||
@@ -111,7 +111,7 @@ class MethodOrderTest : CodegenTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
fun testDeterministicDefaultMethodImplOrder() {
|
||||
open fun testDeterministicDefaultMethodImplOrder() {
|
||||
doTest(
|
||||
"""
|
||||
interface Base<K, V> {
|
||||
@@ -147,7 +147,7 @@ class MethodOrderTest : CodegenTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
fun testBridgeOrder() {
|
||||
open fun testBridgeOrder() {
|
||||
doTest(
|
||||
"""
|
||||
interface IrElement
|
||||
@@ -174,11 +174,12 @@ class MethodOrderTest : CodegenTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
private fun doTest(sourceText: String, classSuffix: String, expectedOrder: List<String>) {
|
||||
protected fun doTest(sourceText: String, classSuffix: String, expectedOrder: List<String>) {
|
||||
createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY)
|
||||
myFiles = CodegenTestFiles.create("file.kt", sourceText, myEnvironment!!.project)
|
||||
|
||||
val classFileForObject = generateClassesInFile().asList().first { it.relativePath.endsWith("$classSuffix.class") }
|
||||
val classFileForObject = generateClassesInFile().asList().firstOrNull { it.relativePath.endsWith("$classSuffix.class") }
|
||||
checkNotNull(classFileForObject) { "class ending on $classSuffix was not generated" }
|
||||
val classReader = ClassReader(classFileForObject.asByteArray())
|
||||
|
||||
val methodNames = ArrayList<String>()
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.codegen
|
||||
|
||||
import org.jetbrains.kotlin.test.ConfigurationKind
|
||||
|
||||
class ReflectionClassLoaderTest : CodegenTestCase() {
|
||||
open class ReflectionClassLoaderTest : CodegenTestCase() {
|
||||
override fun getPrefix() = "reflection/classLoaders"
|
||||
|
||||
override fun setUp() {
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.codegen.defaultConstructor.fir
|
||||
|
||||
import org.jetbrains.kotlin.codegen.defaultConstructor.ir.AbstractIrDefaultArgumentsReflectionTest
|
||||
import org.jetbrains.kotlin.test.FirParser
|
||||
|
||||
abstract class AbstractFirLightTreeDefaultArgumentsReflectionTest : AbstractIrDefaultArgumentsReflectionTest() {
|
||||
override val useFir: Boolean
|
||||
get() = true
|
||||
|
||||
override val firParser: FirParser
|
||||
get() = FirParser.LightTree
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.codegen.defaultConstructor.fir
|
||||
|
||||
import org.jetbrains.kotlin.codegen.defaultConstructor.ir.AbstractIrDefaultArgumentsReflectionTest
|
||||
import org.jetbrains.kotlin.test.FirParser
|
||||
|
||||
abstract class AbstractFirPsiDefaultArgumentsReflectionTest : AbstractIrDefaultArgumentsReflectionTest() {
|
||||
override val useFir: Boolean
|
||||
get() = true
|
||||
|
||||
override val firParser: FirParser
|
||||
get() = FirParser.Psi
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.codegen.defaultConstructor.ir
|
||||
|
||||
import org.jetbrains.kotlin.codegen.defaultConstructor.AbstractDefaultArgumentsReflectionTest
|
||||
import org.jetbrains.kotlin.test.TargetBackend
|
||||
|
||||
abstract class AbstractIrDefaultArgumentsReflectionTest : AbstractDefaultArgumentsReflectionTest() {
|
||||
override val backend: TargetBackend
|
||||
get() = TargetBackend.JVM_IR
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
/*
|
||||
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@file:Suppress("JUnitTestCaseWithNoTests")
|
||||
|
||||
package org.jetbrains.kotlin.codegen.fir
|
||||
|
||||
import org.jetbrains.kotlin.codegen.ir.*
|
||||
import org.jetbrains.kotlin.jvm.compiler.JvmIrLinkageModeTest
|
||||
import org.jetbrains.kotlin.test.FirParser
|
||||
import org.jetbrains.kotlin.test.FirParser.LightTree
|
||||
|
||||
class FirLightTreePackageGenTest : IrPackageGenTest() {
|
||||
override val useFir: Boolean
|
||||
get() = true
|
||||
|
||||
override val firParser: FirParser
|
||||
get() = LightTree
|
||||
}
|
||||
|
||||
class FirLightTreePrimitiveTypesTest : IrPrimitiveTypesTest() {
|
||||
override val useFir: Boolean
|
||||
get() = true
|
||||
|
||||
override val firParser: FirParser
|
||||
get() = LightTree
|
||||
}
|
||||
|
||||
class FirLightTreeAnnotationGenTest : IrAnnotationGenTest() {
|
||||
override val useFir: Boolean
|
||||
get() = true
|
||||
|
||||
override val firParser: FirParser
|
||||
get() = LightTree
|
||||
}
|
||||
|
||||
class FirLightTreeOuterClassGenTest : IrOuterClassGenTest() {
|
||||
override val useFir: Boolean
|
||||
get() = true
|
||||
|
||||
override val firParser: FirParser
|
||||
get() = LightTree
|
||||
}
|
||||
|
||||
abstract class AbstractFirLightTreeCheckLocalVariablesTableTest : AbstractIrCheckLocalVariablesTableTest() {
|
||||
override val useFir: Boolean
|
||||
get() = true
|
||||
|
||||
override val firParser: FirParser
|
||||
get() = LightTree
|
||||
}
|
||||
|
||||
class FirLightTreePropertyGenTest : IrPropertyGenTest() {
|
||||
override val useFir: Boolean
|
||||
get() = true
|
||||
|
||||
override val firParser: FirParser
|
||||
get() = LightTree
|
||||
}
|
||||
|
||||
class FirLightTreeKotlinSyntheticClassAnnotationTest : IrKotlinSyntheticClassAnnotationTest() {
|
||||
override val useFir: Boolean
|
||||
get() = true
|
||||
|
||||
override val firParser: FirParser
|
||||
get() = LightTree
|
||||
}
|
||||
|
||||
class FirLightTreeVarArgTest : IrVarArgTest() {
|
||||
override val useFir: Boolean
|
||||
get() = true
|
||||
|
||||
override val firParser: FirParser
|
||||
get() = LightTree
|
||||
}
|
||||
|
||||
class FirLightTreeControlStructuresTest : IrControlStructuresTest() {
|
||||
override val useFir: Boolean
|
||||
get() = true
|
||||
|
||||
override val firParser: FirParser
|
||||
get() = LightTree
|
||||
}
|
||||
|
||||
class FirLightTreeInnerClassInfoGenTest : IrInnerClassInfoGenTest() {
|
||||
override val useFir: Boolean
|
||||
get() = true
|
||||
|
||||
override val firParser: FirParser
|
||||
get() = LightTree
|
||||
}
|
||||
|
||||
class FirLightTreeMethodOrderTest : IrMethodOrderTest() {
|
||||
override val useFir: Boolean
|
||||
get() = true
|
||||
|
||||
override val firParser: FirParser
|
||||
get() = LightTree
|
||||
|
||||
override fun testDelegatedMethod() {
|
||||
doTest(
|
||||
"""
|
||||
interface Trait {
|
||||
fun f0()
|
||||
fun f4()
|
||||
fun f3()
|
||||
fun f2()
|
||||
fun f1()
|
||||
fun f5()
|
||||
}
|
||||
|
||||
val delegate: Trait = throw Error()
|
||||
|
||||
val obj = object : Trait by delegate {
|
||||
override fun f3() { }
|
||||
}
|
||||
""",
|
||||
"\$obj$1",
|
||||
listOf("<init>()V", "f0()V", "f4()V", "f2()V", "f1()V", "f5()V", "f3()V")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
class FirLightTreeReflectionClassLoaderTest : IrReflectionClassLoaderTest() {
|
||||
override val useFir: Boolean
|
||||
get() = true
|
||||
|
||||
override val firParser: FirParser
|
||||
get() = LightTree
|
||||
}
|
||||
|
||||
class FirLightTreeCustomBytecodeTextTest : IrCustomBytecodeTextTest() {
|
||||
override val useFir: Boolean
|
||||
get() = true
|
||||
|
||||
override val firParser: FirParser
|
||||
get() = LightTree
|
||||
}
|
||||
|
||||
class FirLightTreeCustomScriptCodegenTest : IrCustomScriptCodegenTest() {
|
||||
override val useFir: Boolean
|
||||
get() = true
|
||||
|
||||
override val firParser: FirParser
|
||||
get() = LightTree
|
||||
}
|
||||
|
||||
class FirLightTreeGenerateNotNullAssertionsTest : IrGenerateNotNullAssertionsTest() {
|
||||
override val useFir: Boolean
|
||||
get() = true
|
||||
|
||||
override val firParser: FirParser
|
||||
get() = LightTree
|
||||
}
|
||||
|
||||
class FirLightTreeSourceInfoGenTest : IrSourceInfoGenTest() {
|
||||
override val useFir: Boolean
|
||||
get() = true
|
||||
|
||||
override val firParser: FirParser
|
||||
get() = LightTree
|
||||
}
|
||||
|
||||
class FirLightTreeLinkageModeTest : JvmIrLinkageModeTest() {
|
||||
override val useFir: Boolean
|
||||
get() = true
|
||||
|
||||
override val firParser: FirParser
|
||||
get() = LightTree
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
/*
|
||||
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@file:Suppress("JUnitTestCaseWithNoTests")
|
||||
|
||||
package org.jetbrains.kotlin.codegen.fir
|
||||
|
||||
import org.jetbrains.kotlin.codegen.ir.*
|
||||
import org.jetbrains.kotlin.jvm.compiler.JvmIrLinkageModeTest
|
||||
import org.jetbrains.kotlin.test.FirParser
|
||||
import org.jetbrains.kotlin.test.FirParser.Psi
|
||||
|
||||
class FirPsiPackageGenTest : IrPackageGenTest() {
|
||||
override val useFir: Boolean
|
||||
get() = true
|
||||
|
||||
override val firParser: FirParser
|
||||
get() = Psi
|
||||
}
|
||||
|
||||
class FirPsiPrimitiveTypesTest : IrPrimitiveTypesTest() {
|
||||
override val useFir: Boolean
|
||||
get() = true
|
||||
|
||||
override val firParser: FirParser
|
||||
get() = Psi
|
||||
}
|
||||
|
||||
class FirPsiAnnotationGenTest : IrAnnotationGenTest() {
|
||||
override val useFir: Boolean
|
||||
get() = true
|
||||
|
||||
override val firParser: FirParser
|
||||
get() = Psi
|
||||
}
|
||||
|
||||
class FirPsiOuterClassGenTest : IrOuterClassGenTest() {
|
||||
override val useFir: Boolean
|
||||
get() = true
|
||||
|
||||
override val firParser: FirParser
|
||||
get() = Psi
|
||||
}
|
||||
|
||||
abstract class AbstractFirPsiCheckLocalVariablesTableTest : AbstractIrCheckLocalVariablesTableTest() {
|
||||
override val useFir: Boolean
|
||||
get() = true
|
||||
|
||||
override val firParser: FirParser
|
||||
get() = Psi
|
||||
}
|
||||
|
||||
class FirPsiPropertyGenTest : IrPropertyGenTest() {
|
||||
override val useFir: Boolean
|
||||
get() = true
|
||||
|
||||
override val firParser: FirParser
|
||||
get() = Psi
|
||||
}
|
||||
|
||||
class FirPsiKotlinSyntheticClassAnnotationTest : IrKotlinSyntheticClassAnnotationTest() {
|
||||
override val useFir: Boolean
|
||||
get() = true
|
||||
|
||||
override val firParser: FirParser
|
||||
get() = Psi
|
||||
}
|
||||
|
||||
class FirPsiVarArgTest : IrVarArgTest() {
|
||||
override val useFir: Boolean
|
||||
get() = true
|
||||
|
||||
override val firParser: FirParser
|
||||
get() = Psi
|
||||
}
|
||||
|
||||
class FirPsiControlStructuresTest : IrControlStructuresTest() {
|
||||
override val useFir: Boolean
|
||||
get() = true
|
||||
|
||||
override val firParser: FirParser
|
||||
get() = Psi
|
||||
}
|
||||
|
||||
class FirPsiInnerClassInfoGenTest : IrInnerClassInfoGenTest() {
|
||||
override val useFir: Boolean
|
||||
get() = true
|
||||
|
||||
override val firParser: FirParser
|
||||
get() = Psi
|
||||
}
|
||||
|
||||
class FirPsiMethodOrderTest : IrMethodOrderTest() {
|
||||
override val useFir: Boolean
|
||||
get() = true
|
||||
|
||||
override val firParser: FirParser
|
||||
get() = Psi
|
||||
|
||||
override fun testDelegatedMethod() {
|
||||
doTest(
|
||||
"""
|
||||
interface Trait {
|
||||
fun f0()
|
||||
fun f4()
|
||||
fun f3()
|
||||
fun f2()
|
||||
fun f1()
|
||||
fun f5()
|
||||
}
|
||||
|
||||
val delegate: Trait = throw Error()
|
||||
|
||||
val obj = object : Trait by delegate {
|
||||
override fun f3() { }
|
||||
}
|
||||
""",
|
||||
"\$obj$1",
|
||||
listOf("<init>()V", "f0()V", "f4()V", "f2()V", "f1()V", "f5()V", "f3()V")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
class FirPsiReflectionClassLoaderTest : IrReflectionClassLoaderTest() {
|
||||
override val useFir: Boolean
|
||||
get() = true
|
||||
|
||||
override val firParser: FirParser
|
||||
get() = Psi
|
||||
}
|
||||
|
||||
class FirPsiCustomBytecodeTextTest : IrCustomBytecodeTextTest() {
|
||||
override val useFir: Boolean
|
||||
get() = true
|
||||
|
||||
override val firParser: FirParser
|
||||
get() = Psi
|
||||
}
|
||||
|
||||
class FirPsiCustomScriptCodegenTest : IrCustomScriptCodegenTest() {
|
||||
override val useFir: Boolean
|
||||
get() = true
|
||||
|
||||
override val firParser: FirParser
|
||||
get() = Psi
|
||||
}
|
||||
|
||||
class FirPsiGenerateNotNullAssertionsTest : IrGenerateNotNullAssertionsTest() {
|
||||
override val useFir: Boolean
|
||||
get() = true
|
||||
|
||||
override val firParser: FirParser
|
||||
get() = Psi
|
||||
}
|
||||
|
||||
class FirPsiSourceInfoGenTest : IrSourceInfoGenTest() {
|
||||
override val useFir: Boolean
|
||||
get() = true
|
||||
|
||||
override val firParser: FirParser
|
||||
get() = Psi
|
||||
}
|
||||
|
||||
class FirPsiLinkageModeTest : JvmIrLinkageModeTest() {
|
||||
override val useFir: Boolean
|
||||
get() = true
|
||||
|
||||
override val firParser: FirParser
|
||||
get() = Psi
|
||||
}
|
||||
@@ -0,0 +1,268 @@
|
||||
/*
|
||||
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@file:Suppress("JUnitTestCaseWithNoTests")
|
||||
|
||||
package org.jetbrains.kotlin.codegen.ir
|
||||
|
||||
import org.jetbrains.kotlin.codegen.*
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.config.JVMConfigurationKeys
|
||||
import org.jetbrains.kotlin.config.JvmClosureGenerationScheme
|
||||
import org.jetbrains.kotlin.test.TargetBackend
|
||||
import org.jetbrains.kotlin.test.TargetBackend.JVM_IR
|
||||
|
||||
open class IrPackageGenTest : PackageGenTest() {
|
||||
override val backend: TargetBackend
|
||||
get() = JVM_IR
|
||||
}
|
||||
|
||||
open class IrPrimitiveTypesTest : PrimitiveTypesTest() {
|
||||
override val backend: TargetBackend
|
||||
get() = JVM_IR
|
||||
}
|
||||
|
||||
open class IrAnnotationGenTest : AnnotationGenTest() {
|
||||
override val backend: TargetBackend
|
||||
get() = JVM_IR
|
||||
}
|
||||
|
||||
open class IrOuterClassGenTest : OuterClassGenTest() {
|
||||
override val backend: TargetBackend
|
||||
get() = JVM_IR
|
||||
|
||||
// Class lambda not generated
|
||||
|
||||
override fun testLambdaInConstructor() {
|
||||
}
|
||||
|
||||
override fun testLambdaInInlineFunction() {
|
||||
}
|
||||
|
||||
override fun testLambdaInInlineLambda() {
|
||||
}
|
||||
|
||||
override fun testLambdaInLambdaInlinedIntoObject() {
|
||||
}
|
||||
|
||||
override fun testLambdaInLambdaInlinedIntoObject2() {
|
||||
}
|
||||
|
||||
override fun testLambdaInNoInlineFun() {
|
||||
}
|
||||
|
||||
override fun testLambdaInlined() {
|
||||
}
|
||||
|
||||
override fun testLocalObjectInInlineLambda() {
|
||||
}
|
||||
|
||||
override fun testLocalObjectInLambdaInlinedIntoObject2() {
|
||||
}
|
||||
}
|
||||
|
||||
open class IrPropertyGenTest : PropertyGenTest() {
|
||||
override val backend: TargetBackend
|
||||
get() = JVM_IR
|
||||
}
|
||||
|
||||
open class IrKotlinSyntheticClassAnnotationTest : KotlinSyntheticClassAnnotationTest() {
|
||||
override val backend: TargetBackend
|
||||
get() = JVM_IR
|
||||
|
||||
override fun updateConfiguration(configuration: CompilerConfiguration) {
|
||||
// Current tests rely on class lambdas
|
||||
configuration.put(JVMConfigurationKeys.LAMBDAS, JvmClosureGenerationScheme.CLASS)
|
||||
configuration.put(JVMConfigurationKeys.SAM_CONVERSIONS, JvmClosureGenerationScheme.CLASS)
|
||||
super.updateConfiguration(configuration)
|
||||
}
|
||||
|
||||
override fun testLocalFunction() {
|
||||
// Indy is generated, irrelevant test
|
||||
}
|
||||
}
|
||||
|
||||
open class IrVarArgTest : VarArgTest() {
|
||||
override val backend: TargetBackend
|
||||
get() = JVM_IR
|
||||
}
|
||||
|
||||
open class IrControlStructuresTest : ControlStructuresTest() {
|
||||
override val backend: TargetBackend
|
||||
get() = JVM_IR
|
||||
|
||||
override fun testCompareToNonnullableNotEq() {
|
||||
// https://youtrack.jetbrains.com/issue/KT-65357
|
||||
}
|
||||
}
|
||||
|
||||
open class IrInnerClassInfoGenTest : InnerClassInfoGenTest() {
|
||||
override val backend: TargetBackend
|
||||
get() = JVM_IR
|
||||
|
||||
// Test is irrelevant with indy lambdas.
|
||||
|
||||
override fun testLambdaClassFlags() {
|
||||
}
|
||||
}
|
||||
|
||||
open class IrMethodOrderTest : MethodOrderTest() {
|
||||
override val backend: TargetBackend
|
||||
get() = JVM_IR
|
||||
|
||||
// Test is irrelevant with indy lambdas.
|
||||
override fun testLambdaClosureOrdering() {
|
||||
}
|
||||
|
||||
override fun testDelegatedMethod() {
|
||||
doTest(
|
||||
"""
|
||||
interface Trait {
|
||||
fun f0()
|
||||
fun f4()
|
||||
fun f3()
|
||||
fun f2()
|
||||
fun f1()
|
||||
fun f5()
|
||||
}
|
||||
|
||||
val delegate: Trait = throw Error()
|
||||
|
||||
val obj = object : Trait by delegate {
|
||||
override fun f3() { }
|
||||
}
|
||||
""",
|
||||
"\$obj$1",
|
||||
listOf( "<init>()V", "f0()V", "f1()V", "f2()V", "f4()V", "f5()V", "f3()V")
|
||||
)
|
||||
}
|
||||
|
||||
override fun testAnonymousObjectClosureOrdering() {
|
||||
doTest(
|
||||
"""
|
||||
class Klass {
|
||||
fun Any.f(a: String, b: Int, c: Double, d: Any, e: Long) {
|
||||
object : Runnable {
|
||||
override fun run() {
|
||||
a + b + c + d + e + this@f + this@Klass
|
||||
}
|
||||
}.run()
|
||||
}
|
||||
}
|
||||
""",
|
||||
"\$f$1",
|
||||
listOf("<init>(Ljava/lang/String;IDLjava/lang/Object;JLjava/lang/Object;LKlass;)V", "run()V")
|
||||
)
|
||||
}
|
||||
|
||||
override fun testBridgeOrder() {
|
||||
doTest(
|
||||
"""
|
||||
interface IrElement
|
||||
class IrClassContext
|
||||
|
||||
interface IrElementVisitor<out R, in D> {
|
||||
fun visitElement(element: IrElement, data: D): R
|
||||
}
|
||||
|
||||
interface IrElementTransformer<in D> : IrElementVisitor<IrElement, D> {
|
||||
override fun visitElement(element: IrElement, data: D): IrElement =
|
||||
element.also { throw RuntimeException() }
|
||||
}
|
||||
|
||||
abstract class ClassLowerWithContext : IrElementTransformer<IrClassContext?>
|
||||
""",
|
||||
"ClassLowerWithContext",
|
||||
listOf(
|
||||
"<init>()V",
|
||||
"visitElement(LIrElement;LIrClassContext;)LIrElement;",
|
||||
"visitElement(LIrElement;Ljava/lang/Object;)LIrElement;",
|
||||
"visitElement(LIrElement;Ljava/lang/Object;)Ljava/lang/Object;",
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun testMemberAccessor() {
|
||||
doTest(
|
||||
"""
|
||||
class Outer(private val a: Int, private var b: String) {
|
||||
private fun c() {
|
||||
}
|
||||
|
||||
inner class Inner() {
|
||||
init {
|
||||
b = b + a
|
||||
c()
|
||||
}
|
||||
}
|
||||
}
|
||||
""",
|
||||
"Outer",
|
||||
listOf(
|
||||
"<init>(ILjava/lang/String;)V",
|
||||
"c()V",
|
||||
"access\$setB\$p(LOuter;Ljava/lang/String;)V",
|
||||
"access\$getB\$p(LOuter;)Ljava/lang/String;",
|
||||
"access\$getA\$p(LOuter;)I",
|
||||
"access\$c(LOuter;)V"
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun testDeterministicDefaultMethodImplOrder() {
|
||||
doTest(
|
||||
"""
|
||||
interface Base<K, V> {
|
||||
fun getSize(): Int = 5
|
||||
fun size(): Int = getSize()
|
||||
fun getKeys(): Int = 4
|
||||
fun keySet() = getKeys()
|
||||
fun getEntries(): Int = 3
|
||||
fun entrySet() = getEntries()
|
||||
fun getValues(): Int = 2
|
||||
fun values() = getValues()
|
||||
|
||||
fun removeEldestEntry(eldest: Any?): Boolean
|
||||
}
|
||||
|
||||
class MinMap<K, V> : Base<K, V> {
|
||||
override fun removeEldestEntry(eldest: Any?) = true
|
||||
}
|
||||
""",
|
||||
"MinMap",
|
||||
listOf(
|
||||
"<init>()V",
|
||||
"removeEldestEntry(Ljava/lang/Object;)Z",
|
||||
"getSize()I",
|
||||
"size()I",
|
||||
"getKeys()I",
|
||||
"keySet()I",
|
||||
"getEntries()I",
|
||||
"entrySet()I",
|
||||
"getValues()I",
|
||||
"values()I"
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
open class IrReflectionClassLoaderTest : ReflectionClassLoaderTest() {
|
||||
override val backend: TargetBackend
|
||||
get() = JVM_IR
|
||||
}
|
||||
|
||||
open class IrCustomScriptCodegenTest : CustomScriptCodegenTest() {
|
||||
override val backend: TargetBackend
|
||||
get() = JVM_IR
|
||||
|
||||
override fun testAnnotatedDefinition() {
|
||||
// Discussing
|
||||
}
|
||||
}
|
||||
|
||||
open class IrSourceInfoGenTest : SourceInfoGenTest() {
|
||||
override val backend: TargetBackend
|
||||
get() = JVM_IR
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.codegen.ir
|
||||
|
||||
import org.jetbrains.kotlin.codegen.CodegenTestFiles
|
||||
import org.jetbrains.kotlin.codegen.CustomBytecodeTextTest
|
||||
import org.jetbrains.kotlin.test.ConfigurationKind
|
||||
import org.jetbrains.kotlin.test.TargetBackend
|
||||
|
||||
open class IrCustomBytecodeTextTest : CustomBytecodeTextTest() {
|
||||
override val backend: TargetBackend
|
||||
get() = TargetBackend.JVM_IR
|
||||
|
||||
override fun testEnumMapping() {
|
||||
createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.ALL)
|
||||
myFiles = CodegenTestFiles.create(
|
||||
"whenMappingOrder.kt",
|
||||
"""
|
||||
enum class MyEnum {
|
||||
ENTRY1, ENTRY2, ENTRY3, ENTRY4
|
||||
}
|
||||
|
||||
fun f(e: MyEnum) {
|
||||
when (e) {
|
||||
MyEnum.ENTRY4 -> {}
|
||||
MyEnum.ENTRY3 -> {}
|
||||
MyEnum.ENTRY2 -> {}
|
||||
MyEnum.ENTRY1 -> {}
|
||||
}
|
||||
}
|
||||
""",
|
||||
myEnvironment.project
|
||||
)
|
||||
|
||||
val text = generateToText()
|
||||
val getstatics = text.lines().filter { it.contains("GETSTATIC MyEnum.") }.map { it.trim() }
|
||||
assertOrderedEquals(
|
||||
"actual bytecode:\n$text",
|
||||
getstatics,
|
||||
listOf(
|
||||
"GETSTATIC MyEnum.${'$'}VALUES : [LMyEnum;",
|
||||
"GETSTATIC MyEnum.${'$'}ENTRIES : Lkotlin/enums/EnumEntries;",
|
||||
"GETSTATIC MyEnum.ENTRY1 : LMyEnum;",
|
||||
"GETSTATIC MyEnum.ENTRY2 : LMyEnum;",
|
||||
"GETSTATIC MyEnum.ENTRY3 : LMyEnum;",
|
||||
"GETSTATIC MyEnum.ENTRY4 : LMyEnum;",
|
||||
"GETSTATIC MyEnum.${'$'}VALUES : [LMyEnum;",
|
||||
"GETSTATIC MyEnum.ENTRY4 : LMyEnum;",
|
||||
"GETSTATIC MyEnum.ENTRY3 : LMyEnum;",
|
||||
"GETSTATIC MyEnum.ENTRY2 : LMyEnum;",
|
||||
"GETSTATIC MyEnum.ENTRY1 : LMyEnum;"
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -6,17 +6,14 @@
|
||||
package org.jetbrains.kotlin.codegen.ir;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.codegen.AbstractGenerateNotNullAssertionsTest;
|
||||
import org.jetbrains.kotlin.codegen.GenerateNotNullAssertionsTest;
|
||||
import org.jetbrains.kotlin.test.TargetBackend;
|
||||
|
||||
public class IrGenerateNotNullAssertionsTest extends AbstractGenerateNotNullAssertionsTest {
|
||||
public void testNoAssertionsForKotlinFromBinary() {
|
||||
doTestNoAssertionsForKotlinFromBinary("noAssertionsForKotlin.kt", "noAssertionsForKotlinMain.kt");
|
||||
}
|
||||
|
||||
@SuppressWarnings("JUnitTestCaseWithNoTests")
|
||||
public class IrGenerateNotNullAssertionsTest extends GenerateNotNullAssertionsTest {
|
||||
@NotNull
|
||||
@Override
|
||||
protected TargetBackend getBackend() {
|
||||
public TargetBackend getBackend() {
|
||||
return TargetBackend.JVM_IR;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.test.ConfigurationKind
|
||||
import org.jetbrains.kotlin.test.TargetBackend
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
|
||||
class JvmIrLinkageModeTest : CodegenTestCase() {
|
||||
open class JvmIrLinkageModeTest : CodegenTestCase() {
|
||||
override val backend: TargetBackend
|
||||
get() = TargetBackend.JVM_IR
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.jvm.compiler.fir
|
||||
|
||||
import org.jetbrains.kotlin.jvm.compiler.ir.IrJvmIrLinkageModeTest
|
||||
import org.jetbrains.kotlin.test.FirParser
|
||||
|
||||
@Suppress("JUnitTestCaseWithNoTests")
|
||||
class FirPsiJvmIrLinkageModeTest : IrJvmIrLinkageModeTest() {
|
||||
override val useFir: Boolean
|
||||
get() = true
|
||||
|
||||
override val firParser: FirParser
|
||||
get() = FirParser.Psi
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.jvm.compiler.ir
|
||||
|
||||
import org.jetbrains.kotlin.jvm.compiler.JvmIrLinkageModeTest
|
||||
import org.jetbrains.kotlin.test.TargetBackend
|
||||
|
||||
@Suppress("JUnitTestCaseWithNoTests")
|
||||
open class IrJvmIrLinkageModeTest : JvmIrLinkageModeTest() {
|
||||
override val backend: TargetBackend
|
||||
get() = TargetBackend.JVM_IR
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.serialization
|
||||
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
||||
import org.jetbrains.kotlin.config.*
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.jvm.compiler.LoadDescriptorUtil
|
||||
import org.jetbrains.kotlin.resolve.lazy.JvmResolveUtil
|
||||
import org.jetbrains.kotlin.test.ConfigurationKind
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.jetbrains.kotlin.test.TestJdkKind
|
||||
import org.jetbrains.kotlin.test.testFramework.FrontendBackendConfiguration
|
||||
import java.io.File
|
||||
|
||||
abstract class AbstractJvmVersionRequirementTest : AbstractVersionRequirementTest(), FrontendBackendConfiguration {
|
||||
override fun compileFiles(
|
||||
files: List<File>,
|
||||
outputDirectory: File,
|
||||
languageVersion: LanguageVersion,
|
||||
analysisFlags: Map<AnalysisFlag<*>, Any?>,
|
||||
specificFeatures: Map<LanguageFeature, LanguageFeature.State>,
|
||||
) {
|
||||
LoadDescriptorUtil.compileKotlinToDirAndGetModule(
|
||||
listOf(File("compiler/testData/versionRequirement/${getTestName(true)}.kt")), outputDirectory,
|
||||
KotlinCoreEnvironment.createForTests(
|
||||
testRootDisposable,
|
||||
KotlinTestUtils.newConfiguration(ConfigurationKind.ALL, TestJdkKind.MOCK_JDK, outputDirectory).apply {
|
||||
languageVersionSettings = LanguageVersionSettingsImpl(
|
||||
languageVersion,
|
||||
ApiVersion.createByLanguageVersion(languageVersion),
|
||||
analysisFlags.toMap() + mapOf(AnalysisFlags.explicitApiVersion to true),
|
||||
specificFeatures
|
||||
)
|
||||
}.also {
|
||||
configureIrFir(it)
|
||||
},
|
||||
EnvironmentConfigFiles.JVM_CONFIG_FILES
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun loadModule(directory: File): ModuleDescriptor = JvmResolveUtil.analyze(
|
||||
KotlinCoreEnvironment.createForTests(
|
||||
testRootDisposable,
|
||||
KotlinTestUtils.newConfiguration(ConfigurationKind.ALL, TestJdkKind.MOCK_JDK, tmpdir).also {
|
||||
configureIrFir(it)
|
||||
},
|
||||
EnvironmentConfigFiles.JVM_CONFIG_FILES
|
||||
)
|
||||
).moduleDescriptor
|
||||
}
|
||||
@@ -1,146 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.serialization
|
||||
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
||||
import org.jetbrains.kotlin.config.*
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.jvm.compiler.LoadDescriptorUtil
|
||||
import org.jetbrains.kotlin.metadata.ProtoBuf.VersionRequirement.VersionKind.LANGUAGE_VERSION
|
||||
import org.jetbrains.kotlin.metadata.ProtoBuf.VersionRequirement.VersionKind.COMPILER_VERSION
|
||||
import org.jetbrains.kotlin.metadata.deserialization.VersionRequirement
|
||||
import org.jetbrains.kotlin.resolve.lazy.JvmResolveUtil
|
||||
import org.jetbrains.kotlin.test.ConfigurationKind
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.jetbrains.kotlin.test.TestJdkKind
|
||||
import java.io.File
|
||||
|
||||
class JvmVersionRequirementTest : AbstractVersionRequirementTest() {
|
||||
override fun compileFiles(
|
||||
files: List<File>,
|
||||
outputDirectory: File,
|
||||
languageVersion: LanguageVersion,
|
||||
analysisFlags: Map<AnalysisFlag<*>, Any?>,
|
||||
specificFeatures: Map<LanguageFeature, LanguageFeature.State>
|
||||
) {
|
||||
LoadDescriptorUtil.compileKotlinToDirAndGetModule(
|
||||
listOf(File("compiler/testData/versionRequirement/${getTestName(true)}.kt")), outputDirectory,
|
||||
KotlinCoreEnvironment.createForTests(
|
||||
testRootDisposable,
|
||||
KotlinTestUtils.newConfiguration(ConfigurationKind.ALL, TestJdkKind.MOCK_JDK, outputDirectory).apply {
|
||||
languageVersionSettings = LanguageVersionSettingsImpl(
|
||||
languageVersion,
|
||||
ApiVersion.createByLanguageVersion(languageVersion),
|
||||
analysisFlags.toMap() + mapOf(AnalysisFlags.explicitApiVersion to true),
|
||||
specificFeatures
|
||||
)
|
||||
},
|
||||
EnvironmentConfigFiles.JVM_CONFIG_FILES
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun loadModule(directory: File): ModuleDescriptor = JvmResolveUtil.analyze(
|
||||
KotlinCoreEnvironment.createForTests(
|
||||
testRootDisposable,
|
||||
KotlinTestUtils.newConfiguration(ConfigurationKind.ALL, TestJdkKind.MOCK_JDK, tmpdir),
|
||||
EnvironmentConfigFiles.JVM_CONFIG_FILES
|
||||
)
|
||||
).moduleDescriptor
|
||||
|
||||
fun testAllJvmDefault() {
|
||||
doTest(
|
||||
VersionRequirement.Version(1, 4, 0), DeprecationLevel.ERROR, null, COMPILER_VERSION, null,
|
||||
analysisFlags = mapOf(JvmAnalysisFlags.jvmDefaultMode to JvmDefaultMode.ALL),
|
||||
fqNamesWithRequirements = listOf(
|
||||
"test.Base",
|
||||
"test.Derived",
|
||||
"test.BaseWithProperty",
|
||||
"test.DerivedWithProperty",
|
||||
"test.Empty",
|
||||
"test.EmptyWithNested",
|
||||
"test.WithAbstractDeclaration",
|
||||
"test.DerivedFromWithAbstractDeclaration"
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
fun testAllCompatibilityJvmDefault() {
|
||||
doTest(
|
||||
VersionRequirement.Version(1, 4, 0), DeprecationLevel.ERROR, null, COMPILER_VERSION, null,
|
||||
analysisFlags = mapOf(JvmAnalysisFlags.jvmDefaultMode to JvmDefaultMode.ALL_COMPATIBILITY),
|
||||
fqNamesWithRequirements = emptyList(),
|
||||
fqNamesWithoutRequirement = listOf(
|
||||
"test.Base",
|
||||
"test.Derived",
|
||||
"test.BaseWithProperty",
|
||||
"test.DerivedWithProperty",
|
||||
"test.Empty",
|
||||
"test.EmptyWithNested",
|
||||
"test.WithAbstractDeclaration",
|
||||
"test.DerivedFromWithAbstractDeclaration"
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
fun testInlineParameterNullCheck() {
|
||||
doTest(
|
||||
VersionRequirement.Version(1, 3, 50), DeprecationLevel.ERROR, null, COMPILER_VERSION, null,
|
||||
fqNamesWithRequirements = listOf(
|
||||
"test.doRun",
|
||||
"test.lambdaVarProperty",
|
||||
"test.extensionProperty"
|
||||
),
|
||||
customLanguageVersion = LanguageVersion.KOTLIN_1_4
|
||||
)
|
||||
}
|
||||
|
||||
fun testInlineClassReturnTypeMangled() {
|
||||
// Class members returning inline class values are mangled,
|
||||
// and have "language >= 1.4" and "compiler >= 1.4.30" version requirements.
|
||||
doTest(
|
||||
VersionRequirement.Version(1, 4, 0), DeprecationLevel.ERROR, null, LANGUAGE_VERSION, null,
|
||||
fqNamesWithRequirements = listOf(
|
||||
"test.C.returnsInlineClassType",
|
||||
"test.C.propertyOfInlineClassType"
|
||||
),
|
||||
customLanguageVersion = LanguageVersion.KOTLIN_1_4,
|
||||
shouldBeSingleRequirement = false
|
||||
)
|
||||
doTest(
|
||||
VersionRequirement.Version(1, 4, 30), DeprecationLevel.ERROR, null, COMPILER_VERSION, null,
|
||||
fqNamesWithRequirements = listOf(
|
||||
"test.C.returnsInlineClassType",
|
||||
"test.C.propertyOfInlineClassType",
|
||||
),
|
||||
customLanguageVersion = LanguageVersion.KOTLIN_1_4,
|
||||
shouldBeSingleRequirement = false,
|
||||
)
|
||||
}
|
||||
|
||||
fun testInlineClassesAndRelevantDeclarations1430() {
|
||||
doTest(
|
||||
VersionRequirement.Version(1, 4, 30), DeprecationLevel.ERROR, null, COMPILER_VERSION, null,
|
||||
fqNamesWithRequirements = listOf(
|
||||
"test.simpleFun",
|
||||
"test.aliasedFun",
|
||||
),
|
||||
shouldBeSingleRequirement = false
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.serialization
|
||||
|
||||
import org.jetbrains.kotlin.config.JvmAnalysisFlags
|
||||
import org.jetbrains.kotlin.config.JvmDefaultMode
|
||||
import org.jetbrains.kotlin.config.LanguageVersion
|
||||
import org.jetbrains.kotlin.metadata.ProtoBuf
|
||||
import org.jetbrains.kotlin.metadata.deserialization.VersionRequirement
|
||||
|
||||
class K1JvmVersionRequirementTest : AbstractJvmVersionRequirementTest() {
|
||||
fun testAllJvmDefault() {
|
||||
doTest(
|
||||
VersionRequirement.Version(1, 4, 0), DeprecationLevel.ERROR, null,
|
||||
ProtoBuf.VersionRequirement.VersionKind.COMPILER_VERSION, null,
|
||||
analysisFlags = mapOf(JvmAnalysisFlags.jvmDefaultMode to JvmDefaultMode.ALL),
|
||||
fqNamesWithRequirements = listOf(
|
||||
"test.Base",
|
||||
"test.Derived",
|
||||
"test.BaseWithProperty",
|
||||
"test.DerivedWithProperty",
|
||||
"test.Empty",
|
||||
"test.EmptyWithNested",
|
||||
"test.WithAbstractDeclaration",
|
||||
"test.DerivedFromWithAbstractDeclaration"
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
fun testAllCompatibilityJvmDefault() {
|
||||
doTest(
|
||||
VersionRequirement.Version(1, 4, 0), DeprecationLevel.ERROR, null,
|
||||
ProtoBuf.VersionRequirement.VersionKind.COMPILER_VERSION, null,
|
||||
analysisFlags = mapOf(JvmAnalysisFlags.jvmDefaultMode to JvmDefaultMode.ALL_COMPATIBILITY),
|
||||
fqNamesWithRequirements = emptyList(),
|
||||
fqNamesWithoutRequirement = listOf(
|
||||
"test.Base",
|
||||
"test.Derived",
|
||||
"test.BaseWithProperty",
|
||||
"test.DerivedWithProperty",
|
||||
"test.Empty",
|
||||
"test.EmptyWithNested",
|
||||
"test.WithAbstractDeclaration",
|
||||
"test.DerivedFromWithAbstractDeclaration"
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
fun testInlineParameterNullCheck() {
|
||||
doTest(
|
||||
VersionRequirement.Version(1, 3, 50), DeprecationLevel.ERROR, null,
|
||||
ProtoBuf.VersionRequirement.VersionKind.COMPILER_VERSION, null,
|
||||
fqNamesWithRequirements = listOf(
|
||||
"test.doRun",
|
||||
"test.lambdaVarProperty",
|
||||
"test.extensionProperty"
|
||||
),
|
||||
customLanguageVersion = LanguageVersion.KOTLIN_1_4
|
||||
)
|
||||
}
|
||||
|
||||
fun testInlineClassReturnTypeMangled() {
|
||||
// Class members returning inline class values are mangled,
|
||||
// and have "language >= 1.4" and "compiler >= 1.4.30" version requirements.
|
||||
doTest(
|
||||
VersionRequirement.Version(1, 4, 0), DeprecationLevel.ERROR, null,
|
||||
ProtoBuf.VersionRequirement.VersionKind.LANGUAGE_VERSION, null,
|
||||
fqNamesWithRequirements = listOf(
|
||||
"test.C.returnsInlineClassType",
|
||||
"test.C.propertyOfInlineClassType"
|
||||
),
|
||||
customLanguageVersion = LanguageVersion.KOTLIN_1_4,
|
||||
shouldBeSingleRequirement = false
|
||||
)
|
||||
doTest(
|
||||
VersionRequirement.Version(1, 4, 30), DeprecationLevel.ERROR, null,
|
||||
ProtoBuf.VersionRequirement.VersionKind.COMPILER_VERSION, null,
|
||||
fqNamesWithRequirements = listOf(
|
||||
"test.C.returnsInlineClassType",
|
||||
"test.C.propertyOfInlineClassType",
|
||||
),
|
||||
customLanguageVersion = LanguageVersion.KOTLIN_1_4,
|
||||
shouldBeSingleRequirement = false,
|
||||
)
|
||||
}
|
||||
|
||||
fun testInlineClassesAndRelevantDeclarations1430() {
|
||||
doTest(
|
||||
VersionRequirement.Version(1, 4, 30), DeprecationLevel.ERROR, null,
|
||||
ProtoBuf.VersionRequirement.VersionKind.COMPILER_VERSION, null,
|
||||
fqNamesWithRequirements = listOf(
|
||||
"test.simpleFun",
|
||||
"test.aliasedFun",
|
||||
),
|
||||
shouldBeSingleRequirement = false
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.serialization
|
||||
|
||||
import org.jetbrains.kotlin.test.TargetBackend
|
||||
|
||||
@Suppress("JUnitTestCaseWithNoTests")
|
||||
class K2JvmVersionRequirementTest : AbstractJvmVersionRequirementTest() {
|
||||
override val useFir: Boolean
|
||||
get() = true
|
||||
|
||||
override val backend: TargetBackend
|
||||
get() = TargetBackend.JVM_IR
|
||||
}
|
||||
Reference in New Issue
Block a user