[FIR] Introduce special ReceiverResolution resolution mode for resolution of receivers of calls
This resolution mode is needed to determine do we need approximate integer operator calls or not
This commit is contained in:
committed by
teamcity
parent
b980f5ab32
commit
563e649ac3
@@ -133,7 +133,7 @@ class FirCallResolver(
|
||||
private inline fun <reified Q : FirQualifiedAccess> Q.transformExplicitReceiver(): Q {
|
||||
val explicitReceiver =
|
||||
explicitReceiver as? FirQualifiedAccessExpression
|
||||
?: return transformExplicitReceiver(transformer, ResolutionMode.ContextIndependent) as Q
|
||||
?: return transformExplicitReceiver(transformer, ResolutionMode.ReceiverResolution) as Q
|
||||
|
||||
(explicitReceiver.calleeReference as? FirSuperReference)?.let {
|
||||
transformer.transformSuperReceiver(it, explicitReceiver, this)
|
||||
@@ -143,14 +143,14 @@ class FirCallResolver(
|
||||
if (explicitReceiver is FirPropertyAccessExpression) {
|
||||
this.replaceExplicitReceiver(
|
||||
transformer.transformQualifiedAccessExpression(
|
||||
explicitReceiver, ResolutionMode.ContextIndependent,
|
||||
explicitReceiver, ResolutionMode.ReceiverResolution,
|
||||
isUsedAsReceiver = true
|
||||
) as FirExpression
|
||||
)
|
||||
return this
|
||||
}
|
||||
|
||||
return transformExplicitReceiver(transformer, ResolutionMode.ContextIndependent) as Q
|
||||
return transformExplicitReceiver(transformer, ResolutionMode.ReceiverResolution) as Q
|
||||
}
|
||||
|
||||
private data class ResolutionResult(
|
||||
|
||||
@@ -15,6 +15,7 @@ sealed class ResolutionMode {
|
||||
object ContextDependent : ResolutionMode()
|
||||
object ContextDependentDelegate : ResolutionMode()
|
||||
object ContextIndependent : ResolutionMode()
|
||||
object ReceiverResolution : ResolutionMode()
|
||||
|
||||
// TODO: it's better not to use WithExpectedType(FirImplicitTypeRef)
|
||||
class WithExpectedType(
|
||||
@@ -57,7 +58,8 @@ sealed class ResolutionMode {
|
||||
|
||||
fun ResolutionMode.expectedType(components: BodyResolveComponents, allowFromCast: Boolean = false): FirTypeRef? = when (this) {
|
||||
is ResolutionMode.WithExpectedType -> expectedTypeRef
|
||||
is ResolutionMode.ContextIndependent -> components.noExpectedType
|
||||
is ResolutionMode.ContextIndependent,
|
||||
is ResolutionMode.ReceiverResolution -> components.noExpectedType
|
||||
is ResolutionMode.WithExpectedTypeFromCast -> expectedTypeRef.takeIf { allowFromCast }
|
||||
is ResolutionMode.WithSuggestedType -> suggestedTypeRef
|
||||
else -> null
|
||||
|
||||
+1
@@ -764,6 +764,7 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor
|
||||
}
|
||||
is ResolutionMode.WithExpectedType,
|
||||
is ResolutionMode.ContextIndependent,
|
||||
is ResolutionMode.ReceiverResolution,
|
||||
is ResolutionMode.WithSuggestedType -> {
|
||||
val expectedTypeRef = when (data) {
|
||||
is ResolutionMode.WithExpectedType -> {
|
||||
|
||||
Reference in New Issue
Block a user