[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
+53
@@ -0,0 +1,53 @@
|
||||
val unitFun: Function0<Unit>
|
||||
field = local fun <anonymous>() {
|
||||
return Unit
|
||||
}
|
||||
|
||||
get
|
||||
|
||||
val intFun: Function0<Int>
|
||||
field = local fun <anonymous>(): Int {
|
||||
return 42
|
||||
}
|
||||
|
||||
get
|
||||
|
||||
val stringParamFun: Function1<String, Unit>
|
||||
field = local fun <anonymous>(x: String) {
|
||||
return Unit
|
||||
}
|
||||
|
||||
get
|
||||
|
||||
val listFun: Function1<List<String>, List<String>>
|
||||
field = local fun <anonymous>(l: List<String>): List<String> {
|
||||
return l
|
||||
}
|
||||
|
||||
get
|
||||
|
||||
val mutableListFun: Function1<MutableList<Double>, MutableList<Int>>
|
||||
field = local fun <no name provided>(l: MutableList<Double>): MutableList<Int> {
|
||||
return CHECK_NOT_NULL<Nothing>(arg0 = null)
|
||||
}
|
||||
|
||||
get
|
||||
|
||||
val funWithIn: Function1<Comparable<String>, Unit>
|
||||
field = local fun <no name provided>(x: Comparable<String>) {
|
||||
}
|
||||
|
||||
get
|
||||
|
||||
val extensionFun: @ExtensionFunctionType Function1<Any, Unit>
|
||||
field = local fun Any.<no name provided>() {
|
||||
}
|
||||
|
||||
get
|
||||
|
||||
val extensionWithArgFun: @ExtensionFunctionType Function2<Long, Any, Date>
|
||||
field = local fun Long.<no name provided>(x: Any): Date {
|
||||
return Date()
|
||||
}
|
||||
|
||||
get
|
||||
Reference in New Issue
Block a user