[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();")
|
headerFile.writeText("void foo();")
|
||||||
buildAndFail(":compileKotlinLinux") {
|
buildAndFail(":compileKotlinLinux") {
|
||||||
assertTasksExecuted(":cinteropNlibLinux")
|
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);")
|
headerFile.writeText("void sample(int i);")
|
||||||
|
|||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
fun foo() {
|
fun foo() {
|
||||||
|
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||||
nlib.sample(5)
|
nlib.sample(5)
|
||||||
}
|
}
|
||||||
+1
@@ -3,5 +3,6 @@ package pkg
|
|||||||
import dep.*
|
import dep.*
|
||||||
|
|
||||||
class DependencyKotlinClass {
|
class DependencyKotlinClass {
|
||||||
|
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||||
val mode: Dependency = Dependency.GOO
|
val mode: Dependency = Dependency.GOO
|
||||||
}
|
}
|
||||||
|
|||||||
+1
@@ -7,4 +7,5 @@ fun nativeMain() {
|
|||||||
usleep(100u)
|
usleep(100u)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||||
fun nativeMainUsingCInterop() = dummyFunction()
|
fun nativeMainUsingCInterop() = dummyFunction()
|
||||||
|
|||||||
+1
@@ -8,4 +8,5 @@ fun commonMain() {
|
|||||||
usleep(100u)
|
usleep(100u)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||||
fun nativeMainParentUsingCInterop() = dummyFunction()
|
fun nativeMainParentUsingCInterop() = dummyFunction()
|
||||||
|
|||||||
+1
@@ -7,4 +7,5 @@ fun main() {
|
|||||||
usleep(100u)
|
usleep(100u)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||||
fun nativePlatformMainUsingCInterop() = dummyFunction()
|
fun nativePlatformMainUsingCInterop() = dummyFunction()
|
||||||
|
|||||||
+1
@@ -2,4 +2,5 @@
|
|||||||
|
|
||||||
import dummy.dummyFunction
|
import dummy.dummyFunction
|
||||||
|
|
||||||
|
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||||
fun commonMain() = dummyFunction()
|
fun commonMain() = dummyFunction()
|
||||||
|
|||||||
+1
@@ -2,4 +2,5 @@
|
|||||||
|
|
||||||
import dummy.dummyFunction
|
import dummy.dummyFunction
|
||||||
|
|
||||||
|
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||||
fun nativeMain() = dummyFunction()
|
fun nativeMain() = dummyFunction()
|
||||||
|
|||||||
+1
@@ -2,4 +2,5 @@
|
|||||||
|
|
||||||
import dummy.dummyFunction
|
import dummy.dummyFunction
|
||||||
|
|
||||||
|
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||||
fun nativePlatformMain() = dummyFunction()
|
fun nativePlatformMain() = dummyFunction()
|
||||||
|
|||||||
+1
@@ -3,5 +3,6 @@
|
|||||||
import sampleInterop.sampleInterop
|
import sampleInterop.sampleInterop
|
||||||
|
|
||||||
object NativeMain {
|
object NativeMain {
|
||||||
|
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||||
fun x() = sampleInterop()
|
fun x() = sampleInterop()
|
||||||
}
|
}
|
||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
import simple.simpleInteropFunction
|
import simple.simpleInteropFunction
|
||||||
|
|
||||||
|
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||||
fun main() = simpleInteropFunction()
|
fun main() = simpleInteropFunction()
|
||||||
|
|||||||
+1
@@ -1,5 +1,6 @@
|
|||||||
import dummy.foo
|
import dummy.foo
|
||||||
|
|
||||||
fun dummyMain() {
|
fun dummyMain() {
|
||||||
|
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||||
foo()
|
foo()
|
||||||
}
|
}
|
||||||
|
|||||||
+1
@@ -1,5 +1,6 @@
|
|||||||
object CommonMain {
|
object CommonMain {
|
||||||
init {
|
init {
|
||||||
|
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||||
ProducerNativeCommonMain.fromCInterop().value
|
ProducerNativeCommonMain.fromCInterop().value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
@@ -1,5 +1,6 @@
|
|||||||
import `producer-cinterop-library`.ProducerCLibraryStruct
|
import `producer-cinterop-library`.ProducerCLibraryStruct
|
||||||
|
|
||||||
object ProducerNativeCommonMain {
|
object ProducerNativeCommonMain {
|
||||||
|
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||||
fun fromCInterop(): ProducerCLibraryStruct = error("Stub!")
|
fun fromCInterop(): ProducerCLibraryStruct = error("Stub!")
|
||||||
}
|
}
|
||||||
+1
@@ -11,6 +11,7 @@ object ConsumerALinuxX64 {
|
|||||||
ProducerANative
|
ProducerANative
|
||||||
ProducerALinuxX64
|
ProducerALinuxX64
|
||||||
|
|
||||||
|
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||||
myCFunction()
|
myCFunction()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
@@ -6,5 +6,6 @@
|
|||||||
package library.cinterop.project
|
package library.cinterop.project
|
||||||
|
|
||||||
fun projectAnswer(): Int {
|
fun projectAnswer(): Int {
|
||||||
|
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||||
return getAnotherNumber() * 2
|
return getAnotherNumber() * 2
|
||||||
}
|
}
|
||||||
|
|||||||
+1
@@ -6,5 +6,6 @@
|
|||||||
package library.cinterop.project
|
package library.cinterop.project
|
||||||
|
|
||||||
fun publishedAnswer(): Int {
|
fun publishedAnswer(): Int {
|
||||||
|
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||||
return getNumber() * 2
|
return getNumber() * 2
|
||||||
}
|
}
|
||||||
|
|||||||
+1
@@ -12,5 +12,6 @@ fun libraryAnswer(): Int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun selfCalculatedAnswer(): Int {
|
fun selfCalculatedAnswer(): Int {
|
||||||
|
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||||
return getNumber() * 2 + getAnotherNumber() * 2
|
return getNumber() * 2 + getAnotherNumber() * 2
|
||||||
}
|
}
|
||||||
|
|||||||
+1
@@ -10,5 +10,6 @@ import kotlin.test.*
|
|||||||
fun testAnswer() {
|
fun testAnswer() {
|
||||||
assertEquals(12, libraryAnswer())
|
assertEquals(12, libraryAnswer())
|
||||||
assertEquals(12, selfCalculatedAnswer())
|
assertEquals(12, selfCalculatedAnswer())
|
||||||
|
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||||
assertEquals(5, getTestNumber())
|
assertEquals(5, getTestNumber())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user