suppress duplicate @Override annotations
This commit is contained in:
committed by
Yan Zhulanow
parent
a55a0d94de
commit
6d32b3256b
+5
@@ -1008,7 +1008,12 @@ class ClassFileToSourceStubConverter(val kaptContext: KaptContextForStubGenerati
|
|||||||
invisibleAnnotations: List<AnnotationNode>?,
|
invisibleAnnotations: List<AnnotationNode>?,
|
||||||
descriptorAnnotations: Annotations
|
descriptorAnnotations: Annotations
|
||||||
): JCModifiers {
|
): JCModifiers {
|
||||||
|
var seenOverride = false
|
||||||
fun convertAndAdd(list: JavacList<JCAnnotation>, annotation: AnnotationNode): JavacList<JCAnnotation> {
|
fun convertAndAdd(list: JavacList<JCAnnotation>, annotation: AnnotationNode): JavacList<JCAnnotation> {
|
||||||
|
if (annotation.desc == "Ljava/lang/Override;") {
|
||||||
|
if (seenOverride) return list // KT-34569: skip duplicate @Override annotations
|
||||||
|
seenOverride = true
|
||||||
|
}
|
||||||
val annotationDescriptor = descriptorAnnotations.singleOrNull { checkIfAnnotationValueMatches(annotation, AnnotationValue(it)) }
|
val annotationDescriptor = descriptorAnnotations.singleOrNull { checkIfAnnotationValueMatches(annotation, AnnotationValue(it)) }
|
||||||
val annotationTree = convertAnnotation(annotation, packageFqName, annotationDescriptor) ?: return list
|
val annotationTree = convertAnnotation(annotation, packageFqName, annotationDescriptor) ?: return list
|
||||||
return list.prepend(annotationTree)
|
return list.prepend(annotationTree)
|
||||||
|
|||||||
+5
@@ -288,6 +288,11 @@ public class ClassFileToSourceStubConverterTestGenerated extends AbstractClassFi
|
|||||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/kt28306.kt");
|
runTest("plugins/kapt3/kapt3-compiler/testData/converter/kt28306.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt34569.kt")
|
||||||
|
public void testKt34569() throws Exception {
|
||||||
|
runTest("plugins/kapt3/kapt3-compiler/testData/converter/kt34569.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("lazyProperty.kt")
|
@TestMetadata("lazyProperty.kt")
|
||||||
public void testLazyProperty() throws Exception {
|
public void testLazyProperty() throws Exception {
|
||||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/lazyProperty.kt");
|
runTest("plugins/kapt3/kapt3-compiler/testData/converter/lazyProperty.kt");
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
class T : Runnable {
|
||||||
|
@Override
|
||||||
|
public override fun run() {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import java.lang.System;
|
||||||
|
|
||||||
|
@kotlin.Metadata()
|
||||||
|
public final class T implements java.lang.Runnable {
|
||||||
|
|
||||||
|
@java.lang.Override()
|
||||||
|
public void run() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public T() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user