Skip to content

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

Merged
dbaileychess merged 7 commits intogoogle:masterfrom
aaronriekenberg:master
Apr 28, 2023
Merged

Only generate @kotlin.ExperimentalUnsigned annotation on create*Vector methods having an unsigned array type parameter.#7881
dbaileychess merged 7 commits intogoogle:masterfrom
aaronriekenberg:master

Conversation

@aaronriekenberg
Copy link
Copy Markdown
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
jochenparm pushed a commit to jochenparm/flatbuffers that referenced this pull request Oct 29, 2024
…r methods having an unsigned array type parameter. (google#7881)

Co-authored-by: Derek Bailey <derekbailey@google.com>
jochenparm pushed a commit to jochenparm/flatbuffers that referenced this pull request Oct 29, 2024
…r methods having an unsigned array type parameter. (google#7881)

Co-authored-by: Derek Bailey <derekbailey@google.com>
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