Skip to content
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

Only generate @kotlin.ExperimentalUnsigned annotation on create*Vector methods having an unsigned array type parameter. #7881

Merged
merged 7 commits into from Apr 28, 2023

Conversation

aaronriekenberg
Copy link
Contributor

@aaronriekenberg aaronriekenberg commented Mar 24, 2023

Fixes #7862

From this reference: https://kotlinlang.org/docs/unsigned-integer-types.html

In Kotlin unsigned integer types are stable (UByte/UShort/UInt/ULong) and unsigned array types are experimental (UByteArray/UShortArray/UIntArray/ULongArray).

This PR makes these changes:

  1. Remove @kotlin.ExperimentalUnsignedTypes generation from enumerations. Even if enum has an unsigned integral type, I do not think it is possible for the enum class generated to contain an unsigned array type. See for example: tests/MyGame/Example/Color.kt

  2. Remove @kotlin.ExperimentalUnsignedTypes from other class generations.

  3. Add @kotlin.ExperimentalUnsignedTypes to method generation for create*Vector methods only where the data parameter type is an unsigned array. See for example tests/MyGame/Example/Monster.kt

I ran scripts/generate_code.py to regenerate test code.

I think this simple change might work to make the @kotlin.ExperimentalUnsignedTypes opt-in so that this annotation is only generated if the user's schema uses unsigned array types to generate kotlin code.

Am I missing things here?

Thanks!

…r methods having an unsigned array type parameter.
@dbaileychess dbaileychess enabled auto-merge (squash) April 28, 2023 17:05
@dbaileychess dbaileychess merged commit 417821f into google:master Apr 28, 2023
45 of 46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ codegen Involving generating code from schema kotlin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Kotlin] Use of ExperimentalUnsignedTypes annotation in generated kotlin code
2 participants