[ULC] Fix invalid annotation resolve for KtUltraLightParameterForSetterParameter

This commit is contained in:
Igor Yakovlev
2020-07-20 21:57:58 +03:00
parent db6aa9140d
commit dbb4337ac4
7 changed files with 55 additions and 6 deletions
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.psi.KtParameter
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.codegen.AsmUtil.LABELED_THIS_PARAMETER
import org.jetbrains.kotlin.codegen.AsmUtil.RECEIVER_PARAMETER_NAME
import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget
internal class KtUltraLightSuspendContinuationParameter(
private val ktFunction: KtFunction,
@@ -144,7 +145,7 @@ internal abstract class KtAbstractUltraLightParameterForDeclaration(
) : KtUltraLightParameter(name, kotlinOrigin, support, method) {
protected fun tryGetContainingDescriptor(): CallableDescriptor? =
containingDeclaration.resolve() as? CallableMemberDescriptor
containingDeclaration.resolve() as? CallableDescriptor
protected abstract fun tryGetKotlinType(): KotlinType?
@@ -189,11 +190,16 @@ internal class KtUltraLightParameterForSetterParameter(
override fun tryGetKotlinType(): KotlinType? = property.getKotlinType()
override val givenAnnotations: List<KtLightAbstractAnnotation>?
get() = (property.resolve() as? PropertyDescriptor)
?.setter
?.valueParameters
?.firstOrNull()
?.obtainLightAnnotations(support, this)
get() = property.annotationEntries.filter {
it.useSiteTarget?.getAnnotationUseSiteTarget() == AnnotationUseSiteTarget.SETTER_PARAMETER
}.map { entry ->
KtLightAnnotationForSourceEntry(
lazyQualifiedName = { entry.analyzeAnnotation()?.fqName?.asString() },
kotlinOrigin = entry,
parent = this,
lazyClsDelegate = null
)
}
override fun isVarArgs(): Boolean = false
}
@@ -0,0 +1,14 @@
public final class Test /* Test*/ {
@MyAnnotation5()
private java.lang.String bar;
@MyAnnotation()
@org.jetbrains.annotations.NotNull()
public final java.lang.String getBar();// getBar()
@MyAnnotation2()
public final void setBar(@MyAnnotation3() @org.jetbrains.annotations.NotNull() java.lang.String);// setBar(java.lang.String)
public Test(@MyAnnotation6() @org.jetbrains.annotations.NotNull() java.lang.String);// .ctor(java.lang.String)
}
@@ -0,0 +1,9 @@
// Test
annotation class MyAnnotation
annotation class MyAnnotation2
annotation class MyAnnotation3
annotation class MyAnnotation4
annotation class MyAnnotation5
annotation class MyAnnotation6
class Test(@get:MyAnnotation @set:MyAnnotation2 @setparam:MyAnnotation3 @property:MyAnnotation4 @field:MyAnnotation5 @param:MyAnnotation6 var bar: String)
@@ -38,6 +38,11 @@ public class CompilerLightClassTestGenerated extends AbstractCompilerLightClassT
runTest("compiler/testData/asJava/lightClasses/AnnotatedParameterInInnerClassConstructor.kt");
}
@TestMetadata("AnnotatedPropertyWithSites.kt")
public void testAnnotatedPropertyWithSites() throws Exception {
runTest("compiler/testData/asJava/lightClasses/AnnotatedPropertyWithSites.kt");
}
@TestMetadata("AnnotationClass.kt")
public void testAnnotationClass() throws Exception {
runTest("compiler/testData/asJava/lightClasses/AnnotationClass.kt");
@@ -38,6 +38,11 @@ public class UltraLightClassSanityTestGenerated extends AbstractUltraLightClassS
runTest("compiler/testData/asJava/lightClasses/AnnotatedParameterInInnerClassConstructor.kt");
}
@TestMetadata("AnnotatedPropertyWithSites.kt")
public void testAnnotatedPropertyWithSites() throws Exception {
runTest("compiler/testData/asJava/lightClasses/AnnotatedPropertyWithSites.kt");
}
@TestMetadata("AnnotationClass.kt")
public void testAnnotationClass() throws Exception {
runTest("compiler/testData/asJava/lightClasses/AnnotationClass.kt");
@@ -38,6 +38,11 @@ public class IdeCompiledLightClassTestGenerated extends AbstractIdeCompiledLight
runTest("compiler/testData/asJava/lightClasses/AnnotatedParameterInInnerClassConstructor.kt");
}
@TestMetadata("AnnotatedPropertyWithSites.kt")
public void testAnnotatedPropertyWithSites() throws Exception {
runTest("compiler/testData/asJava/lightClasses/AnnotatedPropertyWithSites.kt");
}
@TestMetadata("AnnotationClass.kt")
public void testAnnotationClass() throws Exception {
runTest("compiler/testData/asJava/lightClasses/AnnotationClass.kt");
@@ -38,6 +38,11 @@ public class IdeLightClassTestGenerated extends AbstractIdeLightClassTest {
runTest("compiler/testData/asJava/lightClasses/AnnotatedParameterInInnerClassConstructor.kt");
}
@TestMetadata("AnnotatedPropertyWithSites.kt")
public void testAnnotatedPropertyWithSites() throws Exception {
runTest("compiler/testData/asJava/lightClasses/AnnotatedPropertyWithSites.kt");
}
@TestMetadata("AnnotationClass.kt")
public void testAnnotationClass() throws Exception {
runTest("compiler/testData/asJava/lightClasses/AnnotationClass.kt");