[FIR] Get rid of FirTypedDeclaration
`FirTypedDeclaration` has only one inheritor (`FirCallableDeclaration`), so there is no much sense to keep this class
This commit is contained in:
committed by
teamcity
parent
ae0ce57b2c
commit
5a3b397552
@@ -713,7 +713,7 @@ class FirCallResolver(
|
||||
coneType != null && !coneType.isUnit -> {
|
||||
ConeFunctionExpectedError(
|
||||
name.asString(),
|
||||
(fir as? FirTypedDeclaration)?.returnTypeRef?.coneType ?: coneType
|
||||
(fir as? FirCallableDeclaration)?.returnTypeRef?.coneType ?: coneType
|
||||
)
|
||||
}
|
||||
singleExpectedCandidate != null && !singleExpectedCandidate.currentApplicability.isSuccess -> {
|
||||
@@ -829,4 +829,4 @@ class FirCallResolver(
|
||||
}
|
||||
|
||||
/** A candidate in the overload candidate set. */
|
||||
data class OverloadCandidate(val candidate: Candidate, val isInBestCandidates: Boolean)
|
||||
data class OverloadCandidate(val candidate: Candidate, val isInBestCandidates: Boolean)
|
||||
|
||||
@@ -71,7 +71,7 @@ fun FirFunction.constructFunctionalType(isSuspend: Boolean = false): ConeLookupT
|
||||
)
|
||||
)
|
||||
}
|
||||
val rawReturnType = (this as FirTypedDeclaration).returnTypeRef.coneType
|
||||
val rawReturnType = (this as FirCallableDeclaration).returnTypeRef.coneType
|
||||
|
||||
return createFunctionalType(parameters, receiverTypeRef?.coneType, rawReturnType, isSuspend = isSuspend)
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ package org.jetbrains.kotlin.fir.resolve.calls
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.FirFunction
|
||||
import org.jetbrains.kotlin.fir.declarations.FirTypedDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.FirCallableDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.FirValueParameter
|
||||
import org.jetbrains.kotlin.fir.expressions.*
|
||||
import org.jetbrains.kotlin.fir.lookupTracker
|
||||
@@ -196,7 +196,7 @@ fun Candidate.resolveSubCallArgument(
|
||||
* It's important to extract type from argument neither from symbol, because of symbol contains
|
||||
* placeholder type with value 0, but argument contains type with proper literal value
|
||||
*/
|
||||
val type: ConeKotlinType = context.returnTypeCalculator.tryCalculateReturnType(candidate.symbol.fir as FirTypedDeclaration).type
|
||||
val type: ConeKotlinType = context.returnTypeCalculator.tryCalculateReturnType(candidate.symbol.fir as FirCallableDeclaration).type
|
||||
val argumentType = candidate.substitutor.substituteOrSelf(type)
|
||||
resolvePlainArgumentType(
|
||||
csBuilder,
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.fir.resolve.calls.tower
|
||||
|
||||
import org.jetbrains.kotlin.fir.declarations.FirTypedDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.FirCallableDeclaration
|
||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccessExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.FirResolvedQualifier
|
||||
@@ -296,7 +296,7 @@ private fun BodyResolveComponents.createExplicitReceiverForInvokeByCallable(
|
||||
candidate
|
||||
)
|
||||
dispatchReceiver = candidate.dispatchReceiverExpression()
|
||||
this.typeRef = returnTypeCalculator.tryCalculateReturnType(symbol.fir as FirTypedDeclaration)
|
||||
this.typeRef = returnTypeCalculator.tryCalculateReturnType(symbol.fir)
|
||||
|
||||
if (!invokeBuiltinExtensionMode) {
|
||||
extensionReceiver = extensionReceiverExpression
|
||||
|
||||
+1
-1
@@ -99,7 +99,7 @@ class FirCallCompletionResultsWriterTransformer(
|
||||
val subCandidate = calleeReference.candidate
|
||||
val declaration = subCandidate.symbol.fir
|
||||
val typeArguments = computeTypeArguments(qualifiedAccessExpression, subCandidate)
|
||||
val typeRef = if (declaration is FirTypedDeclaration) {
|
||||
val typeRef = if (declaration is FirCallableDeclaration) {
|
||||
val calculated = typeCalculator.tryCalculateReturnType(declaration)
|
||||
if (calculated !is FirErrorTypeRef) {
|
||||
buildResolvedTypeRef {
|
||||
|
||||
+2
-2
@@ -9,7 +9,7 @@ import org.jetbrains.kotlin.KtFakeSourceElementKind
|
||||
import org.jetbrains.kotlin.fir.FirElement
|
||||
import org.jetbrains.kotlin.fir.copyWithNewSourceKind
|
||||
import org.jetbrains.kotlin.fir.declarations.FirClass
|
||||
import org.jetbrains.kotlin.fir.declarations.FirTypedDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.FirCallableDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.FirValueParameter
|
||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||
import org.jetbrains.kotlin.fir.references.*
|
||||
@@ -99,7 +99,7 @@ internal fun FirValueParameter.transformVarargTypeToArrayType() {
|
||||
}
|
||||
}
|
||||
|
||||
internal fun FirTypedDeclaration.transformTypeToArrayType() {
|
||||
internal fun FirCallableDeclaration.transformTypeToArrayType() {
|
||||
val returnTypeRef = this.returnTypeRef
|
||||
require(returnTypeRef is FirResolvedTypeRef)
|
||||
// If the delegated type is already resolved, it means we have already created a resolved array type for this vararg type declaration.
|
||||
|
||||
+2
-4
@@ -215,7 +215,7 @@ private class ReturnTypeCalculatorWithJump(
|
||||
|
||||
var outerTowerDataContexts: FirRegularTowerDataContexts? = null
|
||||
|
||||
override fun tryCalculateReturnTypeOrNull(declaration: FirTypedDeclaration): FirResolvedTypeRef {
|
||||
override fun tryCalculateReturnTypeOrNull(declaration: FirCallableDeclaration): FirResolvedTypeRef {
|
||||
if (declaration is FirValueParameter && declaration.returnTypeRef is FirImplicitTypeRef) {
|
||||
// TODO?
|
||||
declaration.transformReturnTypeRef(
|
||||
@@ -229,8 +229,6 @@ private class ReturnTypeCalculatorWithJump(
|
||||
val returnTypeRef = declaration.returnTypeRef
|
||||
if (returnTypeRef is FirResolvedTypeRef) return returnTypeRef
|
||||
|
||||
require(declaration is FirCallableDeclaration) { "${declaration::class}: ${declaration.render()}" }
|
||||
|
||||
if (declaration is FirSyntheticProperty) {
|
||||
return tryCalculateReturnType(declaration.getter.delegate)
|
||||
}
|
||||
@@ -242,7 +240,7 @@ private class ReturnTypeCalculatorWithJump(
|
||||
(declaration.returnTypeRef as? FirResolvedTypeRef)?.let { return it }
|
||||
declaration.attributes.fakeOverrideSubstitution = null
|
||||
val (substitutor, baseSymbol) = fakeOverrideSubstitution
|
||||
val baseDeclaration = baseSymbol.fir as FirTypedDeclaration
|
||||
val baseDeclaration = baseSymbol.fir as FirCallableDeclaration
|
||||
val baseReturnTypeRef = tryCalculateReturnType(baseDeclaration)
|
||||
val baseReturnType = baseReturnTypeRef.type
|
||||
val coneType = substitutor.substituteOrSelf(baseReturnType)
|
||||
|
||||
Reference in New Issue
Block a user