f4e8ae5191
* @ExperimentalForeignApi for all declarations that operate on
unmanaged memory (i.e. pointers and references)
* @BetaInteropApi for the rest of the interoperability declarations,
namely Swift/CInterop-specific interfaces and convenience-functions
### Implementation details
* Some typealiases are not marked explicitly because it crashes the compiler,
yet their experimentality is properly propagated
* License header is adjusted where it previously had been existing
* Deprecated with ERROR interop declarations that are deprecated for more than
two years are removed
* WASM target interop declarations are deprecated
* Deliberately make Boolean.toByte and Byte.toBoolean foreign-experimental to scare
people away
^KT-57728 fixed
Merge-request: KT-MR-9788
Merged-by: Vsevolod Tolstopyatov <qwwdfsad@gmail.com>
35 lines
1.2 KiB
Kotlin
35 lines
1.2 KiB
Kotlin
// This test mostly checks frontend behaviour.
|
|
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
|
|
|
import cForwardDeclarations.*
|
|
import cnames.structs.StructDeclared
|
|
|
|
import kotlin.test.assertEquals
|
|
import kotlinx.cinterop.COpaque
|
|
import kotlinx.cinterop.CStructVar
|
|
import kotlinx.cinterop.ptr
|
|
// The test should also check that these references can't be resolved, but the test infra doesn't support this yet:
|
|
// import cForwardDeclarations.StructUndeclared
|
|
// import cnames.structs.StructUndeclared // Supported in K1 though.
|
|
|
|
fun <T1 : T2, T2> checkSubtype2() {}
|
|
|
|
// Here we rely on frontend reporting conflicting overloads if some of these types turn out to be the same.
|
|
fun checkDifferentTypes(s: StructDeclared?) = 1
|
|
fun checkDifferentTypes(s: StructDefined?) = 2
|
|
|
|
fun main() {
|
|
checkSubtype2<StructDeclared, COpaque>()
|
|
|
|
checkSubtype2<StructDefined, CStructVar>()
|
|
|
|
val declared: StructDeclared? = null
|
|
val defined: StructDefined? = null
|
|
|
|
assertEquals(1, checkDifferentTypes(declared))
|
|
assertEquals(2, checkDifferentTypes(defined))
|
|
|
|
assertEquals(-1, useStructDeclared(declared?.ptr))
|
|
assertEquals(-2, useStructDefined(defined?.ptr))
|
|
}
|