Fir2Ir, JVM IR: support flexible Array types loaded from Java
We don't have true flexible types in the IR, but we approximate it with internal type annotations, such as FlexibleNullability, FlexibleMutability, RawType. These annotations are then handled specially in JvmIrTypeSystemContext, which can construct a fake flexible type so that type checker on IR types would behave exactly as on frontend types. As shown in KT-63441, one instance of flexible types where flexibility was lost during conversion to IR is Java array/vararg types. It's necessary to support it so that IR fake overrides could be constructed correctly, because IR fake override checker requires parameter types to be equal. So this change introduces another internal type annotation, FlexibleArrayElementVariance, which is only applicable to types with classifier kotlin/Array, and which signifies that the annotated type `Array<X>` should rather be seen as `Array<X>..Array<out X>`. #KT-63441 Fixed #KT-63446 Fixed
This commit is contained in:
committed by
Space Team
parent
e98902ce74
commit
ee8d42532b
@@ -1,9 +1,9 @@
|
||||
FILE fqName:<root> fileName:/jdkClassSyntheticProperty.kt
|
||||
PROPERTY name:test visibility:public modality:FINAL [val]
|
||||
FUN name:<get-test> visibility:public modality:FINAL <> ($receiver:java.lang.Class<*>) returnType:@[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] java.lang.reflect.Field?>?
|
||||
FUN name:<get-test> visibility:public modality:FINAL <> ($receiver:java.lang.Class<*>) returnType:@[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] java.lang.reflect.Field?>?
|
||||
correspondingProperty: PROPERTY name:test visibility:public modality:FINAL [val]
|
||||
$receiver: VALUE_PARAMETER name:<this> type:java.lang.Class<*>
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-test> (): @[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] java.lang.reflect.Field?>? declared in <root>'
|
||||
CALL 'public open fun getDeclaredFields (): @[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] java.lang.reflect.Field?>? declared in java.lang.Class' type=@[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] java.lang.reflect.Field?>? origin=GET_PROPERTY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-test> (): @[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] java.lang.reflect.Field?>? declared in <root>'
|
||||
CALL 'public open fun getDeclaredFields (): @[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] java.lang.reflect.Field?>? declared in java.lang.Class' type=@[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] java.lang.reflect.Field?>? origin=GET_PROPERTY
|
||||
$this: GET_VAR '<this>: java.lang.Class<*> declared in <root>.<get-test>' type=java.lang.Class<*> origin=null
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
val Class<*>.test: @FlexibleNullability Array<out @FlexibleNullability Field?>?
|
||||
get(): @FlexibleNullability Array<out @FlexibleNullability Field?>? {
|
||||
val Class<*>.test: @FlexibleNullability @FlexibleArrayElementVariance Array<out @FlexibleNullability Field?>?
|
||||
get(): @FlexibleNullability @FlexibleArrayElementVariance Array<out @FlexibleNullability Field?>? {
|
||||
return <this>.getDeclaredFields()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user