[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.constructFunctionType
|
||||||
import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor
|
import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol
|
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.fir.types.*
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens
|
import org.jetbrains.kotlin.lexer.KtTokens
|
||||||
import org.jetbrains.kotlin.psi
|
import org.jetbrains.kotlin.psi
|
||||||
@@ -179,10 +178,7 @@ internal class KtFirExpressionTypeProvider(
|
|||||||
|
|
||||||
override fun getFunctionalTypeForKtFunction(declaration: KtFunction): KtType {
|
override fun getFunctionalTypeForKtFunction(declaration: KtFunction): KtType {
|
||||||
val firFunction = declaration.resolveToFirSymbol(firResolveSession, FirResolvePhase.TYPES).fir as FirFunction
|
val firFunction = declaration.resolveToFirSymbol(firResolveSession, FirResolvePhase.TYPES).fir as FirFunction
|
||||||
if (firFunction.returnTypeRef is FirImplicitTypeRef) {
|
firFunction.symbol.calculateReturnType()
|
||||||
firFunction.lazyResolveToPhase(FirResolvePhase.IMPLICIT_TYPES_BODY_RESOLVE)
|
|
||||||
}
|
|
||||||
|
|
||||||
return firFunction.constructFunctionType(firFunction.specialFunctionTypeKind(firResolveSession.useSiteFirSession)).asKtType()
|
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.mpp.CallableSymbolMarker
|
||||||
import org.jetbrains.kotlin.name.CallableId
|
import org.jetbrains.kotlin.name.CallableId
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
|
||||||
|
|
||||||
abstract class FirCallableSymbol<D : FirCallableDeclaration> : FirBasedSymbol<D>(), CallableSymbolMarker {
|
abstract class FirCallableSymbol<D : FirCallableDeclaration> : FirBasedSymbol<D>(), CallableSymbolMarker {
|
||||||
abstract val callableId: CallableId
|
abstract val callableId: CallableId
|
||||||
|
|
||||||
val resolvedReturnTypeRef: FirResolvedTypeRef
|
val resolvedReturnTypeRef: FirResolvedTypeRef
|
||||||
get() {
|
get() {
|
||||||
ensureType(fir.returnTypeRef)
|
calculateReturnType()
|
||||||
val returnTypeRef = fir.returnTypeRef
|
return fir.returnTypeRef as FirResolvedTypeRef
|
||||||
if (returnTypeRef !is FirResolvedTypeRef) {
|
|
||||||
errorInLazyResolve("returnTypeRef", returnTypeRef::class, FirResolvedTypeRef::class)
|
|
||||||
}
|
|
||||||
|
|
||||||
return returnTypeRef
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun calculateReturnType() {
|
||||||
|
ensureType(fir.returnTypeRef)
|
||||||
|
val returnTypeRef = fir.returnTypeRef
|
||||||
|
if (returnTypeRef !is FirResolvedTypeRef) {
|
||||||
|
errorInLazyResolve("returnTypeRef", returnTypeRef::class, FirResolvedTypeRef::class)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val resolvedReturnType: ConeKotlinType
|
val resolvedReturnType: ConeKotlinType
|
||||||
get() = resolvedReturnTypeRef.coneType
|
get() = resolvedReturnTypeRef.coneType
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user