Skip to content

Remove @ExperimentalUnsignedTypes annotation from kotlin code generator. #7092

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

Merged
merged 1 commit into from
Feb 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/idl_gen_kotlin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ class KotlinGenerator : public BaseGenerator {
GenerateComment(enum_def.doc_comment, writer, &comment_config);

writer += "@Suppress(\"unused\")";
writer += "@ExperimentalUnsignedTypes";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to make this optional for kotlin users before 1.5?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we change the behaviour to not generate the annotations by default, the user will have to do a change on their build system. Either by invoking flatc with a flag, like --kotlin-unsigned-annotation or by introducing a flags on Kotlin compiler(kotlinc) as defined here.

The other option is to add a flag to suppress generating this annotation --kotlin-supress-unsigned-annotation, keeping the current behaviour default.

AFAIK, Kotlin users adopt newer versions of quite fast so I would be leaning to simply not generating the annotation (keeping current PR as is). Users of old versions can add flags on their build system to remediate that.

Maybe we can leave the PR open for a few more days to see if Kotlin users can provide feedback.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the info. Lets leave open for a bit and if I don't hear anything I will merge.

writer += "class " + Esc(enum_def.name) + " private constructor() {";
writer.IncrementIdentLevel();

Expand Down Expand Up @@ -461,7 +460,6 @@ class KotlinGenerator : public BaseGenerator {
writer.SetValue("superclass", fixed ? "Struct" : "Table");

writer += "@Suppress(\"unused\")";
writer += "@ExperimentalUnsignedTypes";
writer += "class {{struct_name}} : {{superclass}}() {\n";

writer.IncrementIdentLevel();
Expand Down
1 change: 0 additions & 1 deletion tests/MyGame/Example/Ability.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import kotlin.math.sign
import com.google.flatbuffers.*

@Suppress("unused")
@ExperimentalUnsignedTypes
class Ability : Struct() {

fun __init(_i: Int, _bb: ByteBuffer) {
Expand Down
1 change: 0 additions & 1 deletion tests/MyGame/Example/Any.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
package MyGame.Example

@Suppress("unused")
@ExperimentalUnsignedTypes
class Any_ private constructor() {
companion object {
const val NONE: UByte = 0u
Expand Down
1 change: 0 additions & 1 deletion tests/MyGame/Example/AnyAmbiguousAliases.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
package MyGame.Example

@Suppress("unused")
@ExperimentalUnsignedTypes
class AnyAmbiguousAliases private constructor() {
companion object {
const val NONE: UByte = 0u
Expand Down
1 change: 0 additions & 1 deletion tests/MyGame/Example/AnyUniqueAliases.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
package MyGame.Example

@Suppress("unused")
@ExperimentalUnsignedTypes
class AnyUniqueAliases private constructor() {
companion object {
const val NONE: UByte = 0u
Expand Down
1 change: 0 additions & 1 deletion tests/MyGame/Example/Color.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package MyGame.Example
* Composite components of Monster color.
*/
@Suppress("unused")
@ExperimentalUnsignedTypes
class Color private constructor() {
companion object {
const val Red: UByte = 1u
Expand Down
1 change: 0 additions & 1 deletion tests/MyGame/Example/Monster.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import com.google.flatbuffers.*
* an example documentation comment: "monster object"
*/
@Suppress("unused")
@ExperimentalUnsignedTypes
class Monster : Table() {

fun __init(_i: Int, _bb: ByteBuffer) {
Expand Down
1 change: 0 additions & 1 deletion tests/MyGame/Example/Race.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
package MyGame.Example

@Suppress("unused")
@ExperimentalUnsignedTypes
class Race private constructor() {
companion object {
const val None: Byte = -1
Expand Down
1 change: 0 additions & 1 deletion tests/MyGame/Example/Referrable.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import kotlin.math.sign
import com.google.flatbuffers.*

@Suppress("unused")
@ExperimentalUnsignedTypes
class Referrable : Table() {

fun __init(_i: Int, _bb: ByteBuffer) {
Expand Down
1 change: 0 additions & 1 deletion tests/MyGame/Example/Stat.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import kotlin.math.sign
import com.google.flatbuffers.*

@Suppress("unused")
@ExperimentalUnsignedTypes
class Stat : Table() {

fun __init(_i: Int, _bb: ByteBuffer) {
Expand Down
1 change: 0 additions & 1 deletion tests/MyGame/Example/StructOfStructs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import kotlin.math.sign
import com.google.flatbuffers.*

@Suppress("unused")
@ExperimentalUnsignedTypes
class StructOfStructs : Struct() {

fun __init(_i: Int, _bb: ByteBuffer) {
Expand Down
1 change: 0 additions & 1 deletion tests/MyGame/Example/Test.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import kotlin.math.sign
import com.google.flatbuffers.*

@Suppress("unused")
@ExperimentalUnsignedTypes
class Test : Struct() {

fun __init(_i: Int, _bb: ByteBuffer) {
Expand Down
1 change: 0 additions & 1 deletion tests/MyGame/Example/TestSimpleTableWithEnum.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import kotlin.math.sign
import com.google.flatbuffers.*

@Suppress("unused")
@ExperimentalUnsignedTypes
class TestSimpleTableWithEnum : Table() {

fun __init(_i: Int, _bb: ByteBuffer) {
Expand Down
1 change: 0 additions & 1 deletion tests/MyGame/Example/TypeAliases.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import kotlin.math.sign
import com.google.flatbuffers.*

@Suppress("unused")
@ExperimentalUnsignedTypes
class TypeAliases : Table() {

fun __init(_i: Int, _bb: ByteBuffer) {
Expand Down
1 change: 0 additions & 1 deletion tests/MyGame/Example/Vec3.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import kotlin.math.sign
import com.google.flatbuffers.*

@Suppress("unused")
@ExperimentalUnsignedTypes
class Vec3 : Struct() {

fun __init(_i: Int, _bb: ByteBuffer) {
Expand Down
1 change: 0 additions & 1 deletion tests/MyGame/Example2/Monster.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import kotlin.math.sign
import com.google.flatbuffers.*

@Suppress("unused")
@ExperimentalUnsignedTypes
class Monster : Table() {

fun __init(_i: Int, _bb: ByteBuffer) {
Expand Down
1 change: 0 additions & 1 deletion tests/MyGame/InParentNamespace.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import kotlin.math.sign
import com.google.flatbuffers.*

@Suppress("unused")
@ExperimentalUnsignedTypes
class InParentNamespace : Table() {

fun __init(_i: Int, _bb: ByteBuffer) {
Expand Down
1 change: 0 additions & 1 deletion tests/MyGame/MonsterExtra.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import kotlin.math.sign
import com.google.flatbuffers.*

@Suppress("unused")
@ExperimentalUnsignedTypes
class MonsterExtra : Table() {

fun __init(_i: Int, _bb: ByteBuffer) {
Expand Down
1 change: 0 additions & 1 deletion tests/optional_scalars/OptionalByte.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
package optional_scalars

@Suppress("unused")
@ExperimentalUnsignedTypes
class OptionalByte private constructor() {
companion object {
const val None: Byte = 0
Expand Down
1 change: 0 additions & 1 deletion tests/optional_scalars/ScalarStuff.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import kotlin.math.sign
import com.google.flatbuffers.*

@Suppress("unused")
@ExperimentalUnsignedTypes
class ScalarStuff : Table() {

fun __init(_i: Int, _bb: ByteBuffer) {
Expand Down
1 change: 0 additions & 1 deletion tests/union_vector/Attacker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import kotlin.math.sign
import com.google.flatbuffers.*

@Suppress("unused")
@ExperimentalUnsignedTypes
class Attacker : Table() {

fun __init(_i: Int, _bb: ByteBuffer) {
Expand Down
1 change: 0 additions & 1 deletion tests/union_vector/BookReader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import kotlin.math.sign
import com.google.flatbuffers.*

@Suppress("unused")
@ExperimentalUnsignedTypes
class BookReader : Struct() {

fun __init(_i: Int, _bb: ByteBuffer) {
Expand Down
1 change: 0 additions & 1 deletion tests/union_vector/Character.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// automatically generated by the FlatBuffers compiler, do not modify

@Suppress("unused")
@ExperimentalUnsignedTypes
class Character_ private constructor() {
companion object {
const val NONE: UByte = 0u
Expand Down
1 change: 0 additions & 1 deletion tests/union_vector/FallingTub.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import kotlin.math.sign
import com.google.flatbuffers.*

@Suppress("unused")
@ExperimentalUnsignedTypes
class FallingTub : Struct() {

fun __init(_i: Int, _bb: ByteBuffer) {
Expand Down
1 change: 0 additions & 1 deletion tests/union_vector/Gadget.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// automatically generated by the FlatBuffers compiler, do not modify

@Suppress("unused")
@ExperimentalUnsignedTypes
class Gadget private constructor() {
companion object {
const val NONE: UByte = 0u
Expand Down
1 change: 0 additions & 1 deletion tests/union_vector/HandFan.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import kotlin.math.sign
import com.google.flatbuffers.*

@Suppress("unused")
@ExperimentalUnsignedTypes
class HandFan : Table() {

fun __init(_i: Int, _bb: ByteBuffer) {
Expand Down
1 change: 0 additions & 1 deletion tests/union_vector/Movie.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import kotlin.math.sign
import com.google.flatbuffers.*

@Suppress("unused")
@ExperimentalUnsignedTypes
class Movie : Table() {

fun __init(_i: Int, _bb: ByteBuffer) {
Expand Down
1 change: 0 additions & 1 deletion tests/union_vector/Rapunzel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import kotlin.math.sign
import com.google.flatbuffers.*

@Suppress("unused")
@ExperimentalUnsignedTypes
class Rapunzel : Struct() {

fun __init(_i: Int, _bb: ByteBuffer) {
Expand Down