Don't report missing getValue/setValue method error when it's was impossible to finish resolve

#KT-9803 Fixed
This commit is contained in:
Nikolay Krasko
2015-11-02 18:23:18 +03:00
parent f518f5fb9f
commit e10f7fb464
5 changed files with 54 additions and 6 deletions
@@ -189,13 +189,10 @@ public class DelegatedPropertyResolver {
if (!functionResults.isSuccess()) {
String expectedFunction = renderCall(call, trace.getBindingContext());
if (functionResults.isIncomplete()) {
trace.report(DELEGATE_SPECIAL_FUNCTION_MISSING.on(delegateExpression, expectedFunction, delegateType));
}
else if (functionResults.isSingleResult() ||
if (functionResults.isSingleResult() || functionResults.isIncomplete() ||
functionResults.getResultCode() == OverloadResolutionResults.Code.MANY_FAILED_CANDIDATES) {
trace.report(DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE
.on(delegateExpression, expectedFunction, functionResults.getResultingCalls()));
.on(delegateExpression, expectedFunction, functionResults.getResultingCalls()));
}
else if (functionResults.isAmbiguity()) {
trace.report(DELEGATE_SPECIAL_FUNCTION_AMBIGUITY
@@ -2,7 +2,7 @@
import kotlin.reflect.KProperty
var a: Int by A()
var a1 by <!DELEGATE_SPECIAL_FUNCTION_MISSING, DELEGATE_SPECIAL_FUNCTION_MISSING!>A()<!>
var a1 by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE, DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>A()<!>
var b: Int by B()
@@ -0,0 +1,25 @@
// FILE: main.kt
package test
import first.*
import second.*
val a12 by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>A()<!>
// FILE: first.kt
package first
import kotlin.reflect.KProperty
class A
public operator fun <T> A.getValue(thisRef: Any?, property: KProperty<*>): T = null!!
// FILE: second.kt
package second
import first.A
import kotlin.reflect.KProperty
public operator fun <T> A.getValue(thisRef: Any?, property: KProperty<*>): T = null!!
@@ -0,0 +1,20 @@
package
package first {
public operator fun </*0*/ T> first.A.getValue(/*0*/ thisRef: kotlin.Any?, /*1*/ property: kotlin.reflect.KProperty<*>): T
public final class A {
public constructor A()
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
}
}
package second {
public operator fun </*0*/ T> first.A.getValue(/*0*/ thisRef: kotlin.Any?, /*1*/ property: kotlin.reflect.KProperty<*>): T
}
package test {
public val a12: [ERROR : Type from delegate]
}
@@ -4589,6 +4589,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("manyIncompleteCandidates.kt")
public void testManyIncompleteCandidates() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/delegatedProperty/inference/manyIncompleteCandidates.kt");
doTest(fileName);
}
@TestMetadata("noErrorsForImplicitConstraints.kt")
public void testNoErrorsForImplicitConstraints() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/delegatedProperty/inference/noErrorsForImplicitConstraints.kt");