[K/N][Tests] Migrate kt48816 tests
^KT-61259
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
// TARGET_BACKEND: NATIVE
|
||||
// DISABLE_NATIVE: isAppleTarget=false
|
||||
// Without a fix, fails in two-stage mode.
|
||||
// The bug was accidentally fixed with lazy IR for caches, so testing it with this feature disabled:
|
||||
// FREE_COMPILER_ARGS: -Xlazy-ir-for-caches=disable
|
||||
|
||||
// MODULE: cinterop
|
||||
// FILE: objclib.def
|
||||
language = Objective-C
|
||||
headers = objclib.h
|
||||
headerFilter = objclib.h **/NSObject.h **/NSDate.h **/NSUUID.h
|
||||
|
||||
// FILE: objclib.h
|
||||
#import <Foundation/NSObject.h>
|
||||
#import <Foundation/NSDate.h>
|
||||
#import <Foundation/NSUUID.h>
|
||||
|
||||
@interface MyClass1 : NSObject
|
||||
@end
|
||||
|
||||
@interface MyClass2 : NSObject
|
||||
@end
|
||||
|
||||
// MODULE: main(cinterop)
|
||||
// FILE: main.kt
|
||||
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||
import kotlin.reflect.*
|
||||
import kotlin.test.*
|
||||
import objclib.*
|
||||
|
||||
// https://youtrack.jetbrains.com/issue/KT-48816
|
||||
open class Base<Ref> {
|
||||
operator fun KProperty1<Ref, NSUUID>.getValue(ref: Base<Ref>, property: KProperty<*>): NSUUID? {
|
||||
return null
|
||||
}
|
||||
operator fun KProperty1<Ref, NSDate>.getValue(ref: Base<Ref>, property: KProperty<*>): NSDate? {
|
||||
return null
|
||||
}
|
||||
}
|
||||
class Usage: Base<B>()
|
||||
class B
|
||||
|
||||
// The compilation should fail with the above;
|
||||
// but anyway try to actually use the code, just to ensure it doesn't get DCEd:
|
||||
|
||||
val B.uuid: NSUUID get() = fail()
|
||||
val B.date: NSDate get() = fail()
|
||||
|
||||
fun test1() {
|
||||
val uuidProperty = B::uuid
|
||||
val dateProperty = B::date
|
||||
val usage = Usage()
|
||||
with(usage) {
|
||||
assertNull(uuidProperty.getValue(usage, uuidProperty))
|
||||
assertNull(dateProperty.getValue(usage, dateProperty))
|
||||
}
|
||||
}
|
||||
|
||||
// One more reproducer, just in case:
|
||||
class Property<out R>
|
||||
|
||||
open class Base2 {
|
||||
fun getValue(property: Property<MyClass1>) = null
|
||||
fun getValue(property: Property<MyClass2>) = null
|
||||
}
|
||||
class Usage2 : Base2()
|
||||
|
||||
fun test2() {
|
||||
val usage = Usage2()
|
||||
assertNull(usage.getValue(Property<MyClass1>()))
|
||||
assertNull(usage.getValue(Property<MyClass2>()))
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
test1()
|
||||
test2()
|
||||
return "OK"
|
||||
}
|
||||
+27
-1
@@ -1,3 +1,28 @@
|
||||
// TARGET_BACKEND: NATIVE
|
||||
// DISABLE_NATIVE: isAppleTarget=false
|
||||
// The bug was accidentally fixed with lazy IR for caches, so testing it with this feature enabled, and disabled(in other test file):
|
||||
// FREE_COMPILER_ARGS: -Xlazy-ir-for-caches=enable
|
||||
|
||||
// MODULE: cinterop
|
||||
// FILE: objclib.def
|
||||
language = Objective-C
|
||||
headers = objclib.h
|
||||
headerFilter = objclib.h **/NSObject.h **/NSDate.h **/NSUUID.h
|
||||
|
||||
// FILE: objclib.h
|
||||
#import <Foundation/NSObject.h>
|
||||
#import <Foundation/NSDate.h>
|
||||
#import <Foundation/NSUUID.h>
|
||||
|
||||
@interface MyClass1 : NSObject
|
||||
@end
|
||||
|
||||
@interface MyClass2 : NSObject
|
||||
@end
|
||||
|
||||
// MODULE: main(cinterop)
|
||||
// FILE: main.kt
|
||||
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||
import kotlin.reflect.*
|
||||
import kotlin.test.*
|
||||
import objclib.*
|
||||
@@ -45,7 +70,8 @@ fun test2() {
|
||||
assertNull(usage.getValue(Property<MyClass2>()))
|
||||
}
|
||||
|
||||
fun main() {
|
||||
fun box(): String {
|
||||
test1()
|
||||
test2()
|
||||
return "OK"
|
||||
}
|
||||
@@ -4,7 +4,6 @@
|
||||
*/
|
||||
// TARGET_BACKEND: NATIVE
|
||||
// NATIVE_STANDALONE
|
||||
// FREE_COMPILER_ARGS: -opt-in=kotlin.native.internal.InternalForKotlinNative
|
||||
// MODULE: cinterop
|
||||
// FILE: threadStates.def
|
||||
language = C
|
||||
|
||||
-1
@@ -4,7 +4,6 @@
|
||||
*/
|
||||
// TARGET_BACKEND: NATIVE
|
||||
// NATIVE_STANDALONE
|
||||
// FREE_COMPILER_ARGS: -opt-in=kotlin.native.internal.InternalForKotlinNative
|
||||
// MODULE: cinterop
|
||||
// FILE: threadStates.def
|
||||
language = C
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
*/
|
||||
// TARGET_BACKEND: NATIVE
|
||||
// NATIVE_STANDALONE
|
||||
// FREE_COMPILER_ARGS: -opt-in=kotlin.native.internal.InternalForKotlinNative
|
||||
// MODULE: cinterop
|
||||
// FILE: threadStates.def
|
||||
language = C
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
*/
|
||||
// TARGET_BACKEND: NATIVE
|
||||
// NATIVE_STANDALONE
|
||||
// FREE_COMPILER_ARGS: -opt-in=kotlin.native.internal.InternalForKotlinNative
|
||||
// MODULE: cinterop
|
||||
// FILE: threadStates.def
|
||||
language = C
|
||||
|
||||
-1
@@ -4,7 +4,6 @@
|
||||
*/
|
||||
// TARGET_BACKEND: NATIVE
|
||||
// NATIVE_STANDALONE
|
||||
// FREE_COMPILER_ARGS: -opt-in=kotlin.native.internal.InternalForKotlinNative
|
||||
// MODULE: cinterop
|
||||
// FILE: threadStates.def
|
||||
language = C
|
||||
|
||||
-1
@@ -4,7 +4,6 @@
|
||||
*/
|
||||
// TARGET_BACKEND: NATIVE
|
||||
// NATIVE_STANDALONE
|
||||
// FREE_COMPILER_ARGS: -opt-in=kotlin.native.internal.InternalForKotlinNative
|
||||
@file:OptIn(kotlin.native.runtime.NativeRuntimeApi::class, kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||
|
||||
import kotlin.native.runtime.Debugging
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
*/
|
||||
// TARGET_BACKEND: NATIVE
|
||||
// NATIVE_STANDALONE
|
||||
// FREE_COMPILER_ARGS: -opt-in=kotlin.native.internal.InternalForKotlinNative
|
||||
// MODULE: cinterop
|
||||
// FILE: threadStates.def
|
||||
language = C
|
||||
|
||||
-1
@@ -4,7 +4,6 @@
|
||||
*/
|
||||
// TARGET_BACKEND: NATIVE
|
||||
// NATIVE_STANDALONE
|
||||
// FREE_COMPILER_ARGS: -opt-in=kotlin.native.internal.InternalForKotlinNative
|
||||
// MODULE: cinterop
|
||||
// FILE: threadStates.def
|
||||
language = C
|
||||
|
||||
-1
@@ -4,7 +4,6 @@
|
||||
*/
|
||||
// TARGET_BACKEND: NATIVE
|
||||
// NATIVE_STANDALONE
|
||||
// FREE_COMPILER_ARGS: -opt-in=kotlin.native.internal.InternalForKotlinNative
|
||||
// MODULE: cinterop
|
||||
// FILE: threadStates.def
|
||||
language = C
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
*/
|
||||
// TARGET_BACKEND: NATIVE
|
||||
// NATIVE_STANDALONE
|
||||
// FREE_COMPILER_ARGS: -opt-in=kotlin.native.internal.InternalForKotlinNative
|
||||
// MODULE: cinterop
|
||||
// FILE: threadStates.def
|
||||
language = C
|
||||
|
||||
@@ -1176,10 +1176,6 @@ if (PlatformInfo.isAppleTarget(project)) {
|
||||
it.defFile 'interop/objc/kt42172/objclib.def'
|
||||
it.headers "$projectDir/interop/objc/kt42172/objclib.h"
|
||||
}
|
||||
createInterop("objc_kt48816") {
|
||||
it.defFile 'interop/objc/kt48816/objclib.def'
|
||||
it.headers "$projectDir/interop/objc/kt48816/objclib.h"
|
||||
}
|
||||
createInterop("objc_kt55938") {
|
||||
it.defFile 'interop/objc/kt55938/objclib.def'
|
||||
it.headers "$projectDir/interop/objc/kt55938/objclib.h"
|
||||
@@ -1648,21 +1644,6 @@ if (PlatformInfo.isAppleTarget(project)) {
|
||||
UtilsKt.codesign(project, dylibFile.toString())
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
interopTest("interop_objc_kt48816_without_lazy_ir_for_caches") {
|
||||
// Without a fix, fails in two-stage mode.
|
||||
source = "interop/objc/kt48816/main.kt"
|
||||
interop = "objc_kt48816"
|
||||
// The bug was accidentally fixed with lazy IR for caches, so testing it with this feature disabled:
|
||||
flags = ["-Xlazy-ir-for-caches=disable"]
|
||||
}
|
||||
|
||||
interopTest("interop_objc_kt48816_with_lazy_ir_for_caches") {
|
||||
source = "interop/objc/kt48816/main.kt"
|
||||
interop = "objc_kt48816"
|
||||
flags = ["-Xlazy-ir-for-caches=enable"]
|
||||
}
|
||||
|
||||
interopTest("interop_objc_kt55938") {
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
language = Objective-C
|
||||
headerFilter = **/objclib.h **/NSObject.h **/NSDate.h **/NSUUID.h
|
||||
@@ -1,9 +0,0 @@
|
||||
#import <Foundation/NSObject.h>
|
||||
#import <Foundation/NSDate.h>
|
||||
#import <Foundation/NSUUID.h>
|
||||
|
||||
@interface MyClass1 : NSObject
|
||||
@end
|
||||
|
||||
@interface MyClass2 : NSObject
|
||||
@end
|
||||
+12
@@ -5074,6 +5074,18 @@ public class FirNativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTe
|
||||
runTest("compiler/testData/codegen/box/cinterop/objc/kt34467.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt48816_lazy_ir_disable.kt")
|
||||
public void testKt48816_lazy_ir_disable() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/cinterop/objc/kt48816_lazy_ir_disable.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt48816_lazy_ir_enable.kt")
|
||||
public void testKt48816_lazy_ir_enable() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/cinterop/objc/kt48816_lazy_ir_enable.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt53151.kt")
|
||||
public void testKt53151() throws Exception {
|
||||
|
||||
+12
@@ -5190,6 +5190,18 @@ public class FirNativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenB
|
||||
runTest("compiler/testData/codegen/box/cinterop/objc/kt34467.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt48816_lazy_ir_disable.kt")
|
||||
public void testKt48816_lazy_ir_disable() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/cinterop/objc/kt48816_lazy_ir_disable.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt48816_lazy_ir_enable.kt")
|
||||
public void testKt48816_lazy_ir_enable() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/cinterop/objc/kt48816_lazy_ir_enable.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt53151.kt")
|
||||
public void testKt53151() throws Exception {
|
||||
|
||||
+12
@@ -4958,6 +4958,18 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest
|
||||
runTest("compiler/testData/codegen/box/cinterop/objc/kt34467.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt48816_lazy_ir_disable.kt")
|
||||
public void testKt48816_lazy_ir_disable() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/cinterop/objc/kt48816_lazy_ir_disable.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt48816_lazy_ir_enable.kt")
|
||||
public void testKt48816_lazy_ir_enable() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/cinterop/objc/kt48816_lazy_ir_enable.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt53151.kt")
|
||||
public void testKt53151() throws Exception {
|
||||
|
||||
+12
@@ -5075,6 +5075,18 @@ public class NativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenBoxT
|
||||
runTest("compiler/testData/codegen/box/cinterop/objc/kt34467.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt48816_lazy_ir_disable.kt")
|
||||
public void testKt48816_lazy_ir_disable() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/cinterop/objc/kt48816_lazy_ir_disable.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt48816_lazy_ir_enable.kt")
|
||||
public void testKt48816_lazy_ir_enable() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/cinterop/objc/kt48816_lazy_ir_enable.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt53151.kt")
|
||||
public void testKt53151() throws Exception {
|
||||
|
||||
+2
@@ -29,6 +29,7 @@ import org.jetbrains.kotlin.konan.test.blackbox.support.TestDirectives.DISABLE_N
|
||||
import org.jetbrains.kotlin.konan.test.blackbox.support.TestDirectives.DISABLE_NATIVE_K2
|
||||
import org.jetbrains.kotlin.konan.test.blackbox.support.TestDirectives.FILECHECK_STAGE
|
||||
import org.jetbrains.kotlin.konan.test.blackbox.support.TestDirectives.FREE_CINTEROP_ARGS
|
||||
import org.jetbrains.kotlin.konan.test.blackbox.support.TestDirectives.FREE_COMPILER_ARGS
|
||||
import org.jetbrains.kotlin.konan.test.blackbox.support.TestDirectives.IGNORE_NATIVE
|
||||
import org.jetbrains.kotlin.konan.test.blackbox.support.TestDirectives.IGNORE_NATIVE_K1
|
||||
import org.jetbrains.kotlin.konan.test.blackbox.support.TestDirectives.IGNORE_NATIVE_K2
|
||||
@@ -171,6 +172,7 @@ private class ExtTestDataFile(
|
||||
|
||||
private fun assembleFreeCompilerArgs(): TestCompilerArgs {
|
||||
val args = mutableListOf<String>()
|
||||
structure.directives.listValues(FREE_COMPILER_ARGS.name)?.let { args.addAll(it)}
|
||||
testDataFileSettings.languageSettings.sorted().mapTo(args) { "-XXLanguage:$it" }
|
||||
testDataFileSettings.optInsForCompiler.sorted().mapTo(args) { "-opt-in=$it" }
|
||||
args += "-opt-in=kotlin.native.internal.InternalForKotlinNative" // for `Any.isPermanent()` and `Any.isLocal()`
|
||||
|
||||
Reference in New Issue
Block a user