[Gradle] Add ExperimentalForeignApi opt-ins to integration tests
3f3f6eb marks all cinterop-generated declarations with
@ExperimentalForeignApi. As a result, all usages of such declarations
have to opt-in explicitly. This commit adds those opt-ins to all
usages in the Kotlin Gradle plugin integration tests.
^KT-58362
This commit is contained in:
committed by
Space Team
parent
06d2befb72
commit
ec985b1ffe
+1
-1
@@ -26,7 +26,7 @@ class CinteropIT : KGPBaseTest() {
|
||||
headerFile.writeText("void foo();")
|
||||
buildAndFail(":compileKotlinLinux") {
|
||||
assertTasksExecuted(":cinteropNlibLinux")
|
||||
assertOutputContains("src/linuxMain/kotlin/org/sample/Platform.kt:2:10 Unresolved reference: sample")
|
||||
assertOutputContains("src/linuxMain/kotlin/org/sample/Platform.kt:3:10 Unresolved reference: sample")
|
||||
}
|
||||
|
||||
headerFile.writeText("void sample(int i);")
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
fun foo() {
|
||||
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||
nlib.sample(5)
|
||||
}
|
||||
+1
@@ -3,5 +3,6 @@ package pkg
|
||||
import dep.*
|
||||
|
||||
class DependencyKotlinClass {
|
||||
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||
val mode: Dependency = Dependency.GOO
|
||||
}
|
||||
|
||||
+1
@@ -7,4 +7,5 @@ fun nativeMain() {
|
||||
usleep(100u)
|
||||
}
|
||||
|
||||
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||
fun nativeMainUsingCInterop() = dummyFunction()
|
||||
|
||||
+1
@@ -8,4 +8,5 @@ fun commonMain() {
|
||||
usleep(100u)
|
||||
}
|
||||
|
||||
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||
fun nativeMainParentUsingCInterop() = dummyFunction()
|
||||
|
||||
+1
@@ -7,4 +7,5 @@ fun main() {
|
||||
usleep(100u)
|
||||
}
|
||||
|
||||
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||
fun nativePlatformMainUsingCInterop() = dummyFunction()
|
||||
|
||||
+1
@@ -2,4 +2,5 @@
|
||||
|
||||
import dummy.dummyFunction
|
||||
|
||||
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||
fun commonMain() = dummyFunction()
|
||||
|
||||
+1
@@ -2,4 +2,5 @@
|
||||
|
||||
import dummy.dummyFunction
|
||||
|
||||
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||
fun nativeMain() = dummyFunction()
|
||||
|
||||
+1
@@ -2,4 +2,5 @@
|
||||
|
||||
import dummy.dummyFunction
|
||||
|
||||
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||
fun nativePlatformMain() = dummyFunction()
|
||||
|
||||
+1
@@ -3,5 +3,6 @@
|
||||
import sampleInterop.sampleInterop
|
||||
|
||||
object NativeMain {
|
||||
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||
fun x() = sampleInterop()
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
import simple.simpleInteropFunction
|
||||
|
||||
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||
fun main() = simpleInteropFunction()
|
||||
|
||||
+1
@@ -1,5 +1,6 @@
|
||||
import dummy.foo
|
||||
|
||||
fun dummyMain() {
|
||||
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||
foo()
|
||||
}
|
||||
|
||||
+1
@@ -1,5 +1,6 @@
|
||||
object CommonMain {
|
||||
init {
|
||||
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||
ProducerNativeCommonMain.fromCInterop().value
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -1,5 +1,6 @@
|
||||
import `producer-cinterop-library`.ProducerCLibraryStruct
|
||||
|
||||
object ProducerNativeCommonMain {
|
||||
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||
fun fromCInterop(): ProducerCLibraryStruct = error("Stub!")
|
||||
}
|
||||
+1
@@ -11,6 +11,7 @@ object ConsumerALinuxX64 {
|
||||
ProducerANative
|
||||
ProducerALinuxX64
|
||||
|
||||
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||
myCFunction()
|
||||
}
|
||||
}
|
||||
+1
@@ -6,5 +6,6 @@
|
||||
package library.cinterop.project
|
||||
|
||||
fun projectAnswer(): Int {
|
||||
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||
return getAnotherNumber() * 2
|
||||
}
|
||||
|
||||
+1
@@ -6,5 +6,6 @@
|
||||
package library.cinterop.project
|
||||
|
||||
fun publishedAnswer(): Int {
|
||||
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||
return getNumber() * 2
|
||||
}
|
||||
|
||||
+1
@@ -12,5 +12,6 @@ fun libraryAnswer(): Int {
|
||||
}
|
||||
|
||||
fun selfCalculatedAnswer(): Int {
|
||||
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||
return getNumber() * 2 + getAnotherNumber() * 2
|
||||
}
|
||||
|
||||
+1
@@ -10,5 +10,6 @@ import kotlin.test.*
|
||||
fun testAnswer() {
|
||||
assertEquals(12, libraryAnswer())
|
||||
assertEquals(12, selfCalculatedAnswer())
|
||||
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||
assertEquals(5, getTestNumber())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user