[NI] Fix overload resolution ambiguity for incorrect provideDelegate
#KT-25810
This commit is contained in:
@@ -247,7 +247,11 @@ class PSICallResolver(
|
|||||||
tracingStrategy: TracingStrategy,
|
tracingStrategy: TracingStrategy,
|
||||||
trace: BindingTrace
|
trace: BindingTrace
|
||||||
): ManyCandidates<D> {
|
): ManyCandidates<D> {
|
||||||
val resolvedCalls = diagnostic.candidates.map { kotlinToResolvedCallTransformer.onlyTransform<D>(it.resolvedCall, emptyList()) }
|
val resolvedCalls = diagnostic.candidates.map {
|
||||||
|
kotlinToResolvedCallTransformer.onlyTransform<D>(
|
||||||
|
it.resolvedCall, it.diagnosticsFromResolutionParts + it.getSystem().diagnostics
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
if (diagnostic.candidates.areAllFailed()) {
|
if (diagnostic.candidates.areAllFailed()) {
|
||||||
if (diagnostic.candidates.areAllFailedWithInapplicableWrongReceiver()) {
|
if (diagnostic.candidates.areAllFailedWithInapplicableWrongReceiver()) {
|
||||||
|
|||||||
+19
@@ -0,0 +1,19 @@
|
|||||||
|
// !LANGUAGE: +NewInference
|
||||||
|
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||||
|
|
||||||
|
import kotlin.reflect.KProperty
|
||||||
|
|
||||||
|
object Foo
|
||||||
|
object Bar
|
||||||
|
object Baz
|
||||||
|
|
||||||
|
operator fun Foo.provideDelegate(receiver: Any?, property: KProperty<*>) = this
|
||||||
|
operator fun Bar.provideDelegate(receiver: Any?, property: KProperty<*>) = this
|
||||||
|
|
||||||
|
operator fun Foo.getValue(nothing: Any?, property: KProperty<*>): Any = TODO()
|
||||||
|
operator fun Bar.getValue(nothing: Any?, property: KProperty<*>): Any = TODO()
|
||||||
|
operator fun Baz.getValue(nothing: Any?, property: KProperty<*>): Any = TODO()
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
val bar by Baz
|
||||||
|
}
|
||||||
+29
@@ -0,0 +1,29 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public fun test(): kotlin.Unit
|
||||||
|
public operator fun Bar.getValue(/*0*/ nothing: kotlin.Any?, /*1*/ property: kotlin.reflect.KProperty<*>): kotlin.Any
|
||||||
|
public operator fun Baz.getValue(/*0*/ nothing: kotlin.Any?, /*1*/ property: kotlin.reflect.KProperty<*>): kotlin.Any
|
||||||
|
public operator fun Foo.getValue(/*0*/ nothing: kotlin.Any?, /*1*/ property: kotlin.reflect.KProperty<*>): kotlin.Any
|
||||||
|
public operator fun Bar.provideDelegate(/*0*/ receiver: kotlin.Any?, /*1*/ property: kotlin.reflect.KProperty<*>): Bar
|
||||||
|
public operator fun Foo.provideDelegate(/*0*/ receiver: kotlin.Any?, /*1*/ property: kotlin.reflect.KProperty<*>): Foo
|
||||||
|
|
||||||
|
public object Bar {
|
||||||
|
private constructor Bar()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public object Baz {
|
||||||
|
private constructor Baz()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public object Foo {
|
||||||
|
private constructor Foo()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
// !WITH_NEW_INFERENCE
|
|
||||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
|
||||||
import kotlin.reflect.KProperty
|
import kotlin.reflect.KProperty
|
||||||
|
|
||||||
class A {
|
class A {
|
||||||
val c: Int by <!NI;DELEGATE_SPECIAL_FUNCTION_AMBIGUITY, OI;DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>Delegate()<!>
|
val c: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>Delegate()<!>
|
||||||
}
|
}
|
||||||
|
|
||||||
class Delegate {
|
class Delegate {
|
||||||
|
|||||||
@@ -5683,6 +5683,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
|||||||
runTest("compiler/testData/diagnostics/tests/delegatedProperty/provideDelegate/noOperatorModifierOnProvideDelegate.kt");
|
runTest("compiler/testData/diagnostics/tests/delegatedProperty/provideDelegate/noOperatorModifierOnProvideDelegate.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("overloadResolutionForSeveralProvideDelegates.kt")
|
||||||
|
public void testOverloadResolutionForSeveralProvideDelegates() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/delegatedProperty/provideDelegate/overloadResolutionForSeveralProvideDelegates.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("provideDelegateOperatorDeclaration.kt")
|
@TestMetadata("provideDelegateOperatorDeclaration.kt")
|
||||||
public void testProvideDelegateOperatorDeclaration() throws Exception {
|
public void testProvideDelegateOperatorDeclaration() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/delegatedProperty/provideDelegate/provideDelegateOperatorDeclaration.kt");
|
runTest("compiler/testData/diagnostics/tests/delegatedProperty/provideDelegate/provideDelegateOperatorDeclaration.kt");
|
||||||
|
|||||||
Generated
+5
@@ -5683,6 +5683,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
|||||||
runTest("compiler/testData/diagnostics/tests/delegatedProperty/provideDelegate/noOperatorModifierOnProvideDelegate.kt");
|
runTest("compiler/testData/diagnostics/tests/delegatedProperty/provideDelegate/noOperatorModifierOnProvideDelegate.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("overloadResolutionForSeveralProvideDelegates.kt")
|
||||||
|
public void testOverloadResolutionForSeveralProvideDelegates() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/delegatedProperty/provideDelegate/overloadResolutionForSeveralProvideDelegates.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("provideDelegateOperatorDeclaration.kt")
|
@TestMetadata("provideDelegateOperatorDeclaration.kt")
|
||||||
public void testProvideDelegateOperatorDeclaration() throws Exception {
|
public void testProvideDelegateOperatorDeclaration() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/delegatedProperty/provideDelegate/provideDelegateOperatorDeclaration.kt");
|
runTest("compiler/testData/diagnostics/tests/delegatedProperty/provideDelegate/provideDelegateOperatorDeclaration.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user