Skip to content

Conversation

@stefanhaustein
Copy link

Basically implementing the feature suggested here: https://youtrack.jetbrains.com/issue/KT-48068

@SvyatoslavScherbina
Copy link
Contributor

/test-private

@kotlin-safe-merge
Copy link

Failed to process command due to an unexpected exception.

@SvyatoslavScherbina
Copy link
Contributor

The K2 (Analysis API, aka AA) implementation is missing, which makes the new test fail in this mode.
Run

./gradlew :native:objcexport-header-generator:testAnalysisApi --tests "org.jetbrains.kotlin.backend.konan.tests.ObjCExportHeaderGeneratorTest"

to reproduce.

Related code:

@SvyatoslavScherbina
Copy link
Contributor

Another thing to fix: adding a declaration to stdlib requires updating the ABI dump.
Run the following command to do that:

./gradlew :tools:binary-compatibility-validator:cleanTest :tools:binary-compatibility-validator:test --tests "*" -Poverwrite.output=true

@stefanhaustein stefanhaustein changed the title Add opt-in support for NSEnum for Kotlin Native iOS via an annotation [KT-48068] Add opt-in support for NSEnum for Kotlin Native iOS via an annotation Nov 4, 2025
@stefanhaustein stefanhaustein requested a review from a team as a code owner November 4, 2025 13:21
@stefanhaustein
Copy link
Author

The K2 (Analysis API, aka AA) implementation is missing, which makes the new test fail in this mode. Run

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

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}"
Copy link
Contributor

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:

Copy link
Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants