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

[BUG] Generic type with concrete type parameters generate non-compiling code #138

Closed
zielu opened this issue Nov 9, 2023 · 1 comment · Fixed by #139
Closed

[BUG] Generic type with concrete type parameters generate non-compiling code #138

zielu opened this issue Nov 9, 2023 · 1 comment · Fixed by #139
Assignees
Labels
bug Something isn't working

Comments

@zielu
Copy link

zielu commented Nov 9, 2023

Describe the bug

Given following set of interfaces:

interface BaseType {
}
public interface Common<T extends BaseType> {
    T getParam();
}
public interface ConcreteType extends BaseType {
}
@DefaultAutoRecord
public interface MyRecord extends Common<ConcreteType> {
}

I would expect generated MyRecordRecord constructor to have argument of type ConcreteType, however this is not the case, Type is set to T and record cannot be compiled.


**Details**

See above

3. Generated record:

```java
@Generated("pl.com.labaj.autorecord.AutoRecord")
@GeneratedWithAutoRecord
@RecordBuilder
@RecordBuilder.Options(
    addClassRetainedGenerated = true,
    enableWither = false
)
public record MyRecordRecord(T getParam) implements MyRecord {
  public MyRecordRecord {
    // pl.com.labaj.autorecord.processor.AutoRecordProcessor
    requireNonNull(getParam, "getParam must not be null");
  }

  public static MyRecordRecordBuilder builder() {
    return MyRecordRecordBuilder.builder();
  }

  public MyRecordRecordBuilder toBuilder() {
    return MyRecordRecordBuilder.builder(this);
  }
}

5. Error during compilation:

java: cannot find symbol
symbol: class T
location: class MyRecordRecord


**Expected behavior**

```java
public record MyRecordRecord(ConcreteType getParam) implements MyRecord
@zielu zielu added the bug Something isn't working label Nov 9, 2023
@pawellabaj pawellabaj self-assigned this Nov 9, 2023
Copy link
Contributor

create-issue-branch bot pushed a commit that referenced this issue Nov 9, 2023
pawellabaj added a commit that referenced this issue Nov 11, 2023
…compiling code (#139)

* Create draft PR for #138
[skip ci]

* fix: Generates records with complicated Generics structure

---------

Co-authored-by: pawellabaj <pawellabaj@users.noreply.github.com>
Co-authored-by: Pawel_Labaj <Pawel_Labaj@epam.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants