Files
kotlin-fork/plugins/lombok/testData/diagnostics/clashAccessors.kt
T
Nikolay Lunyak 4e58715760 [FIR] Check conflicting overloads via scopes
Scopes may return private symbols from
supertypes, they should not clash with
symbols from the current class.

For example, see:
`FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated.FakeOverride#testPrivateFakeOverrides1`

Lombok shouldn't generate functions if the
user has defined explicit ones.

In K1 generated functions are not really
added to the declared members scope.

^KT-61243 Fixed
2023-10-09 06:55:43 +00:00

117 lines
1.8 KiB
Kotlin
Vendored

// FILE: SuperClass.java
import lombok.*;
import java.util.*;
public class SuperClass {
public void setName(String name) {
}
}
// FILE: ClashTest.java
import lombok.*;
import java.util.*;
@Getter
@Setter
public class ClashTest extends SuperClass {
private int age = 10;
private String name;
private boolean human;
private Integer toOverride;
public int getAge() {
return age;
}
public void setAge(String age) {
}
public boolean isHuman(String arg) {
return human;
}
private int score;
public void setScore(int score, int times) {
}
static void test() {
val obj = new ClashTest();
obj.getAge();
// obj.setAge(41);
obj.getName();
obj.setName("Al");
obj.isHuman();
obj.setHuman(true);
obj.isHuman("sdf");
}
}
// FILE: ChildClass.java
import lombok.*;
import java.util.*;
public class ChildClass extends ClashTest{
@Override
public Integer getToOverride() {
return super.getToOverride();
}
}
// FILE: test.kt
class KotlinChildClass : ClashTest() {
override fun getToOverride(): Int? = super.getToOverride()
}
fun test() {
val obj = ClashTest()
obj.getAge()
//thats shouldn't work because lombok doesn't generate clashing method
obj.setAge(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>41<!>)
<!VAL_REASSIGNMENT!>obj.age<!> = 12
val age = obj.age
obj.setScore(41)
obj.score = 12
obj.getName()
obj.setName("Al")
val name = obj.name
obj.name = "sdf"
obj.isHuman()
obj.setHuman(true)
obj.isHuman("sdf")
val isHuman = obj.isHuman
obj.isHuman = false
val childObj = KotlinChildClass()
childObj.getToOverride()
childObj.setToOverride(34)
childObj.toOverride
childObj.toOverride = 412
}