diff --git a/compiler/testData/asJava/ultraLightClasses/jvmName.kt b/compiler/testData/asJava/ultraLightClasses/jvmName.kt index ec805a01279..0408a9861bd 100644 --- a/compiler/testData/asJava/ultraLightClasses/jvmName.kt +++ b/compiler/testData/asJava/ultraLightClasses/jvmName.kt @@ -5,6 +5,16 @@ class C { @JvmName("set_rwProp") set(v) {} + @get:JvmName("xyz1") + @set:JvmName("xyz2") + var xyz: String + get() = "" + set(value) {} + + @get:JvmName("hasBigArity") + val hasBigArity: Boolean + get() = true + fun getRwProp(): Int = 123 fun setRwProp(v: Int) {} diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IDELightClassGenerationSupport.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IDELightClassGenerationSupport.kt index 1f585335e80..90f2e2b74a6 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IDELightClassGenerationSupport.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IDELightClassGenerationSupport.kt @@ -55,6 +55,7 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe import org.jetbrains.kotlin.resolve.descriptorUtil.getAllSuperClassifiers import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.resolve.lazy.NoDescriptorForDeclarationException +import org.jetbrains.kotlin.resolve.source.getPsi import java.util.concurrent.ConcurrentMap class IDELightClassGenerationSupport(private val project: Project) : LightClassGenerationSupport() { @@ -102,6 +103,22 @@ class IDELightClassGenerationSupport(private val project: Project) : LightClassG return Pair(entry, descriptor) } } + + if (owner is KtPropertyAccessor) { + // We might have from the beginning just resolve the descriptor of the accessor + // But we trying to avoid analysis in case property doesn't have any relevant annotations at all + // (in case of `findAnnotation` returns null) + if (findAnnotation(owner.property, fqName) == null) return null + + val accessorDescriptor = owner.resolveToDescriptorIfAny() ?: return null + + // Just reuse the logic of use-site targeted annotation from the compiler + val annotationDescriptor = accessorDescriptor.annotations.findAnnotation(fqName) ?: return null + val entry = annotationDescriptor.source.getPsi() as? KtAnnotationEntry ?: return null + + return entry to annotationDescriptor + } + return null }