Fix chained conversions for subtypes of functional types

This commit is contained in:
Mikhail Zarechenskiy
2020-06-02 15:48:29 +03:00
parent 71cbe97688
commit 6b58be377e
@@ -69,13 +69,20 @@ object TypeConversions {
val samConvertedType = performConversionAfterSubtyping(
candidate, argument, candidateParameter, candidateExpectedType, SamTypeConversions
)
if (samConvertedType != null) return samConvertedType
val suspendConvertedType =
performConversionAfterSubtyping(candidate, argument, candidateParameter, candidateExpectedType, SuspendTypeConversions)
if (suspendConvertedType != null) return suspendConvertedType
val suspendConvertedType = performConversionAfterSubtyping(
candidate, argument, candidateParameter,
candidateExpectedType = samConvertedType ?: candidateExpectedType,
SuspendTypeConversions
)
return performConversionAfterSubtyping(candidate, argument, candidateParameter, candidateExpectedType, UnitTypeConversions)
val unitConvertedType = performConversionAfterSubtyping(
candidate, argument, candidateParameter,
candidateExpectedType = suspendConvertedType ?: samConvertedType ?: candidateExpectedType,
UnitTypeConversions
)
return unitConvertedType ?: suspendConvertedType ?: samConvertedType
}
private fun performConversionAfterSubtyping(