projectlombok / lombok

Very spicy additions to the Java programming language.
https://projectlombok.org/
Other
12.79k stars 2.37k forks source link

[BUG] @Setter not processed when a setX(Y y) exists #3114

Closed onacit closed 2 years ago

onacit commented 2 years ago

Describe the bug @Setter seems not processed when a setX method with alien type exists.

To Reproduce

@Setter
public class TestBean {

    //public void setError(final String error) {
    //    this.error = error;
    //}

    // compilation error!
    public void setError(final Throwable thrown) {
        setError(Optional.ofNullable(thrown).map(Object::toString).orElse(null));
    }

    private String error;
}

Expected behavior @Setter shouldn't take the setError(Throwable) method as an existing setter for the error property of String type.

Version info (please complete the following information):

Build time: 2022-02-08 09:58:38 UTC Revision: f0d9291c04b90b59445041eaa75b2ee744162586

Kotlin: 1.5.31 Groovy: 3.0.9 Ant: Apache Ant(TM) version 1.10.11 compiled on July 10 2021 JVM: 11.0.14.1 (Eclipse Adoptium 11.0.14.1+1) OS: Mac OS X 12.2.1 x86_64



**Additional context**
Add any other context about the problem here.
rzwitserloot commented 2 years ago

Wontfix - this is Intentional behaviour.

The reason this is intentional and we won't be changing it: It's actually rather difficult to attempt to 'figure out' if we should make that setter or not. For two reasons:

The first 2 bullets on their own are enough, let alone all 4.

For all these reasons, there is no right answer, so we choose not to play: Existence of any method named setFoo regardless of arguments means we don't generate a setter. @Tolerate exists to work around this.