KT-64993 [AA] Unwrap safe call when deducing the expected type of function argument in KtFirExpressionTypeProvider

^KT-64993 Fixed
This commit is contained in:
Roman Golyshev
2024-01-15 23:38:31 +01:00
committed by teamcity
parent 318fd52567
commit 67d32c3072
3 changed files with 6 additions and 7 deletions
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.analysis.api.fir.components
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.analysis.api.components.KtExpressionTypeProvider
import org.jetbrains.kotlin.analysis.api.fir.KtFirAnalysisSession
import org.jetbrains.kotlin.analysis.api.fir.unwrapSafeCall
import org.jetbrains.kotlin.analysis.api.fir.utils.unwrap
import org.jetbrains.kotlin.analysis.api.lifetime.KtLifetimeToken
import org.jetbrains.kotlin.analysis.api.types.KtErrorType
@@ -219,7 +220,7 @@ internal class KtFirExpressionTypeProvider(
private fun getExpectedTypeOfFunctionParameter(expression: PsiElement): KtType? {
val (ktCallElement, argumentExpression) = expression.getFunctionCallAsWithThisAsParameter() ?: return null
val firCall = ktCallElement.getOrBuildFirSafe<FirCall>(firResolveSession) ?: return null
val firCall = ktCallElement.getOrBuildFir(firResolveSession)?.unwrapSafeCall() as? FirCall ?: return null
val callee = (firCall.calleeReference as? FirResolvedNamedReference)?.resolvedSymbol
if (callee?.fir?.origin == FirDeclarationOrigin.SamConstructor) {
@@ -1,5 +0,0 @@
expression: arg
expected type: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/String
@@ -1,2 +1,5 @@
expression: arg
expected type: null
expected type: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/String