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

Generic method implementations inherited from base class are treated as abstract getters by FreeBuilder. #300

Open
tullisar opened this issue Jun 6, 2018 · 1 comment

Comments

@tullisar
Copy link

tullisar commented Jun 6, 2018

This might be related to #112, but something similar happens with generic methods inherited from a base type.

@FreeBuilder
abstract class Test extends ForwardingSet<String>
{
    static class Builder extends Test_Builder
    {

    }

    @Override
    protected abstract Set<String> delegate();

    @Override
    public boolean add(final String value)
    {
        return super.add(value);
    }

    @Override
    public boolean addAll(final Collection<? extends String> values)
    {
        return super.addAll(values);
    }
}

Although the generated builder and value type have no compiler errors, the annotation processor generates several errors related to a few of the methods inherited from ForwardingSet:

No implementation found for non-getter method 'public abstract T[] toArray(T[]) '; cannot generate @FreeBuilder implementation	Test.java	...	line 22	Annotation Problem (Java 6 processor)

addAll and add seem to trigger the issue described in #112, but I can workaround as described in the issue. However, the workaround doesn't seem to do the trick for toArray.

I haven't thoroughly tested other triggering conditions, and I've only tried it using the annotation processing in Eclipse Oxygen (4.7.3a). I'll try it out without Eclipse tomorrow.

@tullisar
Copy link
Author

tullisar commented Jun 6, 2018

Chalk this up to another Eclipse only issue. Created a very simple case to reproduce this:

TestInterface.java

public interface TestInterface
{
    public <T> void doSomething(T[] array);
}

TestBuildable.java

@FreeBuilder
public class TestBuildable implements TestInterface
{
    public static class Builder extends TestBuildable_Builder
    {

    }

    @Override
    public <T> void doSomething(final T[] array)
    {

    }
}

This triggers the annotation error when using Eclipse's annotation processing support. Running a Maven build via the command line issues no errors. Easy enough to work around at least.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants