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

Compile errors when defining nested buildable types in generic outer classes #268

Open
tullisar opened this issue Oct 5, 2017 · 7 comments

Comments

@tullisar
Copy link

tullisar commented Oct 5, 2017

Defining a static buildable type in a generic outer class generates compiler errors when one of the fields is another nested class in the same file.

public class GenericOuterBug<T> 
{
    @FreeBuilder
    public static abstract class Buildable
    {   
        public static class Builder extends GenericOuterBug_Buildable_Builder {}
        public abstract Sibling fieldWithError();
    }
    public static interface Sibling {}
}

The following is a portion of what gets generated. Most of the references to GenericOuterBug.Sibling get generated as GenericOuterBug<T>.Sibling:

  private GenericOuterBug<T>.Sibling fieldWithError;
  <snip>
  public GenericOuterBug.Buildable.Builder fieldWithError(
      GenericOuterBug<T>.Sibling fieldWithError) {
    this.fieldWithError = Preconditions.checkNotNull(fieldWithError);
    _unsetProperties.remove(GenericOuterBug_Buildable_Builder.Property.FIELD_WITH_ERROR);
    return (GenericOuterBug.Buildable.Builder) this;
  }
@alicederyn alicederyn self-assigned this Oct 5, 2017
@alicederyn alicederyn added the bug label Oct 5, 2017
@alicederyn
Copy link
Collaborator

Argh. Generics. Thanks for the report, I'll try and get on this tomorrow :)

@alicederyn
Copy link
Collaborator

Hi @tullisar. I'm unable to reproduce this bug with the example code you've given. What version of FreeBuilder are you on? What version of Java, and what build system? Did you accidentally remove some part of your code that triggers the bug in condensing it for this report?

@tullisar
Copy link
Author

tullisar commented Oct 9, 2017

Freebuilder Version: 1.14.6
JDK: 1.8.0_144
Using Eclipse Oxygen (4.7.1) to build.

Looking at this a bit more, using Eclipse to build seems to trigger this. When I run a Maven build it seems to be just fine.

@tullisar
Copy link
Author

I'm starting to suspect this might be a regression in Eclipse? I never recalled having this bug until recently (on the same construct I've listed as causing the bug). On a whim I launched Eclipse Mars (4.5.1) and ran a build and it generated the code just fine.

Since the maven build works I've just gone ahead and turn off Eclipse's automatic build for the time being. I'm not exactly sure what kind of bug report I'd even submit for Eclipse though. I'm not really familiar with annotation processors and how Eclipse interacts with them.

@alicederyn
Copy link
Collaborator

I can work around most things in FreeBuilder's code, so let's see if I can repro now I know the IDE version. Thanks :)

@alicederyn
Copy link
Collaborator

Yep, I can reproduce this now. (Irritatingly I can't reproduce it in a test, but I'll figure something out to try and avoid future regressions.)

@alicederyn alicederyn removed their assignment Jan 9, 2018
@alicederyn
Copy link
Collaborator

Sorry, @tullisar, I haven't got around to prioritising this yet. Hard to motivate myself to work around a niche Eclipse bug :(

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