Ambiguous method call using Project Lombok

♀尐吖头ヾ 提交于 2019-12-23 08:58:34

问题


I have the following code:

import lombok.Builder;
import lombok.Getter;

@Getter
@Builder
public class NameParserResponse {
    private boolean match;
}


public class Main {

    public static void main(String[] args) {
        NameParserResponse nameParserResponse = NameParserResponse.builder().build();
        nameParserResponse.isMatch();
    }
}

When trying to reference isMatch(), I get:

Ambiguous method call. Both

isMatch () in Response and
isMatch () in Response match

I have also tried removing the @Builder annotation, but this doesn't help.


回答1:


It looks like I had the Hrisey Intellij plugin installed in addition to the Project Lombok plugin. I must have accidentally installed this when I was looking for the Project Lombok plugin.

After disabling this plugin, the issue was no longer present.




回答2:


IntelliJ has a refactoring to "de-Lombok" the code, which will expand the Lombok magic out into the more lengthy code it auto-generates behind the scenes. When I've encountered oddities like this before, looking at the actual produced code, instead of just guessing about it, has helped make the problem clearer. YMMV.

Good luck.



来源:https://stackoverflow.com/questions/50162233/ambiguous-method-call-using-project-lombok

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!