If all candidates are invisible then don't report ambiguity

#KT-10045 Fixed
This commit is contained in:
Mikhail Zarechenskiy
2017-06-20 15:07:16 +03:00
parent cd1ae7f0f2
commit 4b3ffd9418
11 changed files with 53 additions and 21 deletions
@@ -196,7 +196,7 @@ class CandidateResolver(
getReceiverValueWithSmartCast(receiverArgument, smartCastType), candidateDescriptor, scope.ownerDescriptor)
return if (invisibleMember != null) {
tracing.invisibleMember(trace, invisibleMember)
OTHER_ERROR
INVISIBLE_MEMBER_ERROR
} else {
SUCCESS
}
@@ -25,6 +25,7 @@ public enum ResolutionStatus {
UNSAFE_CALL_ERROR,
WRONG_NUMBER_OF_TYPE_ARGUMENTS_ERROR,
UNSTABLE_SMARTCAST_ERROR,
INVISIBLE_MEMBER_ERROR,
OTHER_ERROR,
ARGUMENTS_MAPPING_ERROR,
// '1.foo()' shouldn't be resolved to 'fun String.foo()'
@@ -42,6 +43,7 @@ public enum ResolutionStatus {
EnumSet.of(UNSAFE_CALL_ERROR), // weakest
EnumSet.of(WRONG_NUMBER_OF_TYPE_ARGUMENTS_ERROR),
EnumSet.of(UNSTABLE_SMARTCAST_ERROR),
EnumSet.of(INVISIBLE_MEMBER_ERROR),
EnumSet.of(OTHER_ERROR),
EnumSet.of(ARGUMENTS_MAPPING_ERROR),
EnumSet.of(RECEIVER_TYPE_ERROR),
@@ -27,8 +27,8 @@ import k.all
fun test() {
<!INVISIBLE_MEMBER!>zero<!>()
<!NONE_APPLICABLE!>zero<!>(1)
<!NONE_APPLICABLE!>zero<!>("")
<!INVISIBLE_MEMBER!>zero<!>(1)
<!INVISIBLE_MEMBER!>zero<!>("")
one()
one(<!TOO_MANY_ARGUMENTS!>1<!>)
@@ -0,0 +1,12 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
class A {
private fun foo(i: Int) {}
private fun foo(s: String) {}
}
fun test(a: A) {
a.<!INVISIBLE_MEMBER!>foo<!>(3)
a.<!NONE_APPLICABLE!>foo<!>()
}
@@ -0,0 +1,12 @@
package
public fun test(/*0*/ a: A): kotlin.Unit
public final class A {
public constructor A()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
private final fun foo(/*0*/ i: kotlin.Int): kotlin.Unit
private final fun foo(/*0*/ s: kotlin.String): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -11,7 +11,7 @@ class Data(var x: A)
class B : A() {
fun baz(a: A, b: B, d: Data) {
a.<!INVISIBLE_MEMBER!>foo<!> <!TYPE_MISMATCH!>{ }<!>
a.<!INVISIBLE_MEMBER!>foo<!> { }
b.foo { }
@@ -26,5 +26,5 @@ class B : A() {
}
fun baz(a: A) {
a.<!INVISIBLE_MEMBER!>foo<!> <!TYPE_MISMATCH!>{ }<!>
a.<!INVISIBLE_MEMBER!>foo<!> { }
}
@@ -4,7 +4,7 @@ package k
import JavaClass
fun foo(javaClass: JavaClass) {
javaClass.<!INVISIBLE_MEMBER!>doSomething<!> <!TYPE_MISMATCH!>{ }<!>
javaClass.<!INVISIBLE_MEMBER!>doSomething<!> { }
}
// FILE: KotlinFile2.kt
@@ -4,15 +4,15 @@ package k
import JavaClass
fun foo(javaClass: JavaClass) {
javaClass.<!INVISIBLE_MEMBER!>doSomething<!> <!TYPE_MISMATCH!>{
javaClass.<!INVISIBLE_MEMBER!>doSomething<!> {
bar()
}<!>
}
}
class X : JavaClass() {
fun foo(other: JavaClass) {
doSomething { bar() }
other.<!INVISIBLE_MEMBER!>doSomething<!> <!TYPE_MISMATCH!>{ bar() }<!>
other.<!INVISIBLE_MEMBER!>doSomething<!> { bar() }
}
}
@@ -7,18 +7,18 @@ open class MyClass private constructor(val x: Int) {
typealias MyAlias = MyClass
val test1 = <!NONE_APPLICABLE!>MyAlias<!>(1)
val test1a = <!NONE_APPLICABLE!>MyClass<!>(1)
val test1 = <!INVISIBLE_MEMBER!>MyAlias<!>(1)
val test1a = <!INVISIBLE_MEMBER!>MyClass<!>(1)
val test2 = <!NONE_APPLICABLE!>MyAlias<!>("")
val test2a = <!NONE_APPLICABLE!>MyClass<!>("")
val test2 = <!INVISIBLE_MEMBER!>MyAlias<!>("")
val test2a = <!INVISIBLE_MEMBER!>MyClass<!>("")
val test3 = MyAlias(1.0)
val test3a = MyClass(1.0)
class MyDerived : MyClass(1.0) {
val test4 = <!NONE_APPLICABLE!>MyAlias<!>(1)
val test4a = <!NONE_APPLICABLE!>MyClass<!>(1)
val test4 = <!INVISIBLE_MEMBER!>MyAlias<!>(1)
val test4a = <!INVISIBLE_MEMBER!>MyClass<!>(1)
val test5 = <!PROTECTED_CONSTRUCTOR_NOT_IN_SUPER_CALL!>MyAlias<!>("")
val test5a = <!PROTECTED_CONSTRUCTOR_NOT_IN_SUPER_CALL!>MyClass<!>("")
val test6 = MyAlias(1.0)
@@ -1,9 +1,9 @@
package
public val test1: [ERROR : Type for MyAlias(1)]
public val test1a: [ERROR : Type for MyClass(1)]
public val test2: [ERROR : Type for MyAlias("")]
public val test2a: [ERROR : Type for MyClass("")]
public val test1: MyAlias /* = MyClass */
public val test1a: MyClass
public val test2: MyAlias /* = MyClass */
public val test2a: MyClass
public val test3: MyAlias /* = MyClass */
public val test3a: MyClass
@@ -19,8 +19,8 @@ public open class MyClass {
public final class MyDerived : MyClass {
public constructor MyDerived()
public final val test4: [ERROR : Type for MyAlias(1)]
public final val test4a: [ERROR : Type for MyClass(1)]
public final val test4: MyAlias /* = MyClass */
public final val test4a: MyClass
public final val test5: MyAlias /* = MyClass */
public final val test5a: MyClass
public final val test6: MyAlias /* = MyClass */
@@ -14530,6 +14530,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("onlyPrivateOverloadsDiagnostic.kt")
public void testOnlyPrivateOverloadsDiagnostic() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/overload/onlyPrivateOverloadsDiagnostic.kt");
doTest(fileName);
}
@TestMetadata("OverloadFunRegularAndExt.kt")
public void testOverloadFunRegularAndExt() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/overload/OverloadFunRegularAndExt.kt");