Do not put inapplicable annotations on getter
This commit is contained in:
+3
-2
@@ -78,6 +78,7 @@ public class AnnotationSplitter(
|
|||||||
val map = hashMapOf<AnnotationUseSiteTarget, MutableList<AnnotationWithTarget>>()
|
val map = hashMapOf<AnnotationUseSiteTarget, MutableList<AnnotationWithTarget>>()
|
||||||
val other = arrayListOf<AnnotationWithTarget>()
|
val other = arrayListOf<AnnotationWithTarget>()
|
||||||
val applicableTargets = applicableTargetsLazy()
|
val applicableTargets = applicableTargetsLazy()
|
||||||
|
val applicableTargetsWithoutUseSiteTarget = applicableTargets.intersect(TARGET_PRIORITIES)
|
||||||
|
|
||||||
outer@ for (annotationWithTarget in allAnnotations.getAllAnnotations()) {
|
outer@ for (annotationWithTarget in allAnnotations.getAllAnnotations()) {
|
||||||
val useSiteTarget = annotationWithTarget.target
|
val useSiteTarget = annotationWithTarget.target
|
||||||
@@ -91,7 +92,7 @@ public class AnnotationSplitter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (target in TARGET_PRIORITIES) {
|
for (target in TARGET_PRIORITIES) {
|
||||||
if (target !in applicableTargets) continue
|
if (target !in applicableTargetsWithoutUseSiteTarget) continue
|
||||||
|
|
||||||
val declarationSiteTargetForCurrentTarget = KotlinTarget.USE_SITE_MAPPING[target] ?: continue
|
val declarationSiteTargetForCurrentTarget = KotlinTarget.USE_SITE_MAPPING[target] ?: continue
|
||||||
val applicableTargetsForAnnotation = AnnotationChecker.applicableTargetSet(annotationWithTarget.annotation)
|
val applicableTargetsForAnnotation = AnnotationChecker.applicableTargetSet(annotationWithTarget.annotation)
|
||||||
@@ -115,7 +116,7 @@ public class AnnotationSplitter(
|
|||||||
return CompositeAnnotations(targets.map { getAnnotationsForTarget(it) })
|
return CompositeAnnotations(targets.map { getAnnotationsForTarget(it) })
|
||||||
}
|
}
|
||||||
|
|
||||||
private inner class LazySplitAnnotations(storageManager: StorageManager, target: AnnotationUseSiteTarget?) : Annotations {
|
private inner class LazySplitAnnotations(storageManager: StorageManager, val target: AnnotationUseSiteTarget?) : Annotations {
|
||||||
private val annotations by storageManager.createLazyValue {
|
private val annotations by storageManager.createLazyValue {
|
||||||
val splitAnnotations = this@AnnotationSplitter.splitAnnotations()
|
val splitAnnotations = this@AnnotationSplitter.splitAnnotations()
|
||||||
|
|
||||||
|
|||||||
@@ -1067,7 +1067,6 @@ public class DescriptorResolver {
|
|||||||
if (getter != null) {
|
if (getter != null) {
|
||||||
Annotations getterAnnotations = new CompositeAnnotations(CollectionsKt.listOf(
|
Annotations getterAnnotations = new CompositeAnnotations(CollectionsKt.listOf(
|
||||||
annotationSplitter.getAnnotationsForTarget(PROPERTY_GETTER),
|
annotationSplitter.getAnnotationsForTarget(PROPERTY_GETTER),
|
||||||
annotationSplitter.getOtherAnnotations(),
|
|
||||||
annotationResolver.resolveAnnotationsWithoutArguments(scope, getter.getModifierList(), trace)));
|
annotationResolver.resolveAnnotationsWithoutArguments(scope, getter.getModifierList(), trace)));
|
||||||
|
|
||||||
JetType outType = propertyDescriptor.getType();
|
JetType outType = propertyDescriptor.getType();
|
||||||
|
|||||||
@@ -24,4 +24,15 @@ public class A(
|
|||||||
@AnnProperty @AnnField @AnnFieldProperty @AnnParameterProperty @AnnParameterField @AnnTypeField
|
@AnnProperty @AnnField @AnnFieldProperty @AnnParameterProperty @AnnParameterField @AnnTypeField
|
||||||
public val a: Int = 1
|
public val a: Int = 1
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Target(AnnotationTarget.FIELD)
|
||||||
|
annotation class Anno
|
||||||
|
|
||||||
|
@Anno
|
||||||
|
val p: Int
|
||||||
|
get() = 5
|
||||||
|
|
||||||
|
@Anno
|
||||||
|
val p2: Int = 4
|
||||||
|
get() = field
|
||||||
@@ -19,3 +19,20 @@
|
|||||||
@kotlin.annotation.Target @java.lang.annotation.Retention @java.lang.annotation.Target @kotlin.jvm.internal.KotlinClass AnnProperty
|
@kotlin.annotation.Target @java.lang.annotation.Retention @java.lang.annotation.Target @kotlin.jvm.internal.KotlinClass AnnProperty
|
||||||
|
|
||||||
@kotlin.annotation.Target @java.lang.annotation.Retention @java.lang.annotation.Target @kotlin.jvm.internal.KotlinClass AnnTypeField
|
@kotlin.annotation.Target @java.lang.annotation.Retention @java.lang.annotation.Target @kotlin.jvm.internal.KotlinClass AnnTypeField
|
||||||
|
|
||||||
|
@kotlin.annotation.Target @java.lang.annotation.Retention @java.lang.annotation.Target @kotlin.jvm.internal.KotlinClass Anno
|
||||||
|
|
||||||
|
@kotlin.jvm.internal.KotlinFileFacade DefaultTargetsKt {
|
||||||
|
@Anno field p2: int
|
||||||
|
public method getP(): int
|
||||||
|
public method getP2(): int
|
||||||
|
method <clinit>(): void
|
||||||
|
}
|
||||||
|
|
||||||
|
@java.lang.Deprecated @kotlin.jvm.internal.KotlinPackage _DefaultPackage {
|
||||||
|
public synthetic field $kotlinPackage: kotlin.reflect.KPackage
|
||||||
|
public synthetic field $moduleName: java.lang.String
|
||||||
|
method <clinit>(): void
|
||||||
|
public @kotlin.jvm.internal.KotlinDelegatedMethod method getP(): int
|
||||||
|
public @kotlin.jvm.internal.KotlinDelegatedMethod method getP2(): int
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user