[NI] Wait for proper constraints to fix type for callable reference
If expected type is a type variable, then we'll wait for proper constraints, but previously we resolved callable reference as it didn't have expected type at all, because type variable isn't a functional type
Consider the following example:
fun foo(i: Int) {}
fun foo(s: String) {}
fun <T> id(x: T): T = x
fun test() {
val x1: (Int) -> Unit = id(id(::foo))
}
Here we shouldn't resolve callable reference until we get constraint from expected type of `x1`
This commit is contained in:
@@ -136,7 +136,7 @@ class ResolvedCallableReferenceAtom(
|
|||||||
|
|
||||||
override val inputTypes: Collection<UnwrappedType>
|
override val inputTypes: Collection<UnwrappedType>
|
||||||
get() {
|
get() {
|
||||||
val functionType = getFunctionTypeFromCallableReferenceExpectedType(expectedType) ?: return emptyList()
|
val functionType = getFunctionTypeFromCallableReferenceExpectedType(expectedType) ?: return listOfNotNull(expectedType)
|
||||||
val parameters = functionType.getValueParameterTypesFromFunctionType().map { it.type.unwrap() }
|
val parameters = functionType.getValueParameterTypesFromFunctionType().map { it.type.unwrap() }
|
||||||
val receiver = functionType.getReceiverTypeFromFunctionType()?.unwrap()
|
val receiver = functionType.getReceiverTypeFromFunctionType()?.unwrap()
|
||||||
return receiver?.let { parameters + it } ?: parameters
|
return receiver?.let { parameters + it } ?: parameters
|
||||||
|
|||||||
Reference in New Issue
Block a user