[FIR] [TMP] Complete lambdas that are not part of some call
This commit is contained in:
+12
-3
@@ -455,14 +455,23 @@ class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransformer)
|
|||||||
af = af.transformValueParameters(ImplicitToErrorTypeTransformer, null)
|
af = af.transformValueParameters(ImplicitToErrorTypeTransformer, null)
|
||||||
val bodyExpectedType = returnTypeRefFromResolvedAtom ?: data.expectedTypeRef
|
val bodyExpectedType = returnTypeRefFromResolvedAtom ?: data.expectedTypeRef
|
||||||
af = transformFunction(af, withExpectedType(bodyExpectedType)).single as FirAnonymousFunction
|
af = transformFunction(af, withExpectedType(bodyExpectedType)).single as FirAnonymousFunction
|
||||||
af = af.copy(
|
// To separate function and separate commit
|
||||||
returnTypeRef = af.body?.resultType ?: FirErrorTypeRefImpl(af.source, FirSimpleDiagnostic("No result type for lambda", DiagnosticKind.InferenceError))
|
val writer = FirCallCompletionResultsWriterTransformer(
|
||||||
|
session,
|
||||||
|
ConeSubstitutor.Empty,
|
||||||
|
returnTypeCalculator,
|
||||||
|
inferenceComponents.approximator,
|
||||||
|
integerOperatorsTypeUpdater,
|
||||||
|
integerLiteralTypeApproximator
|
||||||
)
|
)
|
||||||
|
af.transformSingle(writer, data.expectedTypeRef.coneTypeSafe<ConeKotlinType>()?.toExpectedType())
|
||||||
|
val returnTypes = dataFlowAnalyzer.returnExpressionsOfAnonymousFunction(af).mapNotNull { (it as? FirExpression)?.resultType?.coneTypeUnsafe() }
|
||||||
|
af.replaceReturnTypeRef(af.returnTypeRef.resolvedTypeFromPrototype(inferenceComponents.ctx.commonSuperTypeOrNull(returnTypes) ?: session.builtinTypes.unitType.coneTypeUnsafe()))
|
||||||
af.replaceTypeRef(af.constructFunctionalTypeRef(session))
|
af.replaceTypeRef(af.constructFunctionalTypeRef(session))
|
||||||
af.compose()
|
af.compose()
|
||||||
}
|
}
|
||||||
ResolutionMode.ContextIndependent -> {
|
ResolutionMode.ContextIndependent -> {
|
||||||
transformFunction(anonymousFunction, data).single.compose()
|
transformFunction(anonymousFunction, data)
|
||||||
}
|
}
|
||||||
is ResolutionMode.WithStatus -> {
|
is ResolutionMode.WithStatus -> {
|
||||||
throw AssertionError("Should not be here in WithStatus mode")
|
throw AssertionError("Should not be here in WithStatus mode")
|
||||||
|
|||||||
Reference in New Issue
Block a user