[lombok] Don't fail on fake overrides

#KT-47455 Fixes
This commit is contained in:
Andrey Zinovyev
2021-06-25 16:53:25 +03:00
committed by teamcityserver
parent 80b81934de
commit c8fa8b0444
4 changed files with 29 additions and 5 deletions
@@ -16,11 +16,10 @@ import org.jetbrains.kotlin.name.Name
abstract class AbstractConstructorProcessor<A : ConstructorAnnotation> : Processor {
override fun contribute(classDescriptor: ClassDescriptor, partsBuilder: SyntheticPartsBuilder) {
val valueParameters = getPropertiesForParameters(classDescriptor).map { property ->
LombokValueParameter(property.name, property.type)
}
getAnnotation(classDescriptor)?.let { annotation ->
val valueParameters = getPropertiesForParameters(classDescriptor).map { property ->
LombokValueParameter(property.name, property.type)
}
if (annotation.staticName == null) {
val constructor = classDescriptor.createJavaConstructor(
valueParameters = valueParameters,
@@ -24,7 +24,7 @@ class RequiredArgsConstructorProcessor : AbstractConstructorProcessor<RequiredAr
classDescriptor.getJavaFields().filter(this::isFieldRequired)
private fun isFieldRequired(field: PropertyDescriptor): Boolean {
val psi = field.source.getPsi()!! as PsiField
val psi = field.source.getPsi() as? PsiField ?: return false
val final = psi.modifierList?.hasModifierProperty(PsiModifier.FINAL) ?: false ||
field.annotations.any { annotation -> LombokNames.NON_NULL_ANNOTATIONS.contains(annotation.fqName) }
@@ -0,0 +1,20 @@
//KT-47455
//FILE: ParentClass.java
public abstract class ParentClass {
int id;
}
//FILE: ChildClass.java
import lombok.*;
@RequiredArgsConstructor
public class ChildClass extends ParentClass {}
//FILE: test.kt
class Test {
fun run() {
ChildClass::class
}
}
@@ -129,6 +129,11 @@ public class LombokCompileTestGenerated extends AbstractLombokCompileTest {
runTest("plugins/lombok/lombok-compiler-plugin/testData/compile/nullability.kt");
}
@TestMetadata("propertyFromSuper.kt")
public void testPropertyFromSuper() throws Exception {
runTest("plugins/lombok/lombok-compiler-plugin/testData/compile/propertyFromSuper.kt");
}
@TestMetadata("requiredArgsConstructor.kt")
public void testRequiredArgsConstructor() throws Exception {
runTest("plugins/lombok/lombok-compiler-plugin/testData/compile/requiredArgsConstructor.kt");