FIR2IR: generate annotations on fake override parameters #KT-53208 Fixed
This commit is contained in:
+6
-1
@@ -556,12 +556,12 @@ class Fir2IrDeclarationStorage(
|
||||
containerSource = simpleFunction?.containerSource,
|
||||
).apply {
|
||||
metadata = FirMetadataSource.Function(function)
|
||||
convertAnnotationsForNonDeclaredMembers(function, origin)
|
||||
enterScope(this)
|
||||
bindAndDeclareParameters(
|
||||
function, irParent,
|
||||
thisReceiverOwner, isStatic = simpleFunction?.isStatic == true
|
||||
)
|
||||
convertAnnotationsForNonDeclaredMembers(function, origin)
|
||||
leaveScope(this)
|
||||
}
|
||||
}
|
||||
@@ -1595,6 +1595,11 @@ class Fir2IrDeclarationStorage(
|
||||
|| origin == IrDeclarationOrigin.FAKE_OVERRIDE
|
||||
) {
|
||||
annotationGenerator.generate(this, firAnnotationContainer)
|
||||
if (this is IrFunction && firAnnotationContainer is FirSimpleFunction) {
|
||||
valueParameters.zip(firAnnotationContainer.valueParameters).forEach { (irParameter, firParameter) ->
|
||||
annotationGenerator.generate(irParameter, firParameter, isInConstructor = false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
@@ -17817,6 +17817,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/fir/falsePositiveBoundSmartcast.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("findAnnotationOnDefaultMethodParameter.kt")
|
||||
public void testFindAnnotationOnDefaultMethodParameter() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/fir/findAnnotationOnDefaultMethodParameter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("Fir2IrClassifierStorage.kt")
|
||||
public void testFir2IrClassifierStorage() throws Exception {
|
||||
|
||||
Generated
+6
@@ -2632,6 +2632,12 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest {
|
||||
runTest("compiler/testData/ir/irText/firProblems/recursiveCapturedTypeInPropertyReference.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("reflectFindAnnotationOnDefaultMethodParameter.kt")
|
||||
public void testReflectFindAnnotationOnDefaultMethodParameter() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/firProblems/reflectFindAnnotationOnDefaultMethodParameter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("reflectGetOnNullableTypeAlias.kt")
|
||||
public void testReflectGetOnNullableTypeAlias() throws Exception {
|
||||
|
||||
+6
@@ -2632,6 +2632,12 @@ public class LightTreeFir2IrTextTestGenerated extends AbstractLightTreeFir2IrTex
|
||||
runTest("compiler/testData/ir/irText/firProblems/recursiveCapturedTypeInPropertyReference.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("reflectFindAnnotationOnDefaultMethodParameter.kt")
|
||||
public void testReflectFindAnnotationOnDefaultMethodParameter() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/firProblems/reflectFindAnnotationOnDefaultMethodParameter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("reflectGetOnNullableTypeAlias.kt")
|
||||
public void testReflectGetOnNullableTypeAlias() throws Exception {
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// WITH_REFLECT
|
||||
// FULL_JDK
|
||||
// SKIP_JDK6
|
||||
// IGNORE_BACKEND: ANDROID
|
||||
|
||||
fun box(): String {
|
||||
val impl = object : I {
|
||||
}
|
||||
|
||||
val method = impl.javaClass.getMethod("m", String::class.java)
|
||||
val parameter = method.parameters[0]
|
||||
|
||||
val size = parameter.annotations.size
|
||||
if (size == 1) return "OK"
|
||||
return "ERR: $size"
|
||||
}
|
||||
|
||||
annotation class Ann
|
||||
|
||||
interface I {
|
||||
fun m(@Ann s: String) {
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,8 @@ FILE fqName:<root> fileName:/kt43217.kt
|
||||
public open fun isEqualTo (value: @[EnhancedNullability] kotlin.Double): @[EnhancedNullability] kotlin.Any [fake_override] declared in <root>.DoubleExpression
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.ObservableValue<T of <root>.ObservableValue>
|
||||
VALUE_PARAMETER name:value index:0 type:@[EnhancedNullability] kotlin.Double
|
||||
annotations:
|
||||
NotNull(value = <null>)
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.DoubleExpression
|
||||
@@ -99,6 +101,8 @@ FILE fqName:<root> fileName:/kt43217.kt
|
||||
public open fun isEqualTo (value: @[EnhancedNullability] kotlin.Double): @[EnhancedNullability] kotlin.Any [fake_override] declared in <root>.DoubleExpression
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.ObservableValue<T of <root>.ObservableValue>
|
||||
VALUE_PARAMETER name:value index:0 type:@[EnhancedNullability] kotlin.Double
|
||||
annotations:
|
||||
NotNull(value = <null>)
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.DoubleExpression
|
||||
|
||||
Vendored
+102
@@ -0,0 +1,102 @@
|
||||
FILE fqName:<root> fileName:/reflectFindAnnotationOnDefaultMethodParameter.kt
|
||||
FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
BLOCK_BODY
|
||||
VAR name:impl type:<root>.box.<no name provided> [val]
|
||||
BLOCK type=<root>.box.<no name provided> origin=OBJECT_LITERAL
|
||||
CLASS CLASS name:<no name provided> modality:FINAL visibility:local superTypes:[<root>.I]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.box.<no name provided>
|
||||
CONSTRUCTOR visibility:private <> () returnType:<root>.box.<no name provided> [primary]
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:<no name provided> modality:FINAL visibility:local superTypes:[<root>.I]'
|
||||
FUN FAKE_OVERRIDE name:m visibility:public modality:OPEN <> ($this:<root>.I, s:kotlin.String) returnType:kotlin.Unit [fake_override]
|
||||
overridden:
|
||||
public open fun m (s: kotlin.String): kotlin.Unit declared in <root>.I
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.I
|
||||
VALUE_PARAMETER name:s index:0 type:kotlin.String
|
||||
annotations:
|
||||
Ann
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.I
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.I
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String [fake_override] declared in <root>.I
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.box.<no name provided>' type=<root>.box.<no name provided> origin=OBJECT_LITERAL
|
||||
VAR name:method type:@[FlexibleNullability] java.lang.reflect.Method? [val]
|
||||
CALL 'public open fun getMethod (p0: @[FlexibleNullability] kotlin.String?, vararg p1: @[FlexibleNullability] java.lang.Class<*>?): @[FlexibleNullability] java.lang.reflect.Method? declared in java.lang.Class' type=@[FlexibleNullability] java.lang.reflect.Method? origin=null
|
||||
$this: CALL 'public final fun <get-javaClass> <T> (): java.lang.Class<T of kotlin.jvm.JvmClassMappingKt.<get-javaClass>> [inline] declared in kotlin.jvm.JvmClassMappingKt' type=java.lang.Class<<root>.box.<no name provided>> origin=GET_PROPERTY
|
||||
<T>: <root>.box.<no name provided>
|
||||
$receiver: GET_VAR 'val impl: <root>.box.<no name provided> [val] declared in <root>.box' type=<root>.box.<no name provided> origin=null
|
||||
p0: CONST String type=kotlin.String value="m"
|
||||
p1: VARARG type=@[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] java.lang.Class<*>?>? varargElementType=@[FlexibleNullability] java.lang.Class<*>?
|
||||
CALL 'public final fun <get-java> <T> (): java.lang.Class<T of kotlin.jvm.JvmClassMappingKt.<get-java>> declared in kotlin.jvm.JvmClassMappingKt' type=java.lang.Class<kotlin.String> origin=GET_PROPERTY
|
||||
<T>: kotlin.String
|
||||
$receiver: CLASS_REFERENCE 'CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:String modality:FINAL visibility:public superTypes:[kotlin.Comparable<kotlin.String>; kotlin.CharSequence; java.io.Serializable]' type=kotlin.reflect.KClass<kotlin.String>
|
||||
VAR name:parameter type:@[FlexibleNullability] java.lang.reflect.Parameter? [val]
|
||||
CALL 'public final fun get (index: kotlin.Int): T of kotlin.Array [operator] declared in kotlin.Array' type=@[FlexibleNullability] java.lang.reflect.Parameter? origin=null
|
||||
$this: CALL 'public open fun getParameters (): @[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] java.lang.reflect.Parameter?>? [fake_override] declared in java.lang.reflect.Method' type=@[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] java.lang.reflect.Parameter?>? origin=GET_PROPERTY
|
||||
$this: GET_VAR 'val method: @[FlexibleNullability] java.lang.reflect.Method? [val] declared in <root>.box' type=@[FlexibleNullability] java.lang.reflect.Method? origin=null
|
||||
index: CONST Int type=kotlin.Int value=0
|
||||
VAR name:size type:kotlin.Int [val]
|
||||
CALL 'public final fun <get-size> (): kotlin.Int declared in kotlin.Array' type=kotlin.Int origin=GET_PROPERTY
|
||||
$this: CALL 'public open fun getAnnotations (): @[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] kotlin.Annotation?>? declared in java.lang.reflect.Parameter' type=@[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] kotlin.Annotation?>? origin=GET_PROPERTY
|
||||
$this: GET_VAR 'val parameter: @[FlexibleNullability] java.lang.reflect.Parameter? [val] declared in <root>.box' type=@[FlexibleNullability] java.lang.reflect.Parameter? origin=null
|
||||
WHEN type=kotlin.Unit origin=IF
|
||||
BRANCH
|
||||
if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: GET_VAR 'val size: kotlin.Int [val] declared in <root>.box' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=1
|
||||
then: RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in <root>'
|
||||
CONST String type=kotlin.String value="OK"
|
||||
RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in <root>'
|
||||
STRING_CONCATENATION type=kotlin.String
|
||||
CONST String type=kotlin.String value="ERR: "
|
||||
GET_VAR 'val size: kotlin.Int [val] declared in <root>.box' type=kotlin.Int origin=null
|
||||
CLASS ANNOTATION_CLASS name:Ann modality:OPEN visibility:public superTypes:[kotlin.Annotation]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Ann
|
||||
CONSTRUCTOR visibility:public <> () returnType:<root>.Ann [primary]
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ANNOTATION_CLASS name:Ann modality:OPEN visibility:public superTypes:[kotlin.Annotation]'
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.Annotation
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.Annotation
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String [fake_override] declared in kotlin.Annotation
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
CLASS INTERFACE name:I modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.I
|
||||
FUN name:m visibility:public modality:OPEN <> ($this:<root>.I, s:kotlin.String) returnType:kotlin.Unit
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.I
|
||||
VALUE_PARAMETER name:s index:0 type:kotlin.String
|
||||
annotations:
|
||||
Ann
|
||||
BLOCK_BODY
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
Vendored
+36
@@ -0,0 +1,36 @@
|
||||
fun box(): String {
|
||||
val impl: <no name provided> = { // BLOCK
|
||||
local class <no name provided> : I {
|
||||
private constructor() /* primary */ {
|
||||
super/*Any*/()
|
||||
/* <init>() */
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
<no name provided>()
|
||||
}
|
||||
val method: @FlexibleNullability Method? = impl.<get-javaClass><<no name provided>>().getMethod(p0 = "m", p1 = [String::class.<get-java><String>()])
|
||||
val parameter: @FlexibleNullability Parameter? = method.getParameters().get(index = 0)
|
||||
val size: Int = parameter.getAnnotations().<get-size>()
|
||||
when {
|
||||
EQEQ(arg0 = size, arg1 = 1) -> return "OK"
|
||||
}
|
||||
return "ERR: " + size
|
||||
}
|
||||
|
||||
open annotation class Ann : Annotation {
|
||||
constructor() /* primary */ {
|
||||
super/*Any*/()
|
||||
/* <init>() */
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
interface I {
|
||||
fun m(@Ann s: String) {
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
+108
@@ -0,0 +1,108 @@
|
||||
FILE fqName:<root> fileName:/reflectFindAnnotationOnDefaultMethodParameter.kt
|
||||
FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
BLOCK_BODY
|
||||
VAR name:impl type:<root>.box.<no name provided> [val]
|
||||
BLOCK type=<root>.box.<no name provided> origin=OBJECT_LITERAL
|
||||
CLASS CLASS name:<no name provided> modality:FINAL visibility:local superTypes:[<root>.I]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.box.<no name provided>
|
||||
CONSTRUCTOR visibility:public <> () returnType:<root>.box.<no name provided> [primary]
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:<no name provided> modality:FINAL visibility:local superTypes:[<root>.I]'
|
||||
FUN FAKE_OVERRIDE name:m visibility:public modality:OPEN <> ($this:<root>.I, s:kotlin.String) returnType:kotlin.Unit [fake_override]
|
||||
overridden:
|
||||
public open fun m (s: kotlin.String): kotlin.Unit declared in <root>.I
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.I
|
||||
VALUE_PARAMETER name:s index:0 type:kotlin.String
|
||||
annotations:
|
||||
Ann
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.I
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.I
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String [fake_override] declared in <root>.I
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.box.<no name provided>' type=<root>.box.<no name provided> origin=OBJECT_LITERAL
|
||||
VAR name:method type:@[FlexibleNullability] java.lang.reflect.Method? [val]
|
||||
CALL 'public open fun getMethod (p0: @[FlexibleNullability] kotlin.String?, vararg p1: @[FlexibleNullability] java.lang.Class<*>?): @[FlexibleNullability] java.lang.reflect.Method? declared in java.lang.Class' type=@[FlexibleNullability] java.lang.reflect.Method? origin=null
|
||||
$this: CALL 'public final fun <get-javaClass> <T> (): java.lang.Class<T of kotlin.jvm.JvmClassMappingKt.<get-javaClass>> [inline] declared in kotlin.jvm.JvmClassMappingKt' type=java.lang.Class<<root>.box.<no name provided>> origin=GET_PROPERTY
|
||||
<T>: <root>.box.<no name provided>
|
||||
$receiver: GET_VAR 'val impl: <root>.box.<no name provided> [val] declared in <root>.box' type=<root>.box.<no name provided> origin=null
|
||||
p0: CONST String type=kotlin.String value="m"
|
||||
p1: VARARG type=kotlin.Array<out @[FlexibleNullability] java.lang.Class<*>?>? varargElementType=@[FlexibleNullability] java.lang.Class<*>?
|
||||
CALL 'public final fun <get-java> <T> (): java.lang.Class<T of kotlin.jvm.JvmClassMappingKt.<get-java>> declared in kotlin.jvm.JvmClassMappingKt' type=java.lang.Class<kotlin.String> origin=GET_PROPERTY
|
||||
<T>: kotlin.String
|
||||
$receiver: CLASS_REFERENCE 'CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:String modality:FINAL visibility:public superTypes:[kotlin.Comparable<kotlin.String>; kotlin.CharSequence; java.io.Serializable]' type=kotlin.reflect.KClass<kotlin.String>
|
||||
VAR name:parameter type:@[FlexibleNullability] java.lang.reflect.Parameter? [val]
|
||||
CALL 'public final fun get (index: kotlin.Int): T of kotlin.Array [operator] declared in kotlin.Array' type=@[FlexibleNullability] java.lang.reflect.Parameter? origin=GET_ARRAY_ELEMENT
|
||||
$this: TYPE_OP type=kotlin.Array<@[FlexibleNullability] java.lang.reflect.Parameter?> origin=IMPLICIT_CAST typeOperand=kotlin.Array<@[FlexibleNullability] java.lang.reflect.Parameter?>
|
||||
TYPE_OP type=kotlin.Array<out @[FlexibleNullability] java.lang.reflect.Parameter?> origin=IMPLICIT_NOTNULL typeOperand=kotlin.Array<out @[FlexibleNullability] java.lang.reflect.Parameter?>
|
||||
CALL 'public open fun getParameters (): @[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] java.lang.reflect.Parameter?>? [fake_override] declared in java.lang.reflect.Method' type=@[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] java.lang.reflect.Parameter?>? origin=GET_PROPERTY
|
||||
$this: TYPE_OP type=java.lang.reflect.Method origin=IMPLICIT_NOTNULL typeOperand=java.lang.reflect.Method
|
||||
GET_VAR 'val method: @[FlexibleNullability] java.lang.reflect.Method? [val] declared in <root>.box' type=@[FlexibleNullability] java.lang.reflect.Method? origin=null
|
||||
index: CONST Int type=kotlin.Int value=0
|
||||
VAR name:size type:kotlin.Int [val]
|
||||
CALL 'public final fun <get-size> (): kotlin.Int declared in kotlin.Array' type=kotlin.Int origin=GET_PROPERTY
|
||||
$this: TYPE_OP type=kotlin.Array<@[FlexibleNullability] kotlin.Annotation?> origin=IMPLICIT_CAST typeOperand=kotlin.Array<@[FlexibleNullability] kotlin.Annotation?>
|
||||
TYPE_OP type=kotlin.Array<out @[FlexibleNullability] kotlin.Annotation?> origin=IMPLICIT_NOTNULL typeOperand=kotlin.Array<out @[FlexibleNullability] kotlin.Annotation?>
|
||||
CALL 'public open fun getAnnotations (): @[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] kotlin.Annotation?>? declared in java.lang.reflect.Parameter' type=@[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] kotlin.Annotation?>? origin=GET_PROPERTY
|
||||
$this: TYPE_OP type=java.lang.reflect.Parameter origin=IMPLICIT_NOTNULL typeOperand=java.lang.reflect.Parameter
|
||||
GET_VAR 'val parameter: @[FlexibleNullability] java.lang.reflect.Parameter? [val] declared in <root>.box' type=@[FlexibleNullability] java.lang.reflect.Parameter? origin=null
|
||||
WHEN type=kotlin.Unit origin=IF
|
||||
BRANCH
|
||||
if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: GET_VAR 'val size: kotlin.Int [val] declared in <root>.box' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=1
|
||||
then: RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in <root>'
|
||||
CONST String type=kotlin.String value="OK"
|
||||
RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in <root>'
|
||||
STRING_CONCATENATION type=kotlin.String
|
||||
CONST String type=kotlin.String value="ERR: "
|
||||
GET_VAR 'val size: kotlin.Int [val] declared in <root>.box' type=kotlin.Int origin=null
|
||||
CLASS ANNOTATION_CLASS name:Ann modality:OPEN visibility:public superTypes:[kotlin.Annotation]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Ann
|
||||
CONSTRUCTOR visibility:public <> () returnType:<root>.Ann [primary]
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ANNOTATION_CLASS name:Ann modality:OPEN visibility:public superTypes:[kotlin.Annotation]'
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.Annotation
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.Annotation
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String [fake_override] declared in kotlin.Annotation
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
CLASS INTERFACE name:I modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.I
|
||||
FUN name:m visibility:public modality:OPEN <> ($this:<root>.I, s:kotlin.String) returnType:kotlin.Unit
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.I
|
||||
VALUE_PARAMETER name:s index:0 type:kotlin.String
|
||||
annotations:
|
||||
Ann
|
||||
BLOCK_BODY
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// SKIP_KLIB_TEST
|
||||
// WITH_REFLECT
|
||||
// FULL_JDK
|
||||
|
||||
fun box(): String {
|
||||
val impl = object : I {
|
||||
}
|
||||
|
||||
val method = impl.javaClass.getMethod("m", String::class.java)
|
||||
val parameter = method.parameters[0]
|
||||
|
||||
val size = parameter.annotations.size
|
||||
if (size == 1) return "OK"
|
||||
return "ERR: $size"
|
||||
}
|
||||
|
||||
annotation class Ann
|
||||
|
||||
interface I {
|
||||
fun m(@Ann s: String) {
|
||||
}
|
||||
}
|
||||
Vendored
+36
@@ -0,0 +1,36 @@
|
||||
fun box(): String {
|
||||
val impl: <no name provided> = { // BLOCK
|
||||
local class <no name provided> : I {
|
||||
constructor() /* primary */ {
|
||||
super/*Any*/()
|
||||
/* <init>() */
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
<no name provided>()
|
||||
}
|
||||
val method: @FlexibleNullability Method? = impl.<get-javaClass><<no name provided>>().getMethod(p0 = "m", p1 = [String::class.<get-java><String>()])
|
||||
val parameter: @FlexibleNullability Parameter? = method /*!! Method */.getParameters() /*!! Array<out @FlexibleNullability Parameter?> */ /*as Array<@FlexibleNullability Parameter?> */.get(index = 0)
|
||||
val size: Int = parameter /*!! Parameter */.getAnnotations() /*!! Array<out @FlexibleNullability Annotation?> */ /*as Array<@FlexibleNullability Annotation?> */.<get-size>()
|
||||
when {
|
||||
EQEQ(arg0 = size, arg1 = 1) -> return "OK"
|
||||
}
|
||||
return "ERR: " + size
|
||||
}
|
||||
|
||||
open annotation class Ann : Annotation {
|
||||
constructor() /* primary */ {
|
||||
super/*Any*/()
|
||||
/* <init>() */
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
interface I {
|
||||
fun m(@Ann s: String) {
|
||||
}
|
||||
|
||||
}
|
||||
+6
@@ -17817,6 +17817,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/fir/falsePositiveBoundSmartcast.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("findAnnotationOnDefaultMethodParameter.kt")
|
||||
public void testFindAnnotationOnDefaultMethodParameter() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/fir/findAnnotationOnDefaultMethodParameter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("Fir2IrClassifierStorage.kt")
|
||||
public void testFir2IrClassifierStorage() throws Exception {
|
||||
|
||||
Generated
+6
@@ -2632,6 +2632,12 @@ public class IrTextTestGenerated extends AbstractIrTextTest {
|
||||
runTest("compiler/testData/ir/irText/firProblems/recursiveCapturedTypeInPropertyReference.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("reflectFindAnnotationOnDefaultMethodParameter.kt")
|
||||
public void testReflectFindAnnotationOnDefaultMethodParameter() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/firProblems/reflectFindAnnotationOnDefaultMethodParameter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("reflectGetOnNullableTypeAlias.kt")
|
||||
public void testReflectGetOnNullableTypeAlias() throws Exception {
|
||||
|
||||
@@ -1932,6 +1932,11 @@ public class KlibTextTestCaseGenerated extends AbstractKlibTextTestCase {
|
||||
runTest("compiler/testData/ir/irText/firProblems/recursiveCapturedTypeInPropertyReference.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("reflectFindAnnotationOnDefaultMethodParameter.kt")
|
||||
public void testReflectFindAnnotationOnDefaultMethodParameter() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/firProblems/reflectFindAnnotationOnDefaultMethodParameter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("reflectGetOnNullableTypeAlias.kt")
|
||||
public void testReflectGetOnNullableTypeAlias() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/firProblems/reflectGetOnNullableTypeAlias.kt");
|
||||
|
||||
Reference in New Issue
Block a user