-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[K/N][Tests] Fix: Crashes when casting to an Obj-C class companion
When generating section `__objc_classrefs`, need to consider distinguishing `_OBJC_CLASS_$_` and `_OBJC_METACLASS_$_` KT-65260
- Loading branch information
Showing
6 changed files
with
51 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
native/native.tests/testData/codegen/cinterop/objc/kt65260.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright 2010-2024 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. | ||
*/ | ||
// TARGET_BACKEND: NATIVE | ||
// DISABLE_NATIVE: isAppleTarget=false | ||
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class) | ||
import platform.Foundation.* | ||
import platform.darwin.* | ||
import kotlin.test.* | ||
|
||
fun box(): String { | ||
try { | ||
// Test: cast to NSObject Metaclass | ||
Any() as NSObject.Companion | ||
// Test: cast to subclass of NSObject Metaclass | ||
Any() as NSString.Companion | ||
Any() as NSArray.Companion | ||
} catch (e: Exception) { | ||
// Cannot access 'TypeCastException': it is internal in Kotlin/Native. | ||
assertTrue(e is ClassCastException) | ||
} | ||
return "OK" | ||
} |
6 changes: 6 additions & 0 deletions
6
...ests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenLocalTestGenerated.java
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
...s/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenLocalTestGenerated.java
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.