K2: Require resolved type for ResolutionMode.WithExpectedType

Implicit type might have two meaning there:
- noExpectedType
- unknown declaration type where this expression is assigned to

For both cases, we've got ResolutionMode.ContextIndependent that works
just fine
This commit is contained in:
Denis.Zharkov
2022-12-02 17:16:18 +01:00
committed by Space Team
parent df826f04a7
commit e43d8bbb47
5 changed files with 37 additions and 25 deletions
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.fir.resolve.calls.*
import org.jetbrains.kotlin.fir.resolve.createConeDiagnosticForCandidateWithError
import org.jetbrains.kotlin.fir.resolve.inference.FirCallCompleter
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef
import org.jetbrains.kotlin.fir.types.FirTypeProjection
import org.jetbrains.kotlin.fir.types.FirTypeRef
import org.jetbrains.kotlin.resolve.calls.tower.CandidateApplicability
@@ -77,7 +78,8 @@ class SingleCandidateResolver(
val completionResult = firCallCompleter.completeCall(
fakeCall,
resolutionParameters.expectedType?.let(ResolutionMode::WithExpectedType) ?: ResolutionMode.ContextIndependent
(resolutionParameters.expectedType as? FirResolvedTypeRef)?.let { ResolutionMode.WithExpectedType(it) }
?: ResolutionMode.ContextIndependent
)
return completionResult.takeIf { it.callCompleted }?.result