[FIR] Make BodyResolveComponents an abstract class
This commit is contained in:
@@ -44,7 +44,8 @@ import org.jetbrains.kotlin.types.Variance
|
|||||||
class FirCallResolver(
|
class FirCallResolver(
|
||||||
private val components: BodyResolveComponents,
|
private val components: BodyResolveComponents,
|
||||||
private val qualifiedResolver: FirQualifiedNameResolver,
|
private val qualifiedResolver: FirQualifiedNameResolver,
|
||||||
) : BodyResolveComponents by components {
|
) {
|
||||||
|
private val session = components.session
|
||||||
|
|
||||||
private lateinit var transformer: FirExpressionsResolveTransformer
|
private lateinit var transformer: FirExpressionsResolveTransformer
|
||||||
|
|
||||||
@@ -53,7 +54,7 @@ class FirCallResolver(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private val towerResolver = FirTowerResolver(
|
private val towerResolver = FirTowerResolver(
|
||||||
components, resolutionStageRunner,
|
components, components.resolutionStageRunner,
|
||||||
)
|
)
|
||||||
|
|
||||||
private val conflictResolver: ConeCallConflictResolver =
|
private val conflictResolver: ConeCallConflictResolver =
|
||||||
@@ -69,7 +70,7 @@ class FirCallResolver(
|
|||||||
val functionCall = if (needTransformArguments) {
|
val functionCall = if (needTransformArguments) {
|
||||||
functionCall.transformExplicitReceiver()
|
functionCall.transformExplicitReceiver()
|
||||||
.also {
|
.also {
|
||||||
dataFlowAnalyzer.enterQualifiedAccessExpression()
|
components.dataFlowAnalyzer.enterQualifiedAccessExpression()
|
||||||
functionCall.argumentList.transformArguments(transformer, ResolutionMode.ContextDependent)
|
functionCall.argumentList.transformArguments(transformer, ResolutionMode.ContextDependent)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -102,7 +103,7 @@ class FirCallResolver(
|
|||||||
} else {
|
} else {
|
||||||
resultExpression
|
resultExpression
|
||||||
}
|
}
|
||||||
val typeRef = typeFromCallee(resultFunctionCall)
|
val typeRef = components.typeFromCallee(resultFunctionCall)
|
||||||
if (typeRef.type is ConeKotlinErrorType) {
|
if (typeRef.type is ConeKotlinErrorType) {
|
||||||
resultFunctionCall.resultType = typeRef
|
resultFunctionCall.resultType = typeRef
|
||||||
}
|
}
|
||||||
@@ -142,7 +143,7 @@ class FirCallResolver(
|
|||||||
qualifiedResolver.isPotentialQualifierPartPosition(),
|
qualifiedResolver.isPotentialQualifierPartPosition(),
|
||||||
typeArguments,
|
typeArguments,
|
||||||
session,
|
session,
|
||||||
file,
|
components.file,
|
||||||
transformer.components.containingDeclarations,
|
transformer.components.containingDeclarations,
|
||||||
)
|
)
|
||||||
towerResolver.reset()
|
towerResolver.reset()
|
||||||
@@ -159,7 +160,7 @@ class FirCallResolver(
|
|||||||
if ((reducedCandidates.isEmpty() || !result.currentApplicability.isSuccess) &&
|
if ((reducedCandidates.isEmpty() || !result.currentApplicability.isSuccess) &&
|
||||||
explicitReceiver?.typeRef?.coneTypeSafe<ConeIntegerLiteralType>() != null
|
explicitReceiver?.typeRef?.coneTypeSafe<ConeIntegerLiteralType>() != null
|
||||||
) {
|
) {
|
||||||
val approximatedQualifiedAccess = qualifiedAccess.transformExplicitReceiver(integerLiteralTypeApproximator, null)
|
val approximatedQualifiedAccess = qualifiedAccess.transformExplicitReceiver(components.integerLiteralTypeApproximator, null)
|
||||||
if (approximatedQualifiedAccess.explicitReceiver?.typeRef?.coneTypeSafe<ConeIntegerLiteralType>() == null) {
|
if (approximatedQualifiedAccess.explicitReceiver?.typeRef?.coneTypeSafe<ConeIntegerLiteralType>() == null) {
|
||||||
return collectCandidates(approximatedQualifiedAccess, name)
|
return collectCandidates(approximatedQualifiedAccess, name)
|
||||||
}
|
}
|
||||||
@@ -216,7 +217,7 @@ class FirCallResolver(
|
|||||||
|
|
||||||
when {
|
when {
|
||||||
referencedSymbol is FirClassLikeSymbol<*> -> {
|
referencedSymbol is FirClassLikeSymbol<*> -> {
|
||||||
return buildResolvedQualifierForClass(referencedSymbol, nameReference.source, qualifiedAccess.typeArguments, diagnostic)
|
return components.buildResolvedQualifierForClass(referencedSymbol, nameReference.source, qualifiedAccess.typeArguments, diagnostic)
|
||||||
}
|
}
|
||||||
referencedSymbol is FirTypeParameterSymbol && referencedSymbol.fir.isReified -> {
|
referencedSymbol is FirTypeParameterSymbol && referencedSymbol.fir.isReified -> {
|
||||||
return buildResolvedReifiedParameterReference {
|
return buildResolvedReifiedParameterReference {
|
||||||
@@ -251,7 +252,7 @@ class FirCallResolver(
|
|||||||
expectedType, constraintSystemBuilder,
|
expectedType, constraintSystemBuilder,
|
||||||
)
|
)
|
||||||
// No reset here!
|
// No reset here!
|
||||||
val localCollector = CandidateCollector(this, resolutionStageRunner)
|
val localCollector = CandidateCollector(components, components.resolutionStageRunner)
|
||||||
val result = towerResolver.runResolver(
|
val result = towerResolver.runResolver(
|
||||||
info,
|
info,
|
||||||
transformer.resolutionContext,
|
transformer.resolutionContext,
|
||||||
@@ -309,8 +310,8 @@ class FirCallResolver(
|
|||||||
isPotentialQualifierPart = false,
|
isPotentialQualifierPart = false,
|
||||||
typeArguments = typeArguments,
|
typeArguments = typeArguments,
|
||||||
session,
|
session,
|
||||||
file,
|
components.file,
|
||||||
containingDeclarations,
|
components.containingDeclarations,
|
||||||
)
|
)
|
||||||
towerResolver.reset()
|
towerResolver.reset()
|
||||||
|
|
||||||
@@ -320,7 +321,7 @@ class FirCallResolver(
|
|||||||
transformer.resolutionContext
|
transformer.resolutionContext
|
||||||
)
|
)
|
||||||
|
|
||||||
return callResolver.selectDelegatingConstructorCall(delegatedConstructorCall, name, result, callInfo)
|
return components.callResolver.selectDelegatingConstructorCall(delegatedConstructorCall, name, result, callInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun ConeTypeProjection.toFirTypeProjection(): FirTypeProjection = when (this) {
|
private fun ConeTypeProjection.toFirTypeProjection(): FirTypeProjection = when (this) {
|
||||||
@@ -356,8 +357,8 @@ class FirCallResolver(
|
|||||||
isPotentialQualifierPart = false,
|
isPotentialQualifierPart = false,
|
||||||
typeArguments = emptyList(),
|
typeArguments = emptyList(),
|
||||||
session,
|
session,
|
||||||
file,
|
components.file,
|
||||||
containingDeclarations
|
components.containingDeclarations
|
||||||
)
|
)
|
||||||
|
|
||||||
val annotationClassSymbol = annotationCall.getCorrespondingClassSymbolOrNull(session)
|
val annotationClassSymbol = annotationCall.getCorrespondingClassSymbolOrNull(session)
|
||||||
@@ -390,7 +391,7 @@ class FirCallResolver(
|
|||||||
callInfo: CallInfo
|
callInfo: CallInfo
|
||||||
): ResolutionResult? {
|
): ResolutionResult? {
|
||||||
var constructorSymbol: FirConstructorSymbol? = null
|
var constructorSymbol: FirConstructorSymbol? = null
|
||||||
annotationClassSymbol.fir.unsubstitutedScope(session, scopeSession).processDeclaredConstructors {
|
annotationClassSymbol.fir.unsubstitutedScope(session, components.scopeSession).processDeclaredConstructors {
|
||||||
if (it.fir.isPrimary && constructorSymbol == null) {
|
if (it.fir.isPrimary && constructorSymbol == null) {
|
||||||
constructorSymbol = it
|
constructorSymbol = it
|
||||||
}
|
}
|
||||||
@@ -400,7 +401,7 @@ class FirCallResolver(
|
|||||||
constructorSymbol!!,
|
constructorSymbol!!,
|
||||||
ExplicitReceiverKind.NO_EXPLICIT_RECEIVER
|
ExplicitReceiverKind.NO_EXPLICIT_RECEIVER
|
||||||
)
|
)
|
||||||
val applicability = resolutionStageRunner.processCandidate(candidate, transformer.resolutionContext)
|
val applicability = components.resolutionStageRunner.processCandidate(candidate, transformer.resolutionContext)
|
||||||
return ResolutionResult(callInfo, applicability, listOf(candidate))
|
return ResolutionResult(callInfo, applicability, listOf(candidate))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -458,7 +459,7 @@ class FirCallResolver(
|
|||||||
isPotentialQualifierPart = false,
|
isPotentialQualifierPart = false,
|
||||||
emptyList(),
|
emptyList(),
|
||||||
session,
|
session,
|
||||||
file,
|
components.file,
|
||||||
transformer.components.containingDeclarations,
|
transformer.components.containingDeclarations,
|
||||||
candidateForCommonInvokeReceiver = null,
|
candidateForCommonInvokeReceiver = null,
|
||||||
// Additional things for callable reference resolve
|
// Additional things for callable reference resolve
|
||||||
@@ -542,7 +543,7 @@ class FirCallResolver(
|
|||||||
name: Name
|
name: Name
|
||||||
): FirErrorReferenceWithCandidate {
|
): FirErrorReferenceWithCandidate {
|
||||||
val candidate = CandidateFactory(transformer.resolutionContext, callInfo).createErrorCandidate(diagnostic)
|
val candidate = CandidateFactory(transformer.resolutionContext, callInfo).createErrorCandidate(diagnostic)
|
||||||
resolutionStageRunner.processCandidate(candidate, transformer.resolutionContext, stopOnFirstError = false)
|
components.resolutionStageRunner.processCandidate(candidate, transformer.resolutionContext, stopOnFirstError = false)
|
||||||
return FirErrorReferenceWithCandidate(source, name, candidate, diagnostic)
|
return FirErrorReferenceWithCandidate(source, name, candidate, diagnostic)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -552,7 +553,7 @@ class FirCallResolver(
|
|||||||
diagnostic: ConeDiagnostic
|
diagnostic: ConeDiagnostic
|
||||||
): FirErrorReferenceWithCandidate {
|
): FirErrorReferenceWithCandidate {
|
||||||
if (!candidate.fullyAnalyzed) {
|
if (!candidate.fullyAnalyzed) {
|
||||||
resolutionStageRunner.processCandidate(candidate, transformer.resolutionContext, stopOnFirstError = false)
|
components.resolutionStageRunner.processCandidate(candidate, transformer.resolutionContext, stopOnFirstError = false)
|
||||||
}
|
}
|
||||||
return FirErrorReferenceWithCandidate(source, candidate.callInfo.name, candidate, diagnostic)
|
return FirErrorReferenceWithCandidate(source, candidate.callInfo.name, candidate, diagnostic)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,8 @@ import org.jetbrains.kotlin.fir.resolve.typeForQualifier
|
|||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
|
||||||
class FirQualifiedNameResolver(components: BodyResolveComponents) : BodyResolveComponents by components {
|
class FirQualifiedNameResolver(private val components: BodyResolveComponents) {
|
||||||
|
private val session = components.session
|
||||||
private var qualifierStack = mutableListOf<Name>()
|
private var qualifierStack = mutableListOf<Name>()
|
||||||
private var qualifierPartsToDrop = 0
|
private var qualifierPartsToDrop = 0
|
||||||
|
|
||||||
@@ -80,7 +81,7 @@ class FirQualifiedNameResolver(components: BodyResolveComponents) : BodyResolveC
|
|||||||
relativeClassFqName = resolved.relativeClassFqName
|
relativeClassFqName = resolved.relativeClassFqName
|
||||||
symbol = resolved.classSymbol
|
symbol = resolved.classSymbol
|
||||||
}.apply {
|
}.apply {
|
||||||
resultType = typeForQualifier(this)
|
resultType = components.typeForQualifier(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+23
-23
@@ -34,29 +34,29 @@ interface SessionHolder {
|
|||||||
val scopeSession: ScopeSession
|
val scopeSession: ScopeSession
|
||||||
}
|
}
|
||||||
|
|
||||||
interface BodyResolveComponents : SessionHolder {
|
abstract class BodyResolveComponents : SessionHolder {
|
||||||
val returnTypeCalculator: ReturnTypeCalculator
|
abstract val returnTypeCalculator: ReturnTypeCalculator
|
||||||
val implicitReceiverStack: ImplicitReceiverStack
|
abstract val implicitReceiverStack: ImplicitReceiverStack
|
||||||
val containingDeclarations: List<FirDeclaration>
|
abstract val containingDeclarations: List<FirDeclaration>
|
||||||
val fileImportsScope: List<FirScope>
|
abstract val fileImportsScope: List<FirScope>
|
||||||
val towerDataElements: List<FirTowerDataElement>
|
abstract val towerDataElements: List<FirTowerDataElement>
|
||||||
val towerDataContext: FirTowerDataContext
|
abstract val towerDataContext: FirTowerDataContext
|
||||||
val localScopes: FirLocalScopes
|
abstract val localScopes: FirLocalScopes
|
||||||
val towerDataContextForAnonymousFunctions: TowerDataContextForAnonymousFunctions
|
abstract val towerDataContextForAnonymousFunctions: TowerDataContextForAnonymousFunctions
|
||||||
val noExpectedType: FirTypeRef
|
abstract val noExpectedType: FirTypeRef
|
||||||
val symbolProvider: FirSymbolProvider
|
abstract val symbolProvider: FirSymbolProvider
|
||||||
val file: FirFile
|
abstract val file: FirFile
|
||||||
val container: FirDeclaration
|
abstract val container: FirDeclaration
|
||||||
val resolutionStageRunner: ResolutionStageRunner
|
abstract val resolutionStageRunner: ResolutionStageRunner
|
||||||
val samResolver: FirSamResolver
|
abstract val samResolver: FirSamResolver
|
||||||
val callResolver: FirCallResolver
|
abstract val callResolver: FirCallResolver
|
||||||
val callCompleter: FirCallCompleter
|
abstract val callCompleter: FirCallCompleter
|
||||||
val doubleColonExpressionResolver: FirDoubleColonExpressionResolver
|
abstract val doubleColonExpressionResolver: FirDoubleColonExpressionResolver
|
||||||
val syntheticCallGenerator: FirSyntheticCallGenerator
|
abstract val syntheticCallGenerator: FirSyntheticCallGenerator
|
||||||
val dataFlowAnalyzer: FirDataFlowAnalyzer<*>
|
abstract val dataFlowAnalyzer: FirDataFlowAnalyzer<*>
|
||||||
val integerLiteralTypeApproximator: IntegerLiteralTypeApproximationTransformer
|
abstract val integerLiteralTypeApproximator: IntegerLiteralTypeApproximationTransformer
|
||||||
val integerOperatorsTypeUpdater: IntegerOperatorsTypeUpdater
|
abstract val integerOperatorsTypeUpdater: IntegerOperatorsTypeUpdater
|
||||||
val outerClassManager: FirOuterClassManager
|
abstract val outerClassManager: FirOuterClassManager
|
||||||
}
|
}
|
||||||
|
|
||||||
typealias FirLocalScopes = PersistentList<FirLocalScope>
|
typealias FirLocalScopes = PersistentList<FirLocalScope>
|
||||||
|
|||||||
+13
-13
@@ -11,7 +11,6 @@ import org.jetbrains.kotlin.fir.declarations.builder.buildValueParameter
|
|||||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirResolvable
|
import org.jetbrains.kotlin.fir.expressions.FirResolvable
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirStatement
|
import org.jetbrains.kotlin.fir.expressions.FirStatement
|
||||||
import org.jetbrains.kotlin.fir.resolve.BodyResolveComponents
|
|
||||||
import org.jetbrains.kotlin.fir.resolve.ResolutionMode
|
import org.jetbrains.kotlin.fir.resolve.ResolutionMode
|
||||||
import org.jetbrains.kotlin.fir.resolve.calls.FirNamedReferenceWithCandidate
|
import org.jetbrains.kotlin.fir.resolve.calls.FirNamedReferenceWithCandidate
|
||||||
import org.jetbrains.kotlin.fir.resolve.calls.ResolutionContext
|
import org.jetbrains.kotlin.fir.resolve.calls.ResolutionContext
|
||||||
@@ -39,7 +38,8 @@ import org.jetbrains.kotlin.utils.addToStdlib.runIf
|
|||||||
class FirCallCompleter(
|
class FirCallCompleter(
|
||||||
private val transformer: FirBodyResolveTransformer,
|
private val transformer: FirBodyResolveTransformer,
|
||||||
private val components: FirAbstractBodyResolveTransformer.BodyResolveTransformerComponents
|
private val components: FirAbstractBodyResolveTransformer.BodyResolveTransformerComponents
|
||||||
) : BodyResolveComponents by components {
|
) {
|
||||||
|
private val session = components.session
|
||||||
val completer = ConstraintSystemCompleter(components)
|
val completer = ConstraintSystemCompleter(components)
|
||||||
private val inferenceSession
|
private val inferenceSession
|
||||||
get() = transformer.context.inferenceSession
|
get() = transformer.context.inferenceSession
|
||||||
@@ -48,7 +48,7 @@ class FirCallCompleter(
|
|||||||
|
|
||||||
fun <T> completeCall(call: T, expectedTypeRef: FirTypeRef?): CompletionResult<T>
|
fun <T> completeCall(call: T, expectedTypeRef: FirTypeRef?): CompletionResult<T>
|
||||||
where T : FirResolvable, T : FirStatement {
|
where T : FirResolvable, T : FirStatement {
|
||||||
val typeRef = typeFromCallee(call)
|
val typeRef = components.typeFromCallee(call)
|
||||||
|
|
||||||
val reference = call.calleeReference as? FirNamedReferenceWithCandidate ?: return CompletionResult(call, true)
|
val reference = call.calleeReference as? FirNamedReferenceWithCandidate ?: return CompletionResult(call, true)
|
||||||
val candidate = reference.candidate
|
val candidate = reference.candidate
|
||||||
@@ -79,10 +79,10 @@ class FirCallCompleter(
|
|||||||
candidate.system.asReadOnlyStorage().buildAbstractResultingSubstitutor(session.inferenceComponents.ctx) as ConeSubstitutor
|
candidate.system.asReadOnlyStorage().buildAbstractResultingSubstitutor(session.inferenceComponents.ctx) as ConeSubstitutor
|
||||||
val completedCall = call.transformSingle(
|
val completedCall = call.transformSingle(
|
||||||
FirCallCompletionResultsWriterTransformer(
|
FirCallCompletionResultsWriterTransformer(
|
||||||
session, finalSubstitutor, returnTypeCalculator,
|
session, finalSubstitutor, components.returnTypeCalculator,
|
||||||
session.inferenceComponents.approximator,
|
session.inferenceComponents.approximator,
|
||||||
integerOperatorsTypeUpdater,
|
components.integerOperatorsTypeUpdater,
|
||||||
integerLiteralTypeApproximator
|
components.integerLiteralTypeApproximator
|
||||||
),
|
),
|
||||||
null
|
null
|
||||||
)
|
)
|
||||||
@@ -104,7 +104,7 @@ class FirCallCompleter(
|
|||||||
) {
|
) {
|
||||||
analyzer.analyze(candidate.system.asPostponedArgumentsAnalyzerContext(), it, candidate)
|
analyzer.analyze(candidate.system.asPostponedArgumentsAnalyzerContext(), it, candidate)
|
||||||
}
|
}
|
||||||
val approximatedCall = call.transformSingle(integerOperatorsTypeUpdater, null)
|
val approximatedCall = call.transformSingle(components.integerOperatorsTypeUpdater, null)
|
||||||
inferenceSession.addPartiallyResolvedCall(approximatedCall)
|
inferenceSession.addPartiallyResolvedCall(approximatedCall)
|
||||||
CompletionResult(approximatedCall, false)
|
CompletionResult(approximatedCall, false)
|
||||||
}
|
}
|
||||||
@@ -118,10 +118,10 @@ class FirCallCompleter(
|
|||||||
mode: FirCallCompletionResultsWriterTransformer.Mode = FirCallCompletionResultsWriterTransformer.Mode.Normal
|
mode: FirCallCompletionResultsWriterTransformer.Mode = FirCallCompletionResultsWriterTransformer.Mode.Normal
|
||||||
): FirCallCompletionResultsWriterTransformer {
|
): FirCallCompletionResultsWriterTransformer {
|
||||||
return FirCallCompletionResultsWriterTransformer(
|
return FirCallCompletionResultsWriterTransformer(
|
||||||
session, substitutor, returnTypeCalculator,
|
session, substitutor, components.returnTypeCalculator,
|
||||||
session.inferenceComponents.approximator,
|
session.inferenceComponents.approximator,
|
||||||
integerOperatorsTypeUpdater,
|
components.integerOperatorsTypeUpdater,
|
||||||
integerLiteralTypeApproximator,
|
components.integerLiteralTypeApproximator,
|
||||||
mode
|
mode
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -182,14 +182,14 @@ class FirCallCompleter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
lambdaArgument.replaceValueParameters(lambdaArgument.valueParameters + listOfNotNull(itParam))
|
lambdaArgument.replaceValueParameters(lambdaArgument.valueParameters + listOfNotNull(itParam))
|
||||||
lambdaArgument.replaceReturnTypeRef(expectedReturnTypeRef ?: noExpectedType)
|
lambdaArgument.replaceReturnTypeRef(expectedReturnTypeRef ?: components.noExpectedType)
|
||||||
|
|
||||||
val builderInferenceSession = runIf(stubsForPostponedVariables.isNotEmpty()) {
|
val builderInferenceSession = runIf(stubsForPostponedVariables.isNotEmpty()) {
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
FirBuilderInferenceSession(transformer.resolutionContext, stubsForPostponedVariables as Map<ConeTypeVariable, ConeStubType>)
|
FirBuilderInferenceSession(transformer.resolutionContext, stubsForPostponedVariables as Map<ConeTypeVariable, ConeStubType>)
|
||||||
}
|
}
|
||||||
|
|
||||||
val localContext = towerDataContextForAnonymousFunctions.get(lambdaArgument.symbol) ?: error(
|
val localContext = components.towerDataContextForAnonymousFunctions.get(lambdaArgument.symbol) ?: error(
|
||||||
""
|
""
|
||||||
)
|
)
|
||||||
transformer.context.withTowerDataContext(localContext) {
|
transformer.context.withTowerDataContext(localContext) {
|
||||||
@@ -203,7 +203,7 @@ class FirCallCompleter(
|
|||||||
}
|
}
|
||||||
transformer.context.dropContextForAnonymousFunction(lambdaArgument)
|
transformer.context.dropContextForAnonymousFunction(lambdaArgument)
|
||||||
|
|
||||||
val returnArguments = dataFlowAnalyzer.returnExpressionsOfAnonymousFunction(lambdaArgument)
|
val returnArguments = components.dataFlowAnalyzer.returnExpressionsOfAnonymousFunction(lambdaArgument)
|
||||||
|
|
||||||
return ReturnArgumentsAnalysisResult(returnArguments, builderInferenceSession)
|
return ReturnArgumentsAnalysisResult(returnArguments, builderInferenceSession)
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-7
@@ -22,7 +22,6 @@ import org.jetbrains.kotlin.fir.references.impl.FirStubReference
|
|||||||
import org.jetbrains.kotlin.fir.resolve.BodyResolveComponents
|
import org.jetbrains.kotlin.fir.resolve.BodyResolveComponents
|
||||||
import org.jetbrains.kotlin.fir.resolve.calls.*
|
import org.jetbrains.kotlin.fir.resolve.calls.*
|
||||||
import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeUnresolvedNameError
|
import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeUnresolvedNameError
|
||||||
import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.FirAbstractBodyResolveTransformer
|
|
||||||
import org.jetbrains.kotlin.fir.resolvedTypeFromPrototype
|
import org.jetbrains.kotlin.fir.resolvedTypeFromPrototype
|
||||||
import org.jetbrains.kotlin.fir.symbols.CallableId
|
import org.jetbrains.kotlin.fir.symbols.CallableId
|
||||||
import org.jetbrains.kotlin.fir.symbols.SyntheticCallableId
|
import org.jetbrains.kotlin.fir.symbols.SyntheticCallableId
|
||||||
@@ -43,8 +42,10 @@ import org.jetbrains.kotlin.resolve.calls.tower.CandidateApplicability
|
|||||||
import org.jetbrains.kotlin.types.Variance
|
import org.jetbrains.kotlin.types.Variance
|
||||||
|
|
||||||
class FirSyntheticCallGenerator(
|
class FirSyntheticCallGenerator(
|
||||||
private val components: FirAbstractBodyResolveTransformer.BodyResolveTransformerComponents
|
private val components: BodyResolveComponents
|
||||||
) : BodyResolveComponents by components {
|
) {
|
||||||
|
private val session = components.session
|
||||||
|
|
||||||
private val whenSelectFunction: FirSimpleFunction = generateSyntheticSelectFunction(SyntheticCallableId.WHEN)
|
private val whenSelectFunction: FirSimpleFunction = generateSyntheticSelectFunction(SyntheticCallableId.WHEN)
|
||||||
private val trySelectFunction: FirSimpleFunction = generateSyntheticSelectFunction(SyntheticCallableId.TRY)
|
private val trySelectFunction: FirSimpleFunction = generateSyntheticSelectFunction(SyntheticCallableId.TRY)
|
||||||
private val idFunction: FirSimpleFunction = generateSyntheticSelectFunction(SyntheticCallableId.ID)
|
private val idFunction: FirSimpleFunction = generateSyntheticSelectFunction(SyntheticCallableId.ID)
|
||||||
@@ -150,7 +151,7 @@ class FirSyntheticCallGenerator(
|
|||||||
this.argumentList = argumentList
|
this.argumentList = argumentList
|
||||||
}
|
}
|
||||||
|
|
||||||
val argument = callCompleter.completeCall(fakeCallElement, expectedTypeRef).result.argument
|
val argument = components.callCompleter.completeCall(fakeCallElement, expectedTypeRef).result.argument
|
||||||
return ((argument as? FirVarargArgumentsExpression)?.arguments?.get(0) ?: argument) as FirCallableReferenceAccess?
|
return ((argument as? FirVarargArgumentsExpression)?.arguments?.get(0) ?: argument) as FirCallableReferenceAccess?
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,7 +164,7 @@ class FirSyntheticCallGenerator(
|
|||||||
): FirNamedReferenceWithCandidate? {
|
): FirNamedReferenceWithCandidate? {
|
||||||
val callInfo = generateCallInfo(name, argumentList, callKind)
|
val callInfo = generateCallInfo(name, argumentList, callKind)
|
||||||
val candidate = generateCandidate(callInfo, function, context)
|
val candidate = generateCandidate(callInfo, function, context)
|
||||||
val applicability = resolutionStageRunner.processCandidate(candidate, context)
|
val applicability = components.resolutionStageRunner.processCandidate(candidate, context)
|
||||||
if (applicability <= CandidateApplicability.INAPPLICABLE) {
|
if (applicability <= CandidateApplicability.INAPPLICABLE) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
@@ -185,8 +186,8 @@ class FirSyntheticCallGenerator(
|
|||||||
isPotentialQualifierPart = false,
|
isPotentialQualifierPart = false,
|
||||||
typeArguments = emptyList(),
|
typeArguments = emptyList(),
|
||||||
session = session,
|
session = session,
|
||||||
containingFile = file,
|
containingFile = components.file,
|
||||||
containingDeclarations = containingDeclarations
|
containingDeclarations = components.containingDeclarations
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun generateSyntheticSelectTypeParameter(): Pair<FirTypeParameter, FirResolvedTypeRef> {
|
private fun generateSyntheticSelectTypeParameter(): Pair<FirTypeParameter, FirResolvedTypeRef> {
|
||||||
|
|||||||
+1
-1
@@ -99,7 +99,7 @@ abstract class FirAbstractBodyResolveTransformer(phase: FirResolvePhase) : FirAb
|
|||||||
override val scopeSession: ScopeSession,
|
override val scopeSession: ScopeSession,
|
||||||
val transformer: FirBodyResolveTransformer,
|
val transformer: FirBodyResolveTransformer,
|
||||||
val context: BodyResolveContext
|
val context: BodyResolveContext
|
||||||
) : BodyResolveComponents {
|
) : BodyResolveComponents() {
|
||||||
override val fileImportsScope: List<FirScope> get() = context.fileImportsScope
|
override val fileImportsScope: List<FirScope> get() = context.fileImportsScope
|
||||||
override val towerDataElements: List<FirTowerDataElement> get() = context.towerDataContext.towerDataElements
|
override val towerDataElements: List<FirTowerDataElement> get() = context.towerDataContext.towerDataElements
|
||||||
override val localScopes: FirLocalScopes get() = context.towerDataContext.localScopes
|
override val localScopes: FirLocalScopes get() = context.towerDataContext.localScopes
|
||||||
|
|||||||
+1
-1
@@ -927,6 +927,6 @@ open class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransform
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
internal fun <T> storeTypeFromCallee(access: T) where T : FirQualifiedAccess, T : FirExpression {
|
internal fun <T> storeTypeFromCallee(access: T) where T : FirQualifiedAccess, T : FirExpression {
|
||||||
access.resultType = callCompleter.typeFromCallee(access)
|
access.resultType = components.typeFromCallee(access)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user