diff --git a/kotlin-native/backend.native/tests/build.gradle b/kotlin-native/backend.native/tests/build.gradle index c0770b348b4..f799c6c1d1c 100644 --- a/kotlin-native/backend.native/tests/build.gradle +++ b/kotlin-native/backend.native/tests/build.gradle @@ -5234,6 +5234,14 @@ if (PlatformInfo.isAppleTarget(project)) { useGoldenData = true UtilsKt.dependsOnPlatformLibs(it) } + + standaloneTest("interop_kt40426") { + // Test depends on iOS-specific UIKit + enabled = (project.testTarget == 'ios_x64' || project.testTarget == 'ios_simulator_arm64' || project.testTarget == 'ios_arm64') + source = "interop/objc/kt40426/main.kt" + useGoldenData = true + UtilsKt.dependsOnPlatformLibs(it) + } } tasks.register("KT-50983", KonanDriverTest) { diff --git a/kotlin-native/backend.native/tests/interop/objc/kt40426/main.kt b/kotlin-native/backend.native/tests/interop/objc/kt40426/main.kt new file mode 100644 index 00000000000..e9ca41a7fc4 --- /dev/null +++ b/kotlin-native/backend.native/tests/interop/objc/kt40426/main.kt @@ -0,0 +1,33 @@ +/* + * Copyright 2010-2023 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. + */ + +import kotlinx.cinterop.* +import platform.UIKit.* +import platform.CoreGraphics.* +import platform.Foundation.NSString + +class SmileView(frame: CValue): UIView(frame = frame) { + override fun drawRect(rect: CValue) { + super.drawRect(rect) + + val smile = ":)" as NSString + smile.drawInRect(rect, withAttributes = null) + println("SmileView::drawRect") + } + + override fun layoutSubviews() { + super.layoutSubviews() + println("SmileView::layoutSubviews") + } +} + +fun main() { + memScoped { + val frame = alloc() + val x = SmileView(frame.readValue()) + x.drawRect(frame.readValue()) + x.layoutSubviews() + } +} \ No newline at end of file diff --git a/kotlin-native/backend.native/tests/interop/objc/kt40426/main.out b/kotlin-native/backend.native/tests/interop/objc/kt40426/main.out new file mode 100644 index 00000000000..54d057726b4 --- /dev/null +++ b/kotlin-native/backend.native/tests/interop/objc/kt40426/main.out @@ -0,0 +1,2 @@ +SmileView::drawRect +SmileView::layoutSubviews