[FIR] Additional errors to distinguish resolution to classifier cases

When a call is resolved to a classifier, only a single error message was
being used for multiple cases. This lead to confusion as the default
message may not be applicable to a given error case. Added additional
errors and messages to distinguish between these error cases.

#KT-57251 Fixed
This commit is contained in:
Brian Norman
2023-06-02 09:34:49 -05:00
committed by Space Team
parent ac79633590
commit 0ff9982b31
44 changed files with 582 additions and 39 deletions
@@ -43,7 +43,7 @@ fun f() {
C.O
C.O.InO
C.A()
C.<!RESOLUTION_TO_CLASSIFIER!>B<!>()
C.<!INNER_CLASS_CONSTRUCTOR_NO_RECEIVER!>B<!>()
C.E3.<!UNRESOLVED_REFERENCE!>O_O<!>
C.E3.<!UNRESOLVED_REFERENCE!>G<!>()
@@ -43,7 +43,7 @@ fun f() {
C.O
C.O.InO
C.A()
C.<!RESOLUTION_TO_CLASSIFIER!>B<!>()
C.<!INNER_CLASS_CONSTRUCTOR_NO_RECEIVER!>B<!>()
C.E3.<!UNRESOLVED_REFERENCE!>O_O<!>
C.E3.<!UNRESOLVED_REFERENCE!>G<!>()
@@ -6,7 +6,7 @@ typealias FunAlias = IsolatedFunFace
fun referIsolatedFunFace(iff: IsolatedFunFace) {}
fun callIsolatedFunFace() {
referIsolatedFunFace(<!RESOLUTION_TO_CLASSIFIER!>IsolatedFunFace<!> {})
referIsolatedFunFace(<!RESOLUTION_TO_CLASSIFIER!>FunAlias<!> {})
referIsolatedFunFace(<!INTERFACE_AS_FUNCTION!>IsolatedFunFace<!> {})
referIsolatedFunFace(<!INTERFACE_AS_FUNCTION!>FunAlias<!> {})
referIsolatedFunFace(<!ARGUMENT_TYPE_MISMATCH!>{}<!>)
}
@@ -0,0 +1,32 @@
class Outer1 {
class Nested
class C1 { val b = Nested() }
class C2(val b: Any = Nested())
inner class C3 { val b = Nested() }
inner class C4(val b: Any = Nested())
inner class Inner
class C5 { val b = <!INNER_CLASS_CONSTRUCTOR_NO_RECEIVER!>Inner<!>() }
class C6(val b: Any = <!INNER_CLASS_CONSTRUCTOR_NO_RECEIVER!>Inner<!>())
inner class C7 { val b = Inner() }
inner class C8(val b: Any = Inner())
}
class Outer2 {
class Nested {
fun foo() = Outer2()
fun bar() = <!INNER_CLASS_CONSTRUCTOR_NO_RECEIVER!>Inner<!>()
}
inner class Inner {
fun foo() = Outer2()
fun bar() = Nested()
}
fun foo() {
Nested()
Inner()
}
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
class Outer1 {
class Nested
@@ -0,0 +1,36 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
// SKIP_TXT
// FILE: Outer.kt
package abc
class Outer {
inner class Inner() {
constructor(x: Int) : this() {}
}
companion object {
fun baz() {
<!INNER_CLASS_CONSTRUCTOR_NO_RECEIVER!>Inner<!>()
<!INNER_CLASS_CONSTRUCTOR_NO_RECEIVER!>Inner<!>(1)
}
}
}
fun foo() {
Outer.<!INNER_CLASS_CONSTRUCTOR_NO_RECEIVER!>Inner<!>()
Outer.<!INNER_CLASS_CONSTRUCTOR_NO_RECEIVER!>Inner<!>(1)
}
// FILE: imported.kt
import abc.Outer
import abc.Outer.Inner
fun bar() {
<!INNER_CLASS_CONSTRUCTOR_NO_RECEIVER!>Inner<!>()
<!INNER_CLASS_CONSTRUCTOR_NO_RECEIVER!>Inner<!>(1)
with(Outer()) {
Inner()
Inner(1)
}
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
// SKIP_TXT
// FILE: Outer.kt
@@ -10,7 +10,7 @@ class Test {
}
fun more(): InnerClass {
val b = <!RESOLUTION_TO_CLASSIFIER!>InnerClass<!>()
val b = <!INNER_CLASS_CONSTRUCTOR_NO_RECEIVER!>InnerClass<!>()
val testVal = <!UNRESOLVED_REFERENCE!>inClass<!>
<!UNRESOLVED_REFERENCE!>foo<!>()
@@ -10,7 +10,7 @@ class Test {
}
fun more(): InnerClass {
val b = <!RESOLUTION_TO_CLASSIFIER!>InnerClass<!>()
val b = <!INNER_CLASS_CONSTRUCTOR_NO_RECEIVER!>InnerClass<!>()
val testVal = <!UNRESOLVED_REFERENCE!>inClass<!>
<!UNRESOLVED_REFERENCE!>foo<!>()
@@ -0,0 +1,17 @@
class Outer {
class Nested {
class NestedNested
}
inner class Inner {
inner class InnerInner
}
}
fun f1() = Outer()
fun f2() = Outer.Nested()
fun f3() = Outer.Nested.NestedNested()
fun f4() = Outer.<!INNER_CLASS_CONSTRUCTOR_NO_RECEIVER!>Inner<!>()
fun f5() = Outer.Inner.<!INNER_CLASS_CONSTRUCTOR_NO_RECEIVER!>InnerInner<!>()
fun f6() = Outer().Inner()
fun f7() = Outer().Inner().InnerInner()
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
class Outer {
class Nested {
class NestedNested
@@ -0,0 +1,24 @@
// MODULE: m1-common
// FILE: common.kt
expect class Foo
expect class Bar()
expect class Baz constructor()
expect class FooBar {
constructor()
}
fun test() {
<!EXPECT_CLASS_AS_FUNCTION!>Foo<!>()
Bar()
Baz()
FooBar()
}
// MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt
actual class Foo
actual class Bar
actual class Baz
actual class FooBar
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// MODULE: m1-common
// FILE: common.kt
@@ -34,7 +34,7 @@ interface KotlinXStringDemoInterface {
// FILE: StringDemoInterface.kt
actual typealias StringDemoInterface = KotlinXStringDemoInterface
<!ACTUAL_WITHOUT_EXPECT("actual fun StringDemoInterface.plusK(): <ERROR TYPE REF: Unresolved name: value>; The following declaration is incompatible: expect fun StringDemoInterface.plusK(): String")!>actual fun StringDemoIn<!INCOMPATIBLE_MATCHING!>terface.plusK() = <!RESOLUTION_TO_CLASSIFIER!>StringValue<!>(value).plus("K")<!>.<!UNRESOLVED_REFERENCE!>value<!><!>
<!ACTUAL_WITHOUT_EXPECT("actual fun StringDemoInterface.plusK(): <ERROR TYPE REF: Unresolved name: value>; The following declaration is incompatible: expect fun StringDemoInterface.plusK(): String")!>actual fun StringDemoIn<!INCOMPATIBLE_MATCHING!>terface.plusK() = <!EXPECT_CLASS_AS_FUNCTION!>StringValue<!>(value).plus("K")<!>.<!UNRESOLVED_REFERENCE!>value<!><!>
// FILE: main.kt
class StringDemo(override val value: String) : StringDemoInterface
@@ -0,0 +1,16 @@
// KT-4827 UOE at PackageType.throwException()
// EA-53605
public interface TestInterface {
}
class C {
inner class I {
}
}
fun f() {
<!INTERFACE_AS_FUNCTION!>TestInterface<!>()
C.<!INNER_CLASS_CONSTRUCTOR_NO_RECEIVER!>I<!>()
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// KT-4827 UOE at PackageType.throwException()
// EA-53605
@@ -0,0 +1,6 @@
interface MutableMatrix<T> {
}
fun <T> toMutableMatrix(): MutableMatrix<T> {
return <!INTERFACE_AS_FUNCTION!>MutableMatrix<!><T>()
}
@@ -1,7 +1,6 @@
// FIR_IDENTICAL
interface MutableMatrix<T> {
}
fun <T> toMutableMatrix(): MutableMatrix<T> {
return <!RESOLUTION_TO_CLASSIFIER!>MutableMatrix<!><T>()
}
}
@@ -6,7 +6,7 @@ object B
class C
fun test() {
val interface_as_fun = <!RESOLUTION_TO_CLASSIFIER!>A<!>()
val interface_as_fun = <!INTERFACE_AS_FUNCTION!>A<!>()
val interface_as_val = <!NO_COMPANION_OBJECT!>A<!>
val object_as_fun = <!UNRESOLVED_REFERENCE!>B<!>()
@@ -8,7 +8,7 @@ object X {
}
fun testX() {
val interface_as_fun = X.<!RESOLUTION_TO_CLASSIFIER!>A<!>()
val interface_as_fun = X.<!INTERFACE_AS_FUNCTION!>A<!>()
val interface_as_val = X.<!NO_COMPANION_OBJECT!>A<!>
val object_as_fun = X.<!UNRESOLVED_REFERENCE!>B<!>()
@@ -23,7 +23,7 @@ class Y {
}
fun testY() {
val interface_as_fun = Y.<!RESOLUTION_TO_CLASSIFIER!>A<!>()
val interface_as_fun = Y.<!INTERFACE_AS_FUNCTION!>A<!>()
val interface_as_val = Y.<!NO_COMPANION_OBJECT!>A<!>
val object_as_fun = Y.<!UNRESOLVED_REFERENCE!>B<!>()
@@ -0,0 +1,65 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
class A(
n: Nested = foo(),
n2: Nested = Nested(),
inn: Inner = null!!,
inn2: Inner = <!INNER_CLASS_CONSTRUCTOR_NO_RECEIVER!>Inner<!>(),
i: Interface = null!!,
c: Int = CONST,
cc: Int = Companion.CONST,
cn: Int = Nested.CONST,
ci: Int = Interface.CONST,
t1: Int = <!UNRESOLVED_REFERENCE!>a<!>,
t2: Int = <!UNRESOLVED_REFERENCE!>b<!>()
) {
constructor(
dummy: Int,
n: Nested = foo(),
n2: Nested = Nested(),
inn: Inner = null!!,
inn2: Inner = <!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>Inner<!>(),
i: Interface = null!!,
c: Int = CONST,
cc: Int = Companion.CONST,
cn: Int = Nested.CONST,
ci: Int = Interface.CONST,
t1: Int = <!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>a<!>,
t2: Int = <!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>b<!>()
) : this(
foo(),
Nested(),
inn,
<!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>Inner<!>(),
i,
CONST,
Companion.CONST,
Nested.CONST,
Interface.CONST,
<!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>a<!>,
<!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>b<!>()
)
class Nested {
companion object {
const val CONST = 2
}
}
inner class Inner
interface Interface {
companion object {
const val CONST = 3
}
}
val a = 1
fun b() = 2
companion object {
const val CONST = 1
fun foo(): Nested = null!!
}
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
class A(
@@ -0,0 +1,50 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
interface I
open class S(
n: A.Nested,
n2: A.Nested,
inn: A.Inner,
c: Int,
cc: Int,
cn: Int,
ci: Int,
t1: Int,
t2: Int
) : I
class A : I by S(
foo(),
Nested(),
<!INNER_CLASS_CONSTRUCTOR_NO_RECEIVER!>Inner<!>(),
CONST,
Companion.CONST,
Nested.CONST,
Interface.CONST,
<!UNRESOLVED_REFERENCE!>a<!>,
<!UNRESOLVED_REFERENCE!>b<!>()
) {
class Nested {
companion object {
const val CONST = 2
}
}
inner class Inner
interface Interface {
companion object {
const val CONST = 3
}
}
val a = 1
fun b() = 2
companion object {
const val CONST = 1
fun foo(): Nested = null!!
}
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
interface I
@@ -0,0 +1,48 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
open class S(
n: A.Nested,
n2: A.Nested,
inn: A.Inner,
c: Int,
cc: Int,
cn: Int,
ci: Int,
t1: Int,
t2: Int
)
class A : S (
foo(),
Nested(),
<!INNER_CLASS_CONSTRUCTOR_NO_RECEIVER!>Inner<!>(),
CONST,
Companion.CONST,
Nested.CONST,
Interface.CONST,
<!UNRESOLVED_REFERENCE!>a<!>,
<!UNRESOLVED_REFERENCE!>b<!>()
) {
class Nested {
companion object {
const val CONST = 2
}
}
inner class Inner
interface Interface {
companion object {
const val CONST = 3
}
}
val a = 1
fun b() = 2
companion object {
const val CONST = 1
fun foo(): Nested = null!!
}
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
open class S(
@@ -35,10 +35,10 @@ class E: A() {
object Z {
init {
<!RESOLUTION_TO_CLASSIFIER!>B<!>().<!UNRESOLVED_REFERENCE!>foo<!>()
<!RESOLUTION_TO_CLASSIFIER!>B<!>().<!UNRESOLVED_REFERENCE!>bar<!>()
<!INNER_CLASS_CONSTRUCTOR_NO_RECEIVER!>B<!>().<!UNRESOLVED_REFERENCE!>foo<!>()
<!INNER_CLASS_CONSTRUCTOR_NO_RECEIVER!>B<!>().<!UNRESOLVED_REFERENCE!>bar<!>()
<!RESOLUTION_TO_CLASSIFIER!>D<!>()
<!INNER_CLASS_CONSTRUCTOR_NO_RECEIVER!>D<!>()
<!UNRESOLVED_REFERENCE!>C<!>()
}
}
@@ -60,7 +60,7 @@ class F: A() {
companion object {
init {
B().fas()
<!RESOLUTION_TO_CLASSIFIER!>D<!>().<!UNRESOLVED_REFERENCE!>f<!>()
<!INNER_CLASS_CONSTRUCTOR_NO_RECEIVER!>D<!>().<!UNRESOLVED_REFERENCE!>f<!>()
}
}
}
@@ -0,0 +1,90 @@
// FILE: A.java
public interface A {
public class A_S { // static
}
}
// FILE: B.java
public class B {
public static class B_S {
}
public class B_ {
}
}
// FILE: C.java
public class C extends B implements A {
}
// FILE: 1.kt
class X: A {
val a_s: <!UNRESOLVED_REFERENCE!>A_S<!> = null!!
init {
<!UNRESOLVED_REFERENCE!>A_S<!>()
A.A_S()
X.<!UNRESOLVED_REFERENCE!>A_S<!>()
}
object xD {
val a_: <!UNRESOLVED_REFERENCE!>A_S<!> = null!!
init {
<!UNRESOLVED_REFERENCE!>A_S<!>()
}
}
}
class Y: B() {
val b_: B_ = null!!
val b_s: B_S = null!!
init {
B_()
B.<!INNER_CLASS_CONSTRUCTOR_NO_RECEIVER!>B_<!>()
Y.<!UNRESOLVED_REFERENCE!>B_<!>()
B_S()
B.B_S()
Y.<!UNRESOLVED_REFERENCE!>B_S<!>()
}
object X {
val b_: B_ = null!!
val b_s: B_S = null!!
init {
<!INNER_CLASS_CONSTRUCTOR_NO_RECEIVER!>B_<!>()
B_S()
}
}
}
class Z: C() {
val a_s: <!UNRESOLVED_REFERENCE!>A_S<!> = null!!
val b_: B_ = null!!
val b_s: B_S = null!!
init {
<!UNRESOLVED_REFERENCE!>A_S<!>()
B_()
B_S()
}
object X {
val a_s: <!UNRESOLVED_REFERENCE!>A_S<!> = null!!
val b_: B_ = null!!
val b_s: B_S = null!!
init {
<!UNRESOLVED_REFERENCE!>A_S<!>()
<!INNER_CLASS_CONSTRUCTOR_NO_RECEIVER!>B_<!>()
B_S()
}
}
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// FILE: A.java
public interface A {
public class A_S { // static
@@ -0,0 +1,82 @@
// FILE: A.java
public interface A {
class A_S {
}
}
// FILE: B.java
public class B {
static class B_S {
}
class B_ {
}
}
// FILE: C.java
public class C extends B implements A {
}
// FILE: 1.kt
interface E {
class E_S
}
open class D: C(), E
// FILE: F.java
public class F extends D {
}
// FILE: 2.kt
class X: D() {
init {
B_()
B.<!INNER_CLASS_CONSTRUCTOR_NO_RECEIVER!>B_<!>()
C.<!UNRESOLVED_REFERENCE!>B_<!>()
D.<!UNRESOLVED_REFERENCE!>B_<!>()
X.<!UNRESOLVED_REFERENCE!>B_<!>()
<!UNRESOLVED_REFERENCE!>A_S<!>()
A.A_S()
C.<!UNRESOLVED_REFERENCE!>A_S<!>()
D.<!UNRESOLVED_REFERENCE!>A_S<!>()
X.<!UNRESOLVED_REFERENCE!>A_S<!>()
B_S()
B.B_S()
C.<!UNRESOLVED_REFERENCE!>B_S<!>()
D.<!UNRESOLVED_REFERENCE!>B_S<!>()
X.<!UNRESOLVED_REFERENCE!>B_S<!>()
<!UNRESOLVED_REFERENCE!>E_S<!>()
E.E_S()
D.<!UNRESOLVED_REFERENCE!>E_S<!>()
X.<!UNRESOLVED_REFERENCE!>E_S<!>()
}
}
class Y: F() {
init {
B_()
F.<!UNRESOLVED_REFERENCE!>B_<!>()
Y.<!UNRESOLVED_REFERENCE!>B_<!>()
<!UNRESOLVED_REFERENCE!>A_S<!>()
F.<!UNRESOLVED_REFERENCE!>A_S<!>()
Y.<!UNRESOLVED_REFERENCE!>A_S<!>()
B_S()
F.<!UNRESOLVED_REFERENCE!>B_S<!>()
Y.<!UNRESOLVED_REFERENCE!>B_S<!>()
<!UNRESOLVED_REFERENCE!>E_S<!>()
F.<!UNRESOLVED_REFERENCE!>E_S<!>()
Y.<!UNRESOLVED_REFERENCE!>E_S<!>()
}
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// FILE: A.java
public interface A {
class A_S {
@@ -17,8 +17,8 @@ typealias TI = Interface
object AnObject
typealias TO = AnObject
val test6 = <!RESOLUTION_TO_CLASSIFIER!>TI<!>()
val test6a = <!RESOLUTION_TO_CLASSIFIER!>Interface<!>()
val test6 = <!INTERFACE_AS_FUNCTION!>TI<!>()
val test6a = <!INTERFACE_AS_FUNCTION!>Interface<!>()
val test7 = <!UNRESOLVED_REFERENCE!>TO<!>()
val test7a = <!UNRESOLVED_REFERENCE!>AnObject<!>()
@@ -0,0 +1,6 @@
interface IFoo
typealias Test = IFoo
val testAsFunction = <!INTERFACE_AS_FUNCTION!>Test<!>()
val testAsValue = <!NO_COMPANION_OBJECT!>Test<!>
@@ -1,7 +1,6 @@
// FIR_IDENTICAL
interface IFoo
typealias Test = IFoo
val testAsFunction = <!RESOLUTION_TO_CLASSIFIER!>Test<!>()
val testAsValue = <!NO_COMPANION_OBJECT!>Test<!>
val testAsValue = <!NO_COMPANION_OBJECT!>Test<!>
@@ -26,9 +26,9 @@ class Outer {
}
typealias Test5 = Outer.Inner
val test5 = <!RESOLUTION_TO_CLASSIFIER!>Test5<!>()
val test5a = Outer.<!RESOLUTION_TO_CLASSIFIER!>Inner<!>()
val test5b = Outer.<!RESOLUTION_TO_CLASSIFIER!>TestInner<!>()
val test5 = <!INNER_CLASS_CONSTRUCTOR_NO_RECEIVER!>Test5<!>()
val test5a = Outer.<!INNER_CLASS_CONSTRUCTOR_NO_RECEIVER!>Inner<!>()
val test5b = Outer.<!INNER_CLASS_CONSTRUCTOR_NO_RECEIVER!>TestInner<!>()
val test5c = Outer().<!UNRESOLVED_REFERENCE!>TestInner<!>()
val test5d = Outer().Inner()
val test5e = Outer().Test5()