diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallResolver.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallResolver.kt index 006f18437b5..eb5a1deb9db 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallResolver.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallResolver.kt @@ -503,6 +503,10 @@ class ExplicitReceiverTowerDataConsumer( val candidateFactory: CandidateFactory ) : TowerDataConsumer() { + companion object { + val defaultPackage = Name.identifier("kotlin") + } + override fun consume( kind: TowerDataKind, @@ -548,21 +552,24 @@ class ExplicitReceiverTowerDataConsumer( dispatchReceiverValue: ClassDispatchReceiverValue?, implicitExtensionReceiverValue: ImplicitReceiverValue? ): ProcessorAction { - val explicitReceiverType = explicitReceiver.type - if (dispatchReceiverValue == null && explicitReceiverType is ConeClassType) { - val declarationReceiverTypeRef = (symbol as? FirCallableSymbol)?.fir?.receiverTypeRef as? FirResolvedTypeRef - val declarationReceiverType = declarationReceiverTypeRef?.type - if (declarationReceiverType is ConeClassType) { - if (!AbstractTypeChecker.isSubtypeOf( - candidateFactory.inferenceComponents.ctx, - explicitReceiverType, - declarationReceiverType.lookupTag.constructClassType( - declarationReceiverType.typeArguments.map { ConeStarProjection }.toTypedArray(), - isNullable = true + if (symbol is FirFunctionSymbol && symbol.callableId.packageName.startsWith(defaultPackage)) { + val explicitReceiverType = explicitReceiver.type + if (dispatchReceiverValue == null && explicitReceiverType is ConeClassType) { + val declarationReceiverTypeRef = + (symbol as? FirCallableSymbol)?.fir?.receiverTypeRef as? FirResolvedTypeRef + val declarationReceiverType = declarationReceiverTypeRef?.type + if (declarationReceiverType is ConeClassType) { + if (!AbstractTypeChecker.isSubtypeOf( + candidateFactory.inferenceComponents.ctx, + explicitReceiverType, + declarationReceiverType.lookupTag.constructClassType( + declarationReceiverType.typeArguments.map { ConeStarProjection }.toTypedArray(), + isNullable = true + ) ) - ) - ) { - return ProcessorAction.NEXT + ) { + return ProcessorAction.NEXT + } } } } diff --git a/compiler/testData/ir/irText/expressions/typeArguments.fir.txt b/compiler/testData/ir/irText/expressions/typeArguments.fir.txt index e8071b8486b..df9621ba1a4 100644 --- a/compiler/testData/ir/irText/expressions/typeArguments.fir.txt +++ b/compiler/testData/ir/irText/expressions/typeArguments.fir.txt @@ -7,7 +7,7 @@ FILE fqName: fileName:/typeArguments.kt BRANCH if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Array<*> GET_VAR 'x: kotlin.Any declared in .test1' type=kotlin.Any origin=null - then: ERROR_CALL 'Unresolved reference: #' type=IrErrorType + then: ERROR_CALL 'Unresolved reference: #' type=IrErrorType BRANCH if: CONST Boolean type=kotlin.Boolean value=true then: CONST Boolean type=kotlin.Boolean value=false