[FIR] Refactoring: store name in CallInfo
This commit is contained in:
@@ -120,6 +120,7 @@ class FirCallResolver(
|
|||||||
|
|
||||||
val info = CallInfo(
|
val info = CallInfo(
|
||||||
CallKind.Function,
|
CallKind.Function,
|
||||||
|
functionCall.calleeReference.name,
|
||||||
explicitReceiver,
|
explicitReceiver,
|
||||||
arguments,
|
arguments,
|
||||||
functionCall.safe,
|
functionCall.safe,
|
||||||
@@ -131,7 +132,6 @@ class FirCallResolver(
|
|||||||
towerResolver.reset()
|
towerResolver.reset()
|
||||||
val result = towerResolver.runResolver(
|
val result = towerResolver.runResolver(
|
||||||
implicitReceiverStack.receiversAsReversed(),
|
implicitReceiverStack.receiversAsReversed(),
|
||||||
functionCall.calleeReference.name,
|
|
||||||
info
|
info
|
||||||
)
|
)
|
||||||
val bestCandidates = result.bestCandidates()
|
val bestCandidates = result.bestCandidates()
|
||||||
@@ -154,6 +154,7 @@ class FirCallResolver(
|
|||||||
|
|
||||||
val info = CallInfo(
|
val info = CallInfo(
|
||||||
CallKind.VariableAccess,
|
CallKind.VariableAccess,
|
||||||
|
callee.name,
|
||||||
qualifiedAccess.explicitReceiver,
|
qualifiedAccess.explicitReceiver,
|
||||||
emptyList(),
|
emptyList(),
|
||||||
qualifiedAccess.safe,
|
qualifiedAccess.safe,
|
||||||
@@ -165,7 +166,6 @@ class FirCallResolver(
|
|||||||
towerResolver.reset()
|
towerResolver.reset()
|
||||||
val result = towerResolver.runResolver(
|
val result = towerResolver.runResolver(
|
||||||
implicitReceiverStack.receiversAsReversed(),
|
implicitReceiverStack.receiversAsReversed(),
|
||||||
callee.name,
|
|
||||||
info
|
info
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -246,7 +246,6 @@ class FirCallResolver(
|
|||||||
// No reset here!
|
// No reset here!
|
||||||
val result = towerResolver.runResolver(
|
val result = towerResolver.runResolver(
|
||||||
implicitReceiverStack.receiversAsReversed(),
|
implicitReceiverStack.receiversAsReversed(),
|
||||||
callableReferenceAccess.calleeReference.name,
|
|
||||||
info,
|
info,
|
||||||
collector = CandidateCollector(this, resolutionStageRunner)
|
collector = CandidateCollector(this, resolutionStageRunner)
|
||||||
)
|
)
|
||||||
@@ -287,8 +286,10 @@ class FirCallResolver(
|
|||||||
typeArguments: List<FirTypeProjection>
|
typeArguments: List<FirTypeProjection>
|
||||||
): FirDelegatedConstructorCall? {
|
): FirDelegatedConstructorCall? {
|
||||||
val scope = symbol.fir.scope(ConeSubstitutor.Empty, session, scopeSession) ?: return null
|
val scope = symbol.fir.scope(ConeSubstitutor.Empty, session, scopeSession) ?: return null
|
||||||
|
val className = symbol.classId.shortClassName
|
||||||
val callInfo = CallInfo(
|
val callInfo = CallInfo(
|
||||||
CallKind.Function,
|
CallKind.Function,
|
||||||
|
className,
|
||||||
explicitReceiver = null,
|
explicitReceiver = null,
|
||||||
delegatedConstructorCall.arguments,
|
delegatedConstructorCall.arguments,
|
||||||
isSafeCall = false,
|
isSafeCall = false,
|
||||||
@@ -300,7 +301,6 @@ class FirCallResolver(
|
|||||||
val candidateFactory = CandidateFactory(this, callInfo)
|
val candidateFactory = CandidateFactory(this, callInfo)
|
||||||
val candidates = mutableListOf<Candidate>()
|
val candidates = mutableListOf<Candidate>()
|
||||||
|
|
||||||
val className = symbol.classId.shortClassName
|
|
||||||
scope.processFunctionsByName(className) {
|
scope.processFunctionsByName(className) {
|
||||||
if (it is FirConstructorSymbol) {
|
if (it is FirConstructorSymbol) {
|
||||||
candidates += candidateFactory.createCandidate(it, ExplicitReceiverKind.NO_EXPLICIT_RECEIVER)
|
candidates += candidateFactory.createCandidate(it, ExplicitReceiverKind.NO_EXPLICIT_RECEIVER)
|
||||||
@@ -338,6 +338,7 @@ class FirCallResolver(
|
|||||||
): CallInfo {
|
): CallInfo {
|
||||||
return CallInfo(
|
return CallInfo(
|
||||||
CallKind.CallableReference,
|
CallKind.CallableReference,
|
||||||
|
callableReferenceAccess.calleeReference.name,
|
||||||
callableReferenceAccess.explicitReceiver,
|
callableReferenceAccess.explicitReceiver,
|
||||||
emptyList(),
|
emptyList(),
|
||||||
false,
|
false,
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol
|
|||||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
||||||
import org.jetbrains.kotlin.fir.types.ConeTypeVariable
|
import org.jetbrains.kotlin.fir.types.ConeTypeVariable
|
||||||
import org.jetbrains.kotlin.fir.types.FirTypeProjection
|
import org.jetbrains.kotlin.fir.types.FirTypeProjection
|
||||||
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilder
|
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilder
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemOperation
|
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemOperation
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintStorage
|
import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintStorage
|
||||||
@@ -26,6 +27,7 @@ import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind
|
|||||||
|
|
||||||
class CallInfo(
|
class CallInfo(
|
||||||
val callKind: CallKind,
|
val callKind: CallKind,
|
||||||
|
val name: Name,
|
||||||
|
|
||||||
val explicitReceiver: FirExpression?,
|
val explicitReceiver: FirExpression?,
|
||||||
val arguments: List<FirExpression>,
|
val arguments: List<FirExpression>,
|
||||||
@@ -46,20 +48,19 @@ class CallInfo(
|
|||||||
|
|
||||||
fun replaceWithVariableAccess(): CallInfo =
|
fun replaceWithVariableAccess(): CallInfo =
|
||||||
CallInfo(
|
CallInfo(
|
||||||
CallKind.VariableAccess, explicitReceiver, emptyList(),
|
CallKind.VariableAccess, name, explicitReceiver, emptyList(),
|
||||||
isSafeCall, typeArguments, session, containingFile, implicitReceiverStack, expectedType, outerCSBuilder, lhs
|
isSafeCall, typeArguments, session, containingFile, implicitReceiverStack, expectedType, outerCSBuilder, lhs
|
||||||
)
|
)
|
||||||
|
|
||||||
fun replaceExplicitReceiver(explicitReceiver: FirExpression): CallInfo =
|
fun replaceExplicitReceiver(explicitReceiver: FirExpression): CallInfo =
|
||||||
CallInfo(
|
CallInfo(
|
||||||
callKind, explicitReceiver, arguments,
|
callKind, name, explicitReceiver, arguments,
|
||||||
isSafeCall, typeArguments, session, containingFile, implicitReceiverStack, expectedType, outerCSBuilder, lhs
|
isSafeCall, typeArguments, session, containingFile, implicitReceiverStack, expectedType, outerCSBuilder, lhs
|
||||||
)
|
)
|
||||||
|
|
||||||
fun withReceiverAsArgument(receiverExpression: FirExpression): CallInfo =
|
fun withReceiverAsArgument(receiverExpression: FirExpression): CallInfo =
|
||||||
CallInfo(
|
CallInfo(
|
||||||
callKind, explicitReceiver,
|
callKind, name, explicitReceiver, listOf(receiverExpression) + arguments,
|
||||||
listOf(receiverExpression) + arguments,
|
|
||||||
isSafeCall, typeArguments, session, containingFile, implicitReceiverStack, expectedType, outerCSBuilder, lhs
|
isSafeCall, typeArguments, session, containingFile, implicitReceiverStack, expectedType, outerCSBuilder, lhs
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import org.jetbrains.kotlin.fir.scopes.ProcessorAction.NONE
|
|||||||
import org.jetbrains.kotlin.fir.scopes.impl.FirLocalScope
|
import org.jetbrains.kotlin.fir.scopes.impl.FirLocalScope
|
||||||
import org.jetbrains.kotlin.fir.types.ConeIntegerLiteralType
|
import org.jetbrains.kotlin.fir.types.ConeIntegerLiteralType
|
||||||
import org.jetbrains.kotlin.fir.types.coneTypeSafe
|
import org.jetbrains.kotlin.fir.types.coneTypeSafe
|
||||||
import org.jetbrains.kotlin.name.Name
|
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.HIDES_MEMBERS_NAME_LIST
|
import org.jetbrains.kotlin.resolve.descriptorUtil.HIDES_MEMBERS_NAME_LIST
|
||||||
|
|
||||||
enum class TowerDataKind {
|
enum class TowerDataKind {
|
||||||
@@ -203,28 +202,28 @@ class FirTowerResolver(
|
|||||||
private lateinit var implicitReceiverValues: List<ImplicitReceiverValue<*>>
|
private lateinit var implicitReceiverValues: List<ImplicitReceiverValue<*>>
|
||||||
|
|
||||||
fun runResolver(
|
fun runResolver(
|
||||||
implicitReceiverValues: List<ImplicitReceiverValue<*>>, name: Name, info: CallInfo,
|
implicitReceiverValues: List<ImplicitReceiverValue<*>>, info: CallInfo,
|
||||||
collector: CandidateCollector = this.collector
|
collector: CandidateCollector = this.collector
|
||||||
): CandidateCollector {
|
): CandidateCollector {
|
||||||
this.implicitReceiverValues = implicitReceiverValues
|
this.implicitReceiverValues = implicitReceiverValues
|
||||||
towerDataConsumer = when (info.callKind) {
|
towerDataConsumer = when (info.callKind) {
|
||||||
CallKind.VariableAccess -> {
|
CallKind.VariableAccess -> {
|
||||||
createVariableAndObjectConsumer(session, name, info, components, collector)
|
createVariableAndObjectConsumer(session, info.name, info, components, collector)
|
||||||
}
|
}
|
||||||
CallKind.Function -> {
|
CallKind.Function -> {
|
||||||
createFunctionConsumer(session, name, info, components, collector, this)
|
createFunctionConsumer(session, info.name, info, components, collector, this)
|
||||||
}
|
}
|
||||||
CallKind.CallableReference -> {
|
CallKind.CallableReference -> {
|
||||||
if (info.stubReceiver == null) {
|
if (info.stubReceiver == null) {
|
||||||
createCallableReferencesConsumer(session, name, info, components, collector)
|
createCallableReferencesConsumer(session, info.name, info, components, collector)
|
||||||
} else {
|
} else {
|
||||||
PrioritizedTowerDataConsumer(
|
PrioritizedTowerDataConsumer(
|
||||||
collector,
|
collector,
|
||||||
createCallableReferencesConsumer(
|
createCallableReferencesConsumer(
|
||||||
session, name, info.replaceExplicitReceiver(info.stubReceiver), components, collector
|
session, info.name, info.replaceExplicitReceiver(info.stubReceiver), components, collector
|
||||||
),
|
),
|
||||||
createCallableReferencesConsumer(
|
createCallableReferencesConsumer(
|
||||||
session, name, info, components, collector
|
session, info.name, info, components, collector
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -232,7 +231,7 @@ class FirTowerResolver(
|
|||||||
else -> throw AssertionError("Unsupported call kind in tower resolver: ${info.callKind}")
|
else -> throw AssertionError("Unsupported call kind in tower resolver: ${info.callKind}")
|
||||||
}
|
}
|
||||||
val shouldProcessExtensionsBeforeMembers =
|
val shouldProcessExtensionsBeforeMembers =
|
||||||
info.callKind == CallKind.Function && name in HIDES_MEMBERS_NAME_LIST
|
info.callKind == CallKind.Function && info.name in HIDES_MEMBERS_NAME_LIST
|
||||||
val shouldProcessExplicitReceiverScopeOnly =
|
val shouldProcessExplicitReceiverScopeOnly =
|
||||||
info.callKind == CallKind.Function && info.explicitReceiver?.typeRef?.coneTypeSafe<ConeIntegerLiteralType>() != null
|
info.callKind == CallKind.Function && info.explicitReceiver?.typeRef?.coneTypeSafe<ConeIntegerLiteralType>() != null
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -120,7 +120,7 @@ class FirSyntheticCallGenerator(
|
|||||||
name: Name,
|
name: Name,
|
||||||
callKind: CallKind = CallKind.SyntheticSelect
|
callKind: CallKind = CallKind.SyntheticSelect
|
||||||
): FirNamedReferenceWithCandidate? {
|
): FirNamedReferenceWithCandidate? {
|
||||||
val callInfo = generateCallInfo(arguments, callKind)
|
val callInfo = generateCallInfo(name, arguments, callKind)
|
||||||
val candidate = generateCandidate(callInfo, function)
|
val candidate = generateCandidate(callInfo, function)
|
||||||
val applicability = resolutionStageRunner.processCandidate(candidate)
|
val applicability = resolutionStageRunner.processCandidate(candidate)
|
||||||
if (applicability <= CandidateApplicability.INAPPLICABLE) {
|
if (applicability <= CandidateApplicability.INAPPLICABLE) {
|
||||||
@@ -136,8 +136,9 @@ class FirSyntheticCallGenerator(
|
|||||||
explicitReceiverKind = ExplicitReceiverKind.NO_EXPLICIT_RECEIVER
|
explicitReceiverKind = ExplicitReceiverKind.NO_EXPLICIT_RECEIVER
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun generateCallInfo(arguments: List<FirExpression>, callKind: CallKind) = CallInfo(
|
private fun generateCallInfo(name: Name, arguments: List<FirExpression>, callKind: CallKind) = CallInfo(
|
||||||
callKind = callKind,
|
callKind = callKind,
|
||||||
|
name = name,
|
||||||
explicitReceiver = null,
|
explicitReceiver = null,
|
||||||
arguments = arguments,
|
arguments = arguments,
|
||||||
isSafeCall = false,
|
isSafeCall = false,
|
||||||
|
|||||||
Reference in New Issue
Block a user