Cone (FIR) context: provide proper types instead of todo's
This commit is contained in:
committed by
Mikhail Glukhikh
parent
dae5822986
commit
a3806a6e2e
+14
-3
@@ -6,6 +6,10 @@
|
||||
package org.jetbrains.kotlin.fir.resolve.calls
|
||||
|
||||
import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction
|
||||
import org.jetbrains.kotlin.fir.resolve.constructType
|
||||
import org.jetbrains.kotlin.fir.service
|
||||
import org.jetbrains.kotlin.fir.symbols.StandardClassIds
|
||||
import org.jetbrains.kotlin.fir.symbols.invoke
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilder
|
||||
import org.jetbrains.kotlin.resolve.calls.model.PostponedResolvedAtomMarker
|
||||
@@ -115,7 +119,10 @@ private fun extraLambdaInfo(
|
||||
?: expectedType?.typeArguments?.singleOrNull()?.safeAs<ConeTypedProjection>()?.type?.takeIf { isFunctionSupertype }
|
||||
?: typeVariable.defaultType
|
||||
|
||||
val parameters = argument.valueParameters?.map { it.returnTypeRef.coneTypeSafe<ConeKotlinType>() ?: TODO("!nothing") } ?: emptyList()
|
||||
val nothingType = StandardClassIds.Nothing(argument.session.service()).constructType(emptyArray(), false)
|
||||
val parameters = argument.valueParameters?.map {
|
||||
it.returnTypeRef.coneTypeSafe<ConeKotlinType>() ?: nothingType
|
||||
} ?: emptyList()
|
||||
|
||||
val newTypeVariableUsed = returnType == typeVariable.defaultType
|
||||
if (newTypeVariableUsed) csBuilder.registerVariable(typeVariable)
|
||||
@@ -148,12 +155,16 @@ private fun extractLambdaInfoFromFunctionalType(
|
||||
private fun extractLambdaParameters(expectedType: ConeKotlinType, argument: FirAnonymousFunction): List<ConeKotlinType> {
|
||||
val parameters = argument.valueParameters
|
||||
val expectedParameters = expectedType.valueParameterTypes
|
||||
|
||||
val nullableAnyType = StandardClassIds.Any(argument.session.service()).constructType(emptyArray(), true)
|
||||
|
||||
if (parameters.isEmpty()) {
|
||||
return expectedParameters.map { it?.type ?: TODO("any?") }
|
||||
return expectedParameters.map { it?.type ?: nullableAnyType }
|
||||
}
|
||||
|
||||
return parameters.mapIndexed { index, parameter ->
|
||||
parameter.returnTypeRef.coneTypeSafe() ?: expectedParameters.getOrNull(index) ?: TODO("any?")//expectedType.builtIns.nullableAnyType
|
||||
parameter.returnTypeRef.coneTypeSafe() ?: expectedParameters.getOrNull(index) ?: nullableAnyType
|
||||
//expectedType.builtIns.nullableAnyType
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user