diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/results/FlatSignatureForResolvedCall.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/results/FlatSignatureForResolvedCall.kt index f7e9ffd5aea..a9efdd113c6 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/results/FlatSignatureForResolvedCall.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/results/FlatSignatureForResolvedCall.kt @@ -17,6 +17,7 @@ package org.jetbrains.kotlin.resolve.calls.results import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.descriptors.MemberDescriptor import org.jetbrains.kotlin.psi.ValueArgument import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilderImpl @@ -55,7 +56,8 @@ fun > RC.createFlatSignature(): FlatSignature { call.valueArguments.map { valueArgumentToParameterType[it] }, hasExtensionReceiver = originalDescriptor.extensionReceiverParameter != null, hasVarargs = originalDescriptor.valueParameters.any { it.varargElementType != null }, - numDefaults = numDefaults) + numDefaults = numDefaults, + isPlatform = originalDescriptor is MemberDescriptor && originalDescriptor.isPlatform) } fun createOverloadingConflictResolver( diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/results/FlatSignature.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/results/FlatSignature.kt index 4cddb870b26..acce7f91542 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/results/FlatSignature.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/results/FlatSignature.kt @@ -17,6 +17,7 @@ package org.jetbrains.kotlin.resolve.calls.results import org.jetbrains.kotlin.descriptors.CallableDescriptor +import org.jetbrains.kotlin.descriptors.MemberDescriptor import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor import org.jetbrains.kotlin.types.* @@ -41,7 +42,8 @@ class FlatSignature( val valueParameterTypes: List, val hasExtensionReceiver: Boolean, val hasVarargs: Boolean, - val numDefaults: Int + val numDefaults: Int, + val isPlatform: Boolean ) { val isGeneric = typeParameters.isNotEmpty() @@ -52,7 +54,8 @@ class FlatSignature( valueParameterTypes = descriptor.extensionReceiverTypeOrEmpty() + descriptor.valueParameters.map { it.argumentValueType }, hasExtensionReceiver = descriptor.extensionReceiverParameter != null, hasVarargs = descriptor.valueParameters.any { it.varargElementType != null }, - numDefaults = 0) + numDefaults = 0, + isPlatform = descriptor is MemberDescriptor && descriptor.isPlatform) val ValueParameterDescriptor.argumentValueType: KotlinType get() = varargElementType ?: type diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/results/OverloadingConflictResolver.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/results/OverloadingConflictResolver.kt index 32dc312299d..09406030cde 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/results/OverloadingConflictResolver.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/results/OverloadingConflictResolver.kt @@ -219,7 +219,7 @@ class OverloadingConflictResolver( } /** - * Returns `true` if `d1` is definitely not less specific than `d2`, + * Returns `true` if [call1] is definitely not less specific than [call2], * `false` otherwise. */ private fun compareCallsByUsedArguments( @@ -237,6 +237,9 @@ class OverloadingConflictResolver( if (isGeneric1 && isGeneric2) return false } + if (!call1.isPlatform && call2.isPlatform) return true + if (call1.isPlatform && !call2.isPlatform) return false + return createEmptyConstraintSystem().isSignatureNotLessSpecific(call1, call2, SpecificityComparisonWithNumerics, specificityComparator) }