[FIR] FirCallableSymbol: introduce calculateReturnType
It will help to avoid copy-pasted logic there it is needed ^KT-60728
This commit is contained in:
committed by
Space Team
parent
35b0cd65e9
commit
f549712912
+1
-5
@@ -26,7 +26,6 @@ import org.jetbrains.kotlin.fir.references.FirSuperReference
|
||||
import org.jetbrains.kotlin.fir.resolve.constructFunctionType
|
||||
import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.lazyResolveToPhase
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi
|
||||
@@ -179,10 +178,7 @@ internal class KtFirExpressionTypeProvider(
|
||||
|
||||
override fun getFunctionalTypeForKtFunction(declaration: KtFunction): KtType {
|
||||
val firFunction = declaration.resolveToFirSymbol(firResolveSession, FirResolvePhase.TYPES).fir as FirFunction
|
||||
if (firFunction.returnTypeRef is FirImplicitTypeRef) {
|
||||
firFunction.lazyResolveToPhase(FirResolvePhase.IMPLICIT_TYPES_BODY_RESOLVE)
|
||||
}
|
||||
|
||||
firFunction.symbol.calculateReturnType()
|
||||
return firFunction.constructFunctionType(firFunction.specialFunctionTypeKind(firResolveSession.useSiteFirSession)).asKtType()
|
||||
}
|
||||
|
||||
|
||||
@@ -13,22 +13,24 @@ import org.jetbrains.kotlin.fir.types.*
|
||||
import org.jetbrains.kotlin.mpp.CallableSymbolMarker
|
||||
import org.jetbrains.kotlin.name.CallableId
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||
|
||||
abstract class FirCallableSymbol<D : FirCallableDeclaration> : FirBasedSymbol<D>(), CallableSymbolMarker {
|
||||
abstract val callableId: CallableId
|
||||
|
||||
val resolvedReturnTypeRef: FirResolvedTypeRef
|
||||
get() {
|
||||
ensureType(fir.returnTypeRef)
|
||||
val returnTypeRef = fir.returnTypeRef
|
||||
if (returnTypeRef !is FirResolvedTypeRef) {
|
||||
errorInLazyResolve("returnTypeRef", returnTypeRef::class, FirResolvedTypeRef::class)
|
||||
}
|
||||
|
||||
return returnTypeRef
|
||||
calculateReturnType()
|
||||
return fir.returnTypeRef as FirResolvedTypeRef
|
||||
}
|
||||
|
||||
fun calculateReturnType() {
|
||||
ensureType(fir.returnTypeRef)
|
||||
val returnTypeRef = fir.returnTypeRef
|
||||
if (returnTypeRef !is FirResolvedTypeRef) {
|
||||
errorInLazyResolve("returnTypeRef", returnTypeRef::class, FirResolvedTypeRef::class)
|
||||
}
|
||||
}
|
||||
|
||||
val resolvedReturnType: ConeKotlinType
|
||||
get() = resolvedReturnTypeRef.coneType
|
||||
|
||||
|
||||
Reference in New Issue
Block a user