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

Accidental override when enabling <interfaces> for tables with columns X and IS_X in Kotlin #15850

Closed
lukaseder opened this issue Nov 20, 2023 · 2 comments

Comments

@lukaseder
Copy link
Member

Kotlin's infinite wisdom placed in the cleverness of the isX:boolean property naming convention is a gift that keeps on giving, this time when enabling <interfaces> for tables with boolean columns X and IS_X:

CREATE TABLE t_11912 (
  x INT,
  is_x INT,
  is_y INT
);

Generated code produces this compilation error:

[ERROR] Failed to execute goal org.jetbrains.kotlin:kotlin-maven-plugin:1.8.0:test-compile (test-compile) on project jooq-test-codegen-kotlin: Compilation failure: Compilation failure:
[ERROR] C:\Users\lukas\jOOQ\3.19\workspace\jOOQ-pro\jOOQ-test-codegen\jOOQ-test-codegen-kotlin\src\test\kotlin\org\jooq\codegen\test\ambiguouscolumnnames\db\tables\interfaces\IT_11912.kt:[15,5] Platform declaration clash: The following declarations have the same JVM signature (setX(Ljava/lang/Integer;)V):
[ERROR]     fun `<set-isX>`(`<set-?>`: Int?): Unit defined in org.jooq.codegen.test.ambiguouscolumnnames.db.tables.interfaces.IT_11912
[ERROR]     fun `<set-x>`(`<set-?>`: Int?): Unit defined in org.jooq.codegen.test.ambiguouscolumnnames.db.tables.interfaces.IT_11912
[ERROR] C:\Users\lukas\jOOQ\3.19\workspace\jOOQ-pro\jOOQ-test-codegen\jOOQ-test-codegen-kotlin\src\test\kotlin\org\jooq\codegen\test\ambiguouscolumnnames\db\tables\interfaces\IT_11912.kt:[16,5] Platform declaration clash: The following declarations have the same JVM signature (setX(Ljava/lang/Integer;)V):
[ERROR]     fun `<set-isX>`(`<set-?>`: Int?): Unit defined in org.jooq.codegen.test.ambiguouscolumnnames.db.tables.interfaces.IT_11912
[ERROR]     fun `<set-x>`(`<set-?>`: Int?): Unit defined in org.jooq.codegen.test.ambiguouscolumnnames.db.tables.interfaces.IT_11912
[ERROR] C:\Users\lukas\jOOQ\3.19\workspace\jOOQ-pro\jOOQ-test-codegen\jOOQ-test-codegen-kotlin\src\test\kotlin\org\jooq\codegen\test\ambiguouscolumnnames\db\tables\pojos\T_11912.kt:[15,5] Accidental override: The following declarations have the same JVM signature (setX(Ljava/lang/Integer;)V):
[ERROR]     fun `<set-x>`(`<set-?>`: Int?): Unit defined in org.jooq.codegen.test.ambiguouscolumnnames.db.tables.pojos.T_11912
[ERROR]     fun setX(`<set-?>`: Int?): Unit defined in org.jooq.codegen.test.ambiguouscolumnnames.db.tables.pojos.T_11912
[ERROR] C:\Users\lukas\jOOQ\3.19\workspace\jOOQ-pro\jOOQ-test-codegen\jOOQ-test-codegen-kotlin\src\test\kotlin\org\jooq\codegen\test\ambiguouscolumnnames\db\tables\records\T_11912Record.kt:[22,9] Accidental override: The following declarations have the same JVM signature (setX(Ljava/lang/Integer;)V):
[ERROR]     fun `<set-x>`(value: Int?): Unit defined in org.jooq.codegen.test.ambiguouscolumnnames.db.tables.records.T_11912Record
[ERROR]     fun setX(`<set-?>`: Int?): Unit defined in org.jooq.codegen.test.ambiguouscolumnnames.db.tables.records.T_11912Record
[ERROR] -> [Help 1]

The workaround is to use a generator strategy, of course, or to turn off <interfaces>


See also:

@lukaseder
Copy link
Member Author

I guess the @set:JvmName annotations on the subtypes should also be generated on the interface type?

3.14 Better Kotlin and Scala Support automation moved this from To do to Done Nov 20, 2023
lukaseder added a commit that referenced this issue Nov 20, 2023
tables with columns X and IS_X in Kotlin
lukaseder added a commit that referenced this issue Nov 20, 2023
tables with columns X and IS_X in Kotlin
lukaseder added a commit that referenced this issue Nov 20, 2023
tables with columns X and IS_X in Kotlin
lukaseder added a commit that referenced this issue Nov 20, 2023
tables with columns X and IS_X in Kotlin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant