record-builder icon indicating copy to clipboard operation
record-builder copied to clipboard

Cannot find symbol in code generated with addSingleItemCollectionBuilders

Open mwisnicki opened this issue 2 years ago • 2 comments

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 avatar Feb 02 '23 03:02 mwisnicki

OpenJDK18 on Win11

mwisnicki avatar Feb 02 '23 03:02 mwisnicki

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.

Randgalt avatar Feb 04 '23 09:02 Randgalt