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

fix: 🚑 [BUG] Generic type with concrete type parameters generate non-compiling code #139

Conversation

create-issue-branch[bot]
Copy link
Contributor

Original issue description

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

closes #138

@create-issue-branch create-issue-branch bot added the bug Something isn't working label Nov 9, 2023
@create-issue-branch create-issue-branch bot changed the title [BUG] Generic type with concrete type parameters generate non-compiling code fix: 🚑 [BUG] Generic type with concrete type parameters generate non-compiling code Nov 9, 2023
@pawellabaj pawellabaj marked this pull request as ready for review November 11, 2023 17:39
@pawellabaj pawellabaj self-requested a review as a code owner November 11, 2023 17:39
@pawellabaj pawellabaj merged commit 708cf28 into main Nov 11, 2023
@pawellabaj pawellabaj deleted the fix/issue-138--bug-generic-type-with-concrete-type-parameters-generate-non-co branch November 11, 2023 17:39
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
Development

Successfully merging this pull request may close these issues.

[BUG] Generic type with concrete type parameters generate non-compiling code
1 participant