Skip to content

Commit 4b3ffd9

Browse files
committed
If all candidates are invisible then don't report ambiguity
#KT-10045 Fixed
1 parent cd1ae7f commit 4b3ffd9

File tree

11 files changed

+53
-21
lines changed

11 files changed

+53
-21
lines changed

compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ class CandidateResolver(
196196
getReceiverValueWithSmartCast(receiverArgument, smartCastType), candidateDescriptor, scope.ownerDescriptor)
197197
return if (invisibleMember != null) {
198198
tracing.invisibleMember(trace, invisibleMember)
199-
OTHER_ERROR
199+
INVISIBLE_MEMBER_ERROR
200200
} else {
201201
SUCCESS
202202
}

compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/results/ResolutionStatus.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public enum ResolutionStatus {
2525
UNSAFE_CALL_ERROR,
2626
WRONG_NUMBER_OF_TYPE_ARGUMENTS_ERROR,
2727
UNSTABLE_SMARTCAST_ERROR,
28+
INVISIBLE_MEMBER_ERROR,
2829
OTHER_ERROR,
2930
ARGUMENTS_MAPPING_ERROR,
3031
// '1.foo()' shouldn't be resolved to 'fun String.foo()'
@@ -42,6 +43,7 @@ public enum ResolutionStatus {
4243
EnumSet.of(UNSAFE_CALL_ERROR), // weakest
4344
EnumSet.of(WRONG_NUMBER_OF_TYPE_ARGUMENTS_ERROR),
4445
EnumSet.of(UNSTABLE_SMARTCAST_ERROR),
46+
EnumSet.of(INVISIBLE_MEMBER_ERROR),
4547
EnumSet.of(OTHER_ERROR),
4648
EnumSet.of(ARGUMENTS_MAPPING_ERROR),
4749
EnumSet.of(RECEIVER_TYPE_ERROR),

compiler/testData/diagnostics/tests/imports/ImportOverloadFunctions.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ import k.all
2727

2828
fun test() {
2929
<!INVISIBLE_MEMBER!>zero<!>()
30-
<!NONE_APPLICABLE!>zero<!>(1)
31-
<!NONE_APPLICABLE!>zero<!>("")
30+
<!INVISIBLE_MEMBER!>zero<!>(1)
31+
<!INVISIBLE_MEMBER!>zero<!>("")
3232

3333
one()
3434
one(<!TOO_MANY_ARGUMENTS!>1<!>)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// !DIAGNOSTICS: -UNUSED_PARAMETER
2+
3+
class A {
4+
private fun foo(i: Int) {}
5+
private fun foo(s: String) {}
6+
}
7+
8+
fun test(a: A) {
9+
a.<!INVISIBLE_MEMBER!>foo<!>(3)
10+
a.<!NONE_APPLICABLE!>foo<!>()
11+
}
12+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package
2+
3+
public fun test(/*0*/ a: A): kotlin.Unit
4+
5+
public final class A {
6+
public constructor A()
7+
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
8+
private final fun foo(/*0*/ i: kotlin.Int): kotlin.Unit
9+
private final fun foo(/*0*/ s: kotlin.String): kotlin.Unit
10+
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
11+
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
12+
}

compiler/testData/diagnostics/tests/scopes/protectedVisibility/syntheticSAMExtensions.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Data(var x: A)
1111

1212
class B : A() {
1313
fun baz(a: A, b: B, d: Data) {
14-
a.<!INVISIBLE_MEMBER!>foo<!> <!TYPE_MISMATCH!>{ }<!>
14+
a.<!INVISIBLE_MEMBER!>foo<!> { }
1515

1616
b.foo { }
1717

@@ -26,5 +26,5 @@ class B : A() {
2626
}
2727

2828
fun baz(a: A) {
29-
a.<!INVISIBLE_MEMBER!>foo<!> <!TYPE_MISMATCH!>{ }<!>
29+
a.<!INVISIBLE_MEMBER!>foo<!> { }
3030
}

compiler/testData/diagnostics/tests/syntheticExtensions/samAdapters/PackageLocal.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package k
44
import JavaClass
55

66
fun foo(javaClass: JavaClass) {
7-
javaClass.<!INVISIBLE_MEMBER!>doSomething<!> <!TYPE_MISMATCH!>{ }<!>
7+
javaClass.<!INVISIBLE_MEMBER!>doSomething<!> { }
88
}
99

1010
// FILE: KotlinFile2.kt

compiler/testData/diagnostics/tests/syntheticExtensions/samAdapters/Protected.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ package k
44
import JavaClass
55

66
fun foo(javaClass: JavaClass) {
7-
javaClass.<!INVISIBLE_MEMBER!>doSomething<!> <!TYPE_MISMATCH!>{
7+
javaClass.<!INVISIBLE_MEMBER!>doSomething<!> {
88
bar()
9-
}<!>
9+
}
1010
}
1111

1212
class X : JavaClass() {
1313
fun foo(other: JavaClass) {
1414
doSomething { bar() }
15-
other.<!INVISIBLE_MEMBER!>doSomething<!> <!TYPE_MISMATCH!>{ bar() }<!>
15+
other.<!INVISIBLE_MEMBER!>doSomething<!> { bar() }
1616
}
1717
}
1818

compiler/testData/diagnostics/tests/typealias/typeAliasConstructorWrongVisibility.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@ open class MyClass private constructor(val x: Int) {
77

88
typealias MyAlias = MyClass
99

10-
val test1 = <!NONE_APPLICABLE!>MyAlias<!>(1)
11-
val test1a = <!NONE_APPLICABLE!>MyClass<!>(1)
10+
val test1 = <!INVISIBLE_MEMBER!>MyAlias<!>(1)
11+
val test1a = <!INVISIBLE_MEMBER!>MyClass<!>(1)
1212

13-
val test2 = <!NONE_APPLICABLE!>MyAlias<!>("")
14-
val test2a = <!NONE_APPLICABLE!>MyClass<!>("")
13+
val test2 = <!INVISIBLE_MEMBER!>MyAlias<!>("")
14+
val test2a = <!INVISIBLE_MEMBER!>MyClass<!>("")
1515

1616
val test3 = MyAlias(1.0)
1717
val test3a = MyClass(1.0)
1818

1919
class MyDerived : MyClass(1.0) {
20-
val test4 = <!NONE_APPLICABLE!>MyAlias<!>(1)
21-
val test4a = <!NONE_APPLICABLE!>MyClass<!>(1)
20+
val test4 = <!INVISIBLE_MEMBER!>MyAlias<!>(1)
21+
val test4a = <!INVISIBLE_MEMBER!>MyClass<!>(1)
2222
val test5 = <!PROTECTED_CONSTRUCTOR_NOT_IN_SUPER_CALL!>MyAlias<!>("")
2323
val test5a = <!PROTECTED_CONSTRUCTOR_NOT_IN_SUPER_CALL!>MyClass<!>("")
2424
val test6 = MyAlias(1.0)

compiler/testData/diagnostics/tests/typealias/typeAliasConstructorWrongVisibility.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package
22

3-
public val test1: [ERROR : Type for MyAlias(1)]
4-
public val test1a: [ERROR : Type for MyClass(1)]
5-
public val test2: [ERROR : Type for MyAlias("")]
6-
public val test2a: [ERROR : Type for MyClass("")]
3+
public val test1: MyAlias /* = MyClass */
4+
public val test1a: MyClass
5+
public val test2: MyAlias /* = MyClass */
6+
public val test2a: MyClass
77
public val test3: MyAlias /* = MyClass */
88
public val test3a: MyClass
99

@@ -19,8 +19,8 @@ public open class MyClass {
1919

2020
public final class MyDerived : MyClass {
2121
public constructor MyDerived()
22-
public final val test4: [ERROR : Type for MyAlias(1)]
23-
public final val test4a: [ERROR : Type for MyClass(1)]
22+
public final val test4: MyAlias /* = MyClass */
23+
public final val test4a: MyClass
2424
public final val test5: MyAlias /* = MyClass */
2525
public final val test5a: MyClass
2626
public final val test6: MyAlias /* = MyClass */

compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14530,6 +14530,12 @@ public void testLocalFunctions() throws Exception {
1453014530
doTest(fileName);
1453114531
}
1453214532

14533+
@TestMetadata("onlyPrivateOverloadsDiagnostic.kt")
14534+
public void testOnlyPrivateOverloadsDiagnostic() throws Exception {
14535+
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/overload/onlyPrivateOverloadsDiagnostic.kt");
14536+
doTest(fileName);
14537+
}
14538+
1453314539
@TestMetadata("OverloadFunRegularAndExt.kt")
1453414540
public void testOverloadFunRegularAndExt() throws Exception {
1453514541
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/overload/OverloadFunRegularAndExt.kt");

0 commit comments

Comments
 (0)