[FIR2IR] Add conversion of value parameter annotations

This commit is contained in:
Mikhail Glukhikh
2020-05-07 18:22:28 +03:00
parent 76f6e27e37
commit b271b6d7a8
12 changed files with 38 additions and 5 deletions
@@ -100,6 +100,9 @@ internal class ClassMemberGenerator(
}
for ((valueParameter, firValueParameter) in valueParameters.zip(firFunction.valueParameters)) {
valueParameter.setDefaultValue(firValueParameter)
valueParameter.annotations = firValueParameter.annotations.mapNotNull {
it.accept(visitor, null) as? IrConstructorCall
}
}
annotations = firFunction.annotations.mapNotNull {
it.accept(visitor, null) as? IrConstructorCall
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// TARGET_BACKEND: JVM
// WITH_RUNTIME
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// SKIP_JDK6
// TARGET_BACKEND: JVM
// FULL_JDK
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// IGNORE_BACKEND: JS_IR
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS, NATIVE
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// IGNORE_BACKEND: JS_IR
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS, NATIVE
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// IGNORE_BACKEND: JS_IR
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS, NATIVE
@@ -19,6 +19,8 @@ FILE fqName:<root> fileName:/primaryConstructorParameterWithAnnotations.kt
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Test
CONSTRUCTOR visibility:public <> (x:kotlin.Int) returnType:<root>.Test [primary]
VALUE_PARAMETER name:x index:0 type:kotlin.Int
annotations:
Ann
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test modality:FINAL visibility:public superTypes:[kotlin.Any]'
@@ -31,7 +31,12 @@ FILE fqName:<root> fileName:/propertyAccessorsFromClassHeaderWithAnnotations.kt
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.C
CONSTRUCTOR visibility:public <> (x:kotlin.Int, y:kotlin.Int) returnType:<root>.C [primary]
VALUE_PARAMETER name:x index:0 type:kotlin.Int
annotations:
A(x = 'C.x.get')
VALUE_PARAMETER name:y index:1 type:kotlin.Int
annotations:
A(x = 'C.y.get')
A(x = 'C.y.set')
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any]'
@@ -36,6 +36,8 @@ FILE fqName:<root> fileName:/propertySetterParameterWithAnnotations.kt
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.C
CONSTRUCTOR visibility:public <> (p:kotlin.Int) returnType:<root>.C [primary]
VALUE_PARAMETER name:p index:0 type:kotlin.Int
annotations:
AnnParam
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any]'
@@ -29,11 +29,15 @@ FILE fqName:<root> fileName:/valueParametersWithAnnotations.kt
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN name:testFun visibility:public modality:FINAL <> (x:kotlin.Int) returnType:kotlin.Unit
VALUE_PARAMETER name:x index:0 type:kotlin.Int
annotations:
TestAnn(x = 'testFun.x')
BLOCK_BODY
CLASS CLASS name:TestClassConstructor1 modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.TestClassConstructor1
CONSTRUCTOR visibility:public <> (x:kotlin.Int) returnType:<root>.TestClassConstructor1 [primary]
VALUE_PARAMETER name:x index:0 type:kotlin.Int
annotations:
TestAnn(x = 'TestClassConstructor1.x')
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:TestClassConstructor1 modality:FINAL visibility:public superTypes:[kotlin.Any]'
@@ -67,21 +67,33 @@ FILE fqName:<root> fileName:/signedToUnsignedConversions_test.kt
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:UINT_CONST type:kotlin.UInt visibility:public [final,static]' type=kotlin.UInt origin=null
FUN name:takeUByte visibility:public modality:FINAL <> (u:kotlin.UByte) returnType:kotlin.Unit
VALUE_PARAMETER name:u index:0 type:kotlin.UByte
annotations:
ImplicitIntegerCoercion
BLOCK_BODY
FUN name:takeUShort visibility:public modality:FINAL <> (u:kotlin.UShort) returnType:kotlin.Unit
VALUE_PARAMETER name:u index:0 type:kotlin.UShort
annotations:
ImplicitIntegerCoercion
BLOCK_BODY
FUN name:takeUInt visibility:public modality:FINAL <> (u:kotlin.UInt) returnType:kotlin.Unit
VALUE_PARAMETER name:u index:0 type:kotlin.UInt
annotations:
ImplicitIntegerCoercion
BLOCK_BODY
FUN name:takeULong visibility:public modality:FINAL <> (u:kotlin.ULong) returnType:kotlin.Unit
VALUE_PARAMETER name:u index:0 type:kotlin.ULong
annotations:
ImplicitIntegerCoercion
BLOCK_BODY
FUN name:takeUBytes visibility:public modality:FINAL <> (u:kotlin.UByteArray) returnType:kotlin.Unit
VALUE_PARAMETER name:u index:0 type:kotlin.UByteArray varargElementType:kotlin.UByte [vararg]
annotations:
ImplicitIntegerCoercion
BLOCK_BODY
FUN name:takeLong visibility:public modality:FINAL <> (l:kotlin.Long) returnType:kotlin.Unit
VALUE_PARAMETER name:l index:0 type:kotlin.Long
annotations:
ImplicitIntegerCoercion
BLOCK_BODY
FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
@@ -4,6 +4,8 @@ FILE fqName:<root> fileName:/castsInsideCoroutineInference.kt
OptIn(markerClass = CLASS_REFERENCE 'CLASS IR_EXTERNAL_DECLARATION_STUB ANNOTATION_CLASS name:ExperimentalTypeInference modality:FINAL visibility:public superTypes:[kotlin.Annotation]' type=kotlin.reflect.KClass<kotlin.experimental.ExperimentalTypeInference>)
TYPE_PARAMETER name:R index:0 variance: superTypes:[kotlin.Any?]
VALUE_PARAMETER name:block index:0 type:kotlin.coroutines.SuspendFunction2<<root>.CoroutineScope, <root>.FlowCollector<R of <root>.scopedFlow>, kotlin.Unit>
annotations:
BuilderInference
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun scopedFlow <R> (block: kotlin.coroutines.SuspendFunction2<<root>.CoroutineScope, <root>.FlowCollector<R of <root>.scopedFlow>, kotlin.Unit>): <root>.Flow<R of <root>.scopedFlow> declared in <root>'
CALL 'public final fun flow <T> (block: kotlin.coroutines.SuspendFunction1<<root>.FlowCollector<T of <root>.flow>, kotlin.Unit>): <root>.Flow<T of <root>.flow> declared in <root>' type=<root>.Flow<R of <root>.scopedFlow> origin=null
@@ -54,6 +56,8 @@ FILE fqName:<root> fileName:/castsInsideCoroutineInference.kt
OptIn(markerClass = CLASS_REFERENCE 'CLASS IR_EXTERNAL_DECLARATION_STUB ANNOTATION_CLASS name:ExperimentalTypeInference modality:FINAL visibility:public superTypes:[kotlin.Annotation]' type=kotlin.reflect.KClass<kotlin.experimental.ExperimentalTypeInference>)
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
VALUE_PARAMETER name:block index:0 type:kotlin.coroutines.SuspendFunction1<<root>.FlowCollector<T of <root>.unsafeFlow>, kotlin.Unit> [crossinline]
annotations:
BuilderInference
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun unsafeFlow <T> (block: kotlin.coroutines.SuspendFunction1<<root>.FlowCollector<T of <root>.unsafeFlow>, kotlin.Unit>): <root>.Flow<T of <root>.unsafeFlow> [inline] declared in <root>'
CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null
@@ -186,6 +190,8 @@ FILE fqName:<root> fileName:/castsInsideCoroutineInference.kt
OptIn(markerClass = CLASS_REFERENCE 'CLASS IR_EXTERNAL_DECLARATION_STUB ANNOTATION_CLASS name:ExperimentalTypeInference modality:FINAL visibility:public superTypes:[kotlin.Annotation]' type=kotlin.reflect.KClass<kotlin.experimental.ExperimentalTypeInference>)
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
VALUE_PARAMETER name:block index:0 type:kotlin.coroutines.SuspendFunction1<<root>.FlowCollector<T of <root>.flow>, kotlin.Unit>
annotations:
BuilderInference
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun flow <T> (block: kotlin.coroutines.SuspendFunction1<<root>.FlowCollector<T of <root>.flow>, kotlin.Unit>): <root>.Flow<T of <root>.flow> declared in <root>'
CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null
@@ -194,6 +200,8 @@ FILE fqName:<root> fileName:/castsInsideCoroutineInference.kt
OptIn(markerClass = CLASS_REFERENCE 'CLASS IR_EXTERNAL_DECLARATION_STUB ANNOTATION_CLASS name:ExperimentalTypeInference modality:FINAL visibility:public superTypes:[kotlin.Annotation]' type=kotlin.reflect.KClass<kotlin.experimental.ExperimentalTypeInference>)
TYPE_PARAMETER name:R index:0 variance: superTypes:[kotlin.Any?]
VALUE_PARAMETER name:block index:0 type:kotlin.coroutines.SuspendFunction1<<root>.CoroutineScope, R of <root>.flowScope>
annotations:
BuilderInference
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun flowScope <R> (block: kotlin.coroutines.SuspendFunction1<<root>.CoroutineScope, R of <root>.flowScope>): R of <root>.flowScope [suspend] declared in <root>'
CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null
@@ -301,6 +309,8 @@ FILE fqName:<root> fileName:/castsInsideCoroutineInference.kt
TYPE_PARAMETER name:E index:0 variance: superTypes:[kotlin.Any?]
$receiver: VALUE_PARAMETER name:<this> type:<root>.CoroutineScope
VALUE_PARAMETER name:block index:0 type:kotlin.coroutines.SuspendFunction1<<root>.ProducerScope<E of <root>.produce>, kotlin.Unit>
annotations:
BuilderInference
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun produce <E> (block: kotlin.coroutines.SuspendFunction1<<root>.ProducerScope<E of <root>.produce>, kotlin.Unit>): <root>.ReceiveChannel<E of <root>.produce> declared in <root>'
CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null