New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[K/N][Tests] Fix crashes when casting to an Obj-C class companion #5270
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add tests covering the change.
compiler/ir/ir.objcinterop/src/org/jetbrains/kotlin/ir/objcinterop/ObjCInterop.kt
Outdated
Show resolved
Hide resolved
8be5416
to
764f903
Compare
compiler/ir/ir.objcinterop/src/org/jetbrains/kotlin/ir/objcinterop/ObjCInterop.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The behavior still doesn't seem entirely right:
NSNumber as NSObject.Companion
such a cast should fail, but it succeeds.
compiler/ir/ir.objcinterop/src/org/jetbrains/kotlin/ir/objcinterop/ObjCInterop.kt
Outdated
Show resolved
Hide resolved
...tive/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/CodeGenerator.kt
Outdated
Show resolved
Hide resolved
abdeced
to
a110cd6
Compare
I have a doubt about this case, corresponding to ObjC. // This result is YES, ObjC class object is instance of meta class.
BOOL result = [NSNumber isKindOfClass:object_getClass(NSObject.class)]; |
Yes, but semantically
open class A {
companion object : AMeta()
}
open class AMeta
open class B : A() {
companion object : BMeta()
}
open class BMeta : AMeta()
fun main() {
val bAny: Any = B
println(bAny is A.Companion)
} It prints |
When generating section `__objc_classrefs`, need to consider distinguishing `_OBJC_CLASS_$_` and `_OBJC_METACLASS_$_` KT-65260
...native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt
Outdated
Show resolved
Hide resolved
...native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt
Outdated
Show resolved
Hide resolved
Use pointer equality for type-checking
^KT-65260