Randgalt / record-builder

Record builder generator for Java records
Apache License 2.0
723 stars 51 forks source link

Cannot find symbol in code generated with addSingleItemCollectionBuilders #141

Open mwisnicki opened 1 year ago

mwisnicki commented 1 year ago

Code:

@RecordBuilder
@RecordBuilder.Options(addSingleItemCollectionBuilders = true)
record Person(String name, int age, Map<String, Object> other) implements PersonBuilder.With {}

POM:

    <dependencies>
        <dependency>
            <groupId>io.soabase.record-builder</groupId>
            <artifactId>record-builder-processor</artifactId>
            <version>35</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

Compiler error:

\target\generated-sources\annotations\org\example\PersonBuilder.java:141:22
java: cannot find symbol
  symbol:   method __map(java.util.Map<capture#1 of ? extends java.lang.String,capture#2 of ?>)
  location: class org.example.PersonBuilder

Generated snippet:

    /**
     * Re-create the internally allocated {@code Map<String, Object>} for {@code other} by copying the argument
     */
    @Generated("io.soabase.recordbuilder.core.RecordBuilder")
    public PersonBuilder other(Map<? extends String, ?> other) {
        this.other = __map(other);
        return this;
    }

There is no __map defined anywhere Lists fail the same way with missing __list.

mwisnicki commented 1 year ago

OpenJDK18 on Win11

Randgalt commented 1 year ago

This is a duplicate of https://github.com/Randgalt/record-builder/issues/129 I believe. We don't have a good solution yet. I had a PR but it was not acceptable by the community. I didn't write the original PR that is causing the error and I'm not sure what the correct solution is here. I'd really like the community to detail what the correct behavior should be.