Kapt+JVM_IR: generate annotation property initializers
#KT-55490 Fixed
This commit is contained in:
+6
-3
@@ -33,6 +33,7 @@ import org.jetbrains.kotlin.psi.psiUtil.startOffsetSkippingComments
|
|||||||
import org.jetbrains.kotlin.psi2ir.pureEndOffsetOrUndefined
|
import org.jetbrains.kotlin.psi2ir.pureEndOffsetOrUndefined
|
||||||
import org.jetbrains.kotlin.psi2ir.pureStartOffsetOrUndefined
|
import org.jetbrains.kotlin.psi2ir.pureStartOffsetOrUndefined
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
|
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||||
import org.jetbrains.kotlin.resolve.hasBackingField
|
import org.jetbrains.kotlin.resolve.hasBackingField
|
||||||
|
|
||||||
class PropertyGenerator(declarationGenerator: DeclarationGenerator) : DeclarationGeneratorExtension(declarationGenerator) {
|
class PropertyGenerator(declarationGenerator: DeclarationGenerator) : DeclarationGeneratorExtension(declarationGenerator) {
|
||||||
@@ -76,8 +77,11 @@ class PropertyGenerator(declarationGenerator: DeclarationGenerator) : Declaratio
|
|||||||
): IrProperty {
|
): IrProperty {
|
||||||
val irPropertyType = propertyDescriptor.type.toIrType()
|
val irPropertyType = propertyDescriptor.type.toIrType()
|
||||||
return generateSyntheticPropertyWithInitializer(ktDeclarationContainer, propertyDescriptor, generateSyntheticAccessors) {
|
return generateSyntheticPropertyWithInitializer(ktDeclarationContainer, propertyDescriptor, generateSyntheticAccessors) {
|
||||||
if (irValueParameter == null || context.configuration.skipBodies) null
|
if (irValueParameter == null)
|
||||||
else {
|
null
|
||||||
|
else if (context.configuration.skipBodies && !DescriptorUtils.isAnnotationClass(propertyDescriptor.containingDeclaration))
|
||||||
|
null
|
||||||
|
else
|
||||||
context.irFactory.createExpressionBody(
|
context.irFactory.createExpressionBody(
|
||||||
IrGetValueImpl(
|
IrGetValueImpl(
|
||||||
ktDeclarationContainer.startOffsetSkippingComments, ktDeclarationContainer.endOffset,
|
ktDeclarationContainer.startOffsetSkippingComments, ktDeclarationContainer.endOffset,
|
||||||
@@ -86,7 +90,6 @@ class PropertyGenerator(declarationGenerator: DeclarationGenerator) : Declaratio
|
|||||||
IrStatementOrigin.INITIALIZE_PROPERTY_FROM_PARAMETER
|
IrStatementOrigin.INITIALIZE_PROPERTY_FROM_PARAMETER
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// IGNORE_BACKEND: JVM_IR
|
|
||||||
|
|
||||||
annotation class Anno1
|
annotation class Anno1
|
||||||
enum class Colors { WHITE, BLACK }
|
enum class Colors { WHITE, BLACK }
|
||||||
annotation class Anno2(
|
annotation class Anno2(
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
@kotlin.Metadata()
|
|
||||||
@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME)
|
@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME)
|
||||||
|
@kotlin.Metadata()
|
||||||
public abstract @interface Anno1 {
|
public abstract @interface Anno1 {
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////
|
////////////////////
|
||||||
|
|
||||||
|
|
||||||
@kotlin.Metadata()
|
|
||||||
@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME)
|
@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME)
|
||||||
|
@kotlin.Metadata()
|
||||||
public abstract @interface Anno2 {
|
public abstract @interface Anno2 {
|
||||||
|
|
||||||
public abstract int i() default 5;
|
public abstract int i() default 5;
|
||||||
@@ -32,8 +32,8 @@ public abstract @interface Anno2 {
|
|||||||
////////////////////
|
////////////////////
|
||||||
|
|
||||||
|
|
||||||
@kotlin.Metadata()
|
|
||||||
@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME)
|
@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME)
|
||||||
|
@kotlin.Metadata()
|
||||||
public abstract @interface Anno3 {
|
public abstract @interface Anno3 {
|
||||||
|
|
||||||
public abstract java.lang.String value();
|
public abstract java.lang.String value();
|
||||||
@@ -67,10 +67,10 @@ public enum Enum1 {
|
|||||||
////////////////////
|
////////////////////
|
||||||
|
|
||||||
|
|
||||||
@kotlin.Metadata()
|
|
||||||
@Anno3(value = "value")
|
|
||||||
@Anno2(a = @Anno1(), clazz = TestAnno.class, classes = {TestAnno.class, Anno1.class})
|
|
||||||
@Anno1()
|
@Anno1()
|
||||||
|
@Anno2(a = @Anno1(), clazz = TestAnno.class, classes = {TestAnno.class, Anno1.class})
|
||||||
|
@Anno3(value = "value")
|
||||||
|
@kotlin.Metadata()
|
||||||
public final class TestAnno {
|
public final class TestAnno {
|
||||||
|
|
||||||
public TestAnno() {
|
public TestAnno() {
|
||||||
@@ -81,12 +81,12 @@ public final class TestAnno {
|
|||||||
////////////////////
|
////////////////////
|
||||||
|
|
||||||
|
|
||||||
@kotlin.Metadata()
|
|
||||||
@Anno2(i = 6, s = "BCD", ii = {4, 5, 6}, ss = {"Z", "X"}, a = @Anno1(), color = Colors.WHITE, colors = {Colors.WHITE}, clazz = TestAnno.class, classes = {TestAnno.class, Anno1.class})
|
|
||||||
@Anno3(value = "value")
|
@Anno3(value = "value")
|
||||||
|
@Anno2(i = 6, s = "BCD", ii = {4, 5, 6}, ss = {"Z", "X"}, a = @Anno1(), color = Colors.WHITE, colors = {Colors.WHITE}, clazz = TestAnno.class, classes = {TestAnno.class, Anno1.class})
|
||||||
|
@kotlin.Metadata()
|
||||||
public final class TestAnno2 {
|
public final class TestAnno2 {
|
||||||
@org.jetbrains.annotations.NotNull()
|
|
||||||
@Anno3(value = "field")
|
@Anno3(value = "field")
|
||||||
|
@org.jetbrains.annotations.NotNull()
|
||||||
private java.lang.String b = "property initializer";
|
private java.lang.String b = "property initializer";
|
||||||
|
|
||||||
public TestAnno2() {
|
public TestAnno2() {
|
||||||
@@ -94,20 +94,20 @@ public final class TestAnno2 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Anno1()
|
@Anno1()
|
||||||
public final void a(@org.jetbrains.annotations.NotNull()
|
public final void a(@Anno3(value = "param-pam-pam")
|
||||||
@Anno3(value = "param-pam-pam")
|
@org.jetbrains.annotations.NotNull()
|
||||||
java.lang.String param) {
|
java.lang.String param) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@org.jetbrains.annotations.NotNull()
|
|
||||||
@Anno3(value = "getter")
|
@Anno3(value = "getter")
|
||||||
|
@org.jetbrains.annotations.NotNull()
|
||||||
public final java.lang.String getB() {
|
public final java.lang.String getB() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Anno3(value = "setter")
|
@Anno3(value = "setter")
|
||||||
public final void setB(@org.jetbrains.annotations.NotNull()
|
public final void setB(@Anno3(value = "setparam")
|
||||||
@Anno3(value = "setparam")
|
@org.jetbrains.annotations.NotNull()
|
||||||
java.lang.String p0) {
|
java.lang.String p0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user