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

Collection<...> generates invalid code #227

Closed
Joao-Neves opened this issue Dec 22, 2016 · 7 comments
Closed

Collection<...> generates invalid code #227

Joao-Neves opened this issue Dec 22, 2016 · 7 comments
Assignees
Labels

Comments

@Joao-Neves
Copy link

Joao-Neves commented Dec 22, 2016

From version 1.10.6 onwards every time I write something like:

@FreeBuilder
public interface MyBuilder {

    Collection<MyClass> getMyClass();

    class Builder extends MyBuilder_Builder {}
} 

I get the following compilation error:

Error:(xxx, xx) java: incompatible types: java.util.Collection<mypackage.MyClass> cannot be converted to java.util.List<mypackage.MyClass>

By inspecting the generated code we can see that this occurs when you attempt to do this myClass = value.getMyClass(); but the field myClass is defined as List<MyClass> instead of Collection<MyClass>.

@alicederyn
Copy link
Collaborator

Thanks for the spot! As a workaround you can use List instead of Collection until we get this fixed, if binary backwards compatibility is not an issue for you.

@alicederyn alicederyn self-assigned this Dec 22, 2016
@alicederyn alicederyn added the bug label Dec 22, 2016
@alicederyn alicederyn changed the title Collection<MyClass> generates invalid code Collection<...> generates invalid code Dec 22, 2016
@alicederyn
Copy link
Collaborator

Note that this bug also affects wildcard types like List<? extends Number>.

@alicederyn
Copy link
Collaborator

@Joao-Neves Could you give v1.12.1-rc1 a try?

@Joao-Neves
Copy link
Author

@ChrisAlice Sure thing, I'll test it as soon as I get to the office tomorrow morning.

@Joao-Neves
Copy link
Author

@ChrisAlice Hello, it's working fine on my end. Thank you for the quick fix!
Happy Holidays!

@alicederyn
Copy link
Collaborator

Happy holidays!

alicederyn referenced this issue Jan 6, 2017
…nvalid.code

Cast Collection to List when necessary
@alicederyn
Copy link
Collaborator

This should be fixed in v1.12.1 proper now.

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

No branches or pull requests

2 participants