Skip to content

Kotlin codegen generates invalid code when a parameterized mapped superclass is used #890

@jpmsilva

Description

@jpmsilva

Important Notice

Thank you for opening an issue! Please note that, as outlined in the README, I currently only work on feature requests or bug fixes when sponsored. Balancing this project with professional and personal priorities means I have a very limited amount of effort I can divert to this project.

You must put in the work to address this issue, or it won't be addressed.

  • I am willing to put in the work and submit a PR to resolve this issue.

Describe the bug

When using a parameterized mapped superclass the generated Q-classes are invalid with respect to the generic parameters.

To Reproduce

A test example can be seen at https://github.com/jpmsilva/openfeign-querydsl/tree/kotlin-codegen-generic-supertype (branched from the 6.10.1 release).

Running clean package -P quickbuild from the folder querydsl-examples/querydsl-example-kotlin-codegen shows the issue:

[INFO] --- kotlin:2.1.0:compile (compile) @ querydsl-example-kotlin-codegen ---
[INFO] Applied plugin: 'jpa'
[WARNING] Duplicate source root: querydsl/querydsl-examples/querydsl-example-kotlin-codegen/target/generated-sources/kapt/compile
[WARNING] Duplicate source root: querydsl/querydsl-examples/querydsl-example-kotlin-codegen/target/generated-sources/kaptKotlin/compile
[ERROR] querydsl/querydsl-examples/querydsl-example-kotlin-codegen/target/generated-sources/kaptKotlin/compile/com/querydsl/examples/kotlin/entity/QExampleBaseEntity.kt: (23, 42) None of the following candidates is applicable:
constructor<T : Any!>(p0: Class<out T!>!, p1: String!): EntityPathBase<T>
constructor<T : Any!>(p0: Class<out T!>!, p1: PathMetadata!): EntityPathBase<T>
[ERROR] querydsl/querydsl-examples/querydsl-example-kotlin-codegen/target/generated-sources/kaptKotlin/compile/com/querydsl/examples/kotlin/entity/QExampleBaseEntity.kt: (27, 48) None of the following candidates is applicable:
constructor<T : Any!>(p0: Class<out T!>!, p1: String!): EntityPathBase<T>
constructor<T : Any!>(p0: Class<out T!>!, p1: PathMetadata!): EntityPathBase<T>
[ERROR] querydsl/querydsl-examples/querydsl-example-kotlin-codegen/target/generated-sources/kaptKotlin/compile/com/querydsl/examples/kotlin/entity/QExampleEntity.kt: (27, 5) None of the following candidates is applicable:
constructor(variable: String): QExampleBaseEntity
constructor(path: Path<out ExampleBaseEntity<Serializable>>): QExampleBaseEntity
constructor(metadata: PathMetadata): QExampleBaseEntity

Expected behavior
Build should complete without errors.

Screenshots
N/A

Desktop (please complete the following information):
N/A

Smartphone (please complete the following information):
N/A

Additional context
I might be able to submit a PR to properly set the out keyword in the superclass parameters of the generated Q-classes. This aligns the generated Kotlin Q-classes with the Java Q-classes with regards to entity parameters, when they are used.

When using the Java codegen variant these generic mapped superclass types are properly handled. The issue only happens in the Kotlin codegen module.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions