-
Notifications
You must be signed in to change notification settings - Fork 6.1k
[KT-48068] Add opt-in support for NSEnum for Kotlin Native iOS via an annotation #5539
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
base: master
Are you sure you want to change the base?
Conversation
|
/test-private |
|
Failed to process command due to an unexpected exception. |
native/objcexport-header-generator/src/org/jetbrains/kotlin/backend/konan/objcexport/stubs.kt
Outdated
Show resolved
Hide resolved
native/objcexport-header-generator/src/org/jetbrains/kotlin/backend/konan/objcexport/stubs.kt
Outdated
Show resolved
Hide resolved
native/native.tests/testData/framework/objcexport/nativeEnum.kt
Outdated
Show resolved
Hide resolved
kotlin-native/runtime/src/main/kotlin/kotlin/native/Annotations.kt
Outdated
Show resolved
Hide resolved
...-generator/impl/k1/src/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportTranslator.kt
Show resolved
Hide resolved
...-generator/impl/k1/src/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportTranslator.kt
Outdated
Show resolved
Hide resolved
...-generator/impl/k1/src/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportTranslator.kt
Show resolved
Hide resolved
...er/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportCodeSpec.kt
Outdated
Show resolved
Hide resolved
...bjcexport-header-generator/src/org/jetbrains/kotlin/backend/konan/objcexport/StubRenderer.kt
Outdated
Show resolved
Hide resolved
|
The K2 (Analysis API, aka AA) implementation is missing, which makes the new test fail in this mode. ./gradlew :native:objcexport-header-generator:testAnalysisApi --tests "org.jetbrains.kotlin.backend.konan.tests.ObjCExportHeaderGeneratorTest"to reproduce. Related code: Line 54 in f90cbf3
|
|
Another thing to fix: adding a declaration to stdlib requires updating the ABI dump. |
I have added this, but AA emits the a comment about the annotation whereas K1 does not... Any suggestions how to resolve this? Current state is the AA output |
...end.native/src/org/jetbrains/kotlin/backend/konan/llvm/objcexport/ObjCExportCodeGenerator.kt
Outdated
Show resolved
Hide resolved
...end.native/src/org/jetbrains/kotlin/backend/konan/llvm/objcexport/ObjCExportCodeGenerator.kt
Outdated
Show resolved
Hide resolved
...end.native/src/org/jetbrains/kotlin/backend/konan/llvm/objcexport/ObjCExportCodeGenerator.kt
Outdated
Show resolved
Hide resolved
...er/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportCodeSpec.kt
Outdated
Show resolved
Hide resolved
| is ObjCInitMethodForKotlinConstructor -> "$objcClass.${baseMethod.selector},${baseMethod.symbol.signature}" | ||
| is ObjCKotlinThrowableAsErrorMethod -> null | ||
| is ObjCMethodForKotlinMethod -> "$objcClass.${baseMethod.selector},${baseMethod.symbol.signature}" | ||
| is ObjCGetterForNSEnumType -> "$objcClass.$selector,${symbol.signature}" |
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.
Now, that's a bit tricky.
IIRC, the dump generated here is used for some additional DCE: if the Objective-C/Swift code doesn't use certain generated method, using this dump we can find the original Kotlin declaration that doesn't need to be exposed then.
The problem with this implementation is therefore the following: if the generated nsEnum property of a class is not used, the compiler will be instructed to hide Enum.ordinal, which is not exactly intended.
See these changes for more details:
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.
I have changed the return value to null, does this make sense?
Basically implementing the feature suggested here: https://youtrack.jetbrains.com/issue/KT-48068