[FIR2IR] Simplify generation of bound callable reference receivers
Remove a bunch of custom logic to determine when a callable reference is bound or not (and hence mustn't have a receiver). Instead, a helper extension is introduced to determine when a callable reference is bound by checking if dispatch/extensionReceiver is not FirNoReceiver and the referenced member is not static. #KT-57253 Fixed
This commit is contained in:
committed by
Space Team
parent
a3f0e429e3
commit
b476eee6e3
@@ -9,6 +9,7 @@ import org.jetbrains.kotlin.KtSourceElement
|
||||
import org.jetbrains.kotlin.fir.FirElement
|
||||
import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin
|
||||
import org.jetbrains.kotlin.fir.declarations.FirValueParameter
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.isStatic
|
||||
import org.jetbrains.kotlin.fir.diagnostics.ConeDiagnostic
|
||||
import org.jetbrains.kotlin.fir.expressions.builder.buildConstExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.builder.buildErrorExpression
|
||||
@@ -17,10 +18,7 @@ import org.jetbrains.kotlin.fir.expressions.impl.FirBlockImpl
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirNoReceiverExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirResolvedArgumentList
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirSingleExpressionBlock
|
||||
import org.jetbrains.kotlin.fir.references.FirReference
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
||||
import org.jetbrains.kotlin.fir.references.resolved
|
||||
import org.jetbrains.kotlin.fir.references.toResolvedFunctionSymbol
|
||||
import org.jetbrains.kotlin.fir.references.*
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
|
||||
import org.jetbrains.kotlin.fir.types.ConeClassLikeType
|
||||
import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef
|
||||
@@ -162,3 +160,12 @@ fun FirExpression.unwrapSmartcastExpression(): FirExpression =
|
||||
is FirSmartCastExpression -> originalExpression
|
||||
else -> this
|
||||
}
|
||||
|
||||
/**
|
||||
* A callable reference is bound iff
|
||||
* - one of [dispatchReceiver] or [extensionReceiver] is **not** [FirNoReceiverExpression] and
|
||||
* - it's not referring to a static member.
|
||||
*/
|
||||
val FirCallableReferenceAccess.isBound: Boolean
|
||||
get() = (dispatchReceiver != FirNoReceiverExpression || extensionReceiver != FirNoReceiverExpression) &&
|
||||
calleeReference.toResolvedCallableSymbol()?.isStatic != true
|
||||
|
||||
Reference in New Issue
Block a user