FIR2IR: enhance approximation of captured types
This commit is contained in:
@@ -120,7 +120,11 @@ class Fir2IrTypeConverter(
|
||||
if (cached == null) {
|
||||
val irType = lowerType?.toIrType(typeContext) ?: run {
|
||||
capturedTypeCache[this] = errorTypeForCapturedTypeStub
|
||||
constructor.supertypes!!.first().toIrType(typeContext)
|
||||
val supertypes = constructor.supertypes!!
|
||||
val approximation = supertypes.find {
|
||||
it == (constructor.projection as? ConeKotlinTypeProjection)?.type
|
||||
} ?: supertypes.first()
|
||||
approximation.toIrType(typeContext)
|
||||
}
|
||||
capturedTypeCache[this] = irType
|
||||
irType
|
||||
|
||||
+3
-3
@@ -2,13 +2,13 @@ fun test(a: SomeJavaClass<out String>) {
|
||||
a.someFunction(hello = local fun <anonymous>(it: String?) {
|
||||
return Unit
|
||||
}
|
||||
/*-> Hello<Any?>? */)
|
||||
/*-> Hello<String>? */)
|
||||
a.plus(hello = local fun <anonymous>(it: String?) {
|
||||
return Unit
|
||||
}
|
||||
/*-> Hello<Any?>? */)
|
||||
/*-> Hello<String>? */)
|
||||
a.get(hello = local fun <anonymous>(it: String?) {
|
||||
return Unit
|
||||
}
|
||||
/*-> Hello<Any?>? */)
|
||||
/*-> Hello<String>? */)
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ FILE fqName:<root> fileName:/genericSamProjectedOut.kt
|
||||
BLOCK_BODY
|
||||
CALL 'public open fun someFunction (hello: example.Hello<A of example.SomeJavaClass?>?): kotlin.Unit declared in example.SomeJavaClass' type=kotlin.Unit origin=null
|
||||
$this: GET_VAR 'a: example.SomeJavaClass<out kotlin.String> declared in <root>.test' type=example.SomeJavaClass<out kotlin.String> origin=null
|
||||
hello: TYPE_OP type=example.Hello<kotlin.Any?>? origin=SAM_CONVERSION typeOperand=example.Hello<kotlin.Any?>?
|
||||
hello: TYPE_OP type=example.Hello<kotlin.String>? origin=SAM_CONVERSION typeOperand=example.Hello<kotlin.String>?
|
||||
FUN_EXPR type=kotlin.Function1<kotlin.String?, kotlin.Unit> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> (it:kotlin.String?) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:it index:0 type:kotlin.String?
|
||||
@@ -13,7 +13,7 @@ FILE fqName:<root> fileName:/genericSamProjectedOut.kt
|
||||
GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit
|
||||
CALL 'public open fun plus (hello: example.Hello<A of example.SomeJavaClass?>?): kotlin.Unit [operator] declared in example.SomeJavaClass' type=kotlin.Unit origin=PLUS
|
||||
$this: GET_VAR 'a: example.SomeJavaClass<out kotlin.String> declared in <root>.test' type=example.SomeJavaClass<out kotlin.String> origin=null
|
||||
hello: TYPE_OP type=example.Hello<kotlin.Any?>? origin=SAM_CONVERSION typeOperand=example.Hello<kotlin.Any?>?
|
||||
hello: TYPE_OP type=example.Hello<kotlin.String>? origin=SAM_CONVERSION typeOperand=example.Hello<kotlin.String>?
|
||||
FUN_EXPR type=kotlin.Function1<kotlin.String?, kotlin.Unit> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> (it:kotlin.String?) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:it index:0 type:kotlin.String?
|
||||
@@ -22,7 +22,7 @@ FILE fqName:<root> fileName:/genericSamProjectedOut.kt
|
||||
GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit
|
||||
CALL 'public open fun get (hello: example.Hello<A of example.SomeJavaClass?>?): kotlin.Unit [operator] declared in example.SomeJavaClass' type=kotlin.Unit origin=null
|
||||
$this: GET_VAR 'a: example.SomeJavaClass<out kotlin.String> declared in <root>.test' type=example.SomeJavaClass<out kotlin.String> origin=null
|
||||
hello: TYPE_OP type=example.Hello<kotlin.Any?>? origin=SAM_CONVERSION typeOperand=example.Hello<kotlin.Any?>?
|
||||
hello: TYPE_OP type=example.Hello<kotlin.String>? origin=SAM_CONVERSION typeOperand=example.Hello<kotlin.String>?
|
||||
FUN_EXPR type=kotlin.Function1<kotlin.String?, kotlin.Unit> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> (it:kotlin.String?) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:it index:0 type:kotlin.String?
|
||||
|
||||
Reference in New Issue
Block a user