KAPT+IR: Properly process annotations and backing field annotations

This commit is contained in:
Mikhael Bogdanov
2022-02-16 10:37:48 +01:00
parent ea2bf3c867
commit f05c72d48f
14 changed files with 486 additions and 12 deletions
@@ -52,7 +52,7 @@ abstract class IrBasedDeclarationDescriptor<T : IrDeclaration>(val owner: T) : D
symbol.owner.valueParameters.map { it.name to getValueArgument(it.index) }
.filter { it.second != null }
.associate { it.first to it.second!!.toConstantValue() },
/*TODO*/ SourceElement.NO_SOURCE
source
)
}
@@ -5,12 +5,15 @@
package org.jetbrains.kotlin.ir.expressions
import org.jetbrains.kotlin.descriptors.SourceElement
import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
abstract class IrConstructorCall : IrFunctionAccessExpression() {
abstract override val symbol: IrConstructorSymbol
abstract val source: SourceElement
abstract val constructorTypeArgumentsCount: Int
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
@@ -5,6 +5,7 @@
package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.descriptors.SourceElement
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
@@ -23,6 +24,7 @@ class IrConstructorCallImpl(
override val constructorTypeArgumentsCount: Int,
valueArgumentsCount: Int,
override val origin: IrStatementOrigin? = null,
override val source: SourceElement = SourceElement.NO_SOURCE
) : IrConstructorCall() {
override val typeArgumentsByIndex: Array<IrType?> = arrayOfNulls(typeArgumentsCount)
@@ -170,7 +170,8 @@ abstract class ConstantValueGenerator(
primaryConstructorSymbol,
valueArgumentsCount = primaryConstructorDescriptor.valueParameters.size,
typeArgumentsCount = annotationClassDescriptor.declaredTypeParameters.size,
constructorTypeArgumentsCount = 0
constructorTypeArgumentsCount = 0,
source = annotationDescriptor.source
)
val substitutor = TypeConstructorSubstitution.create(annotationType).buildSubstitutor()