[FIR] Add equality constraint from expected type for some synthetic function calls
This fixes some cases where we infer some type variable inside one of the branches to Nothing instead of the expected type because Nothing appeared in some other branch. Specifically, we add an equality instead of a subtype constraint during completion of calls to synthetic functions for if/when, try and !!. We don't do it when the call contains a (possibly nested) elvis or is inside the RHS of an assignment. Otherwise, we would prevent some smart-casts. #KT-65882 Fixed
This commit is contained in:
committed by
Space Team
parent
eaef7122f6
commit
69a7bf7f68
+1
-1
@@ -71,7 +71,7 @@ FILE fqName:<root> fileName:/implicitCastToTypeParameter.kt
|
||||
$receiver: VALUE_PARAMETER name:<this> type:<root>.Foo<T of <root>.<get-asT>>
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-asT> <T> (): T of <root>.<get-asT>? declared in <root>'
|
||||
WHEN type=kotlin.Any? origin=IF
|
||||
WHEN type=T of <root>.<get-asT>? origin=IF
|
||||
BRANCH
|
||||
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=T of <root>.<get-asT>
|
||||
GET_VAR '<this>: <root>.Foo<T of <root>.<get-asT>> declared in <root>.<get-asT>' type=<root>.Foo<T of <root>.<get-asT>> origin=null
|
||||
|
||||
@@ -2,7 +2,7 @@ FILE fqName:<root> fileName:/kt50028.kt
|
||||
FUN name:test_1 visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun test_1 (): kotlin.String declared in <root>'
|
||||
WHEN type=kotlin.Nothing origin=WHEN
|
||||
WHEN type=kotlin.String origin=WHEN
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: BLOCK type=kotlin.Unit origin=null
|
||||
|
||||
Reference in New Issue
Block a user