[FIR] Implement RESOLUTION_TO_CLASSIFIER

This commit is contained in:
Ivan Kochurkin
2021-06-30 18:33:20 +03:00
parent 2574dc907c
commit d4e1cded59
51 changed files with 88 additions and 483 deletions
@@ -1,10 +0,0 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION
import A.Inner
class A {
inner class Inner
}
fun main() {
::Inner
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_EXPRESSION
import A.Inner
@@ -1,34 +0,0 @@
// !CHECK_TYPE
// !DIAGNOSTICS: -UNUSED_EXPRESSION
// !LANGUAGE: +CallableReferencesToClassMembersWithEmptyLHS
import kotlin.reflect.KFunction1
class A {
inner class Inner
fun main() {
::Inner
val y = A::Inner
checkSubtype<KFunction1<A, Inner>>(y)
}
companion object {
fun main() {
::Inner
val y = A::Inner
checkSubtype<KFunction1<A, A.Inner>>(y)
}
}
}
class B {
fun main() {
::<!UNRESOLVED_REFERENCE!>Inner<!>
val y = A::Inner
checkSubtype<KFunction1<A, A.Inner>>(y)
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !CHECK_TYPE
// !DIAGNOSTICS: -UNUSED_EXPRESSION
// !LANGUAGE: +CallableReferencesToClassMembersWithEmptyLHS
@@ -43,7 +43,7 @@ fun f() {
C.O
C.O.InO
C.A()
C.<!UNRESOLVED_REFERENCE!>B<!>()
C.<!RESOLUTION_TO_CLASSIFIER!>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.<!UNRESOLVED_REFERENCE!>B<!>()
C.<!RESOLUTION_TO_CLASSIFIER!>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(<!UNRESOLVED_REFERENCE!>IsolatedFunFace<!> {})
referIsolatedFunFace(<!UNRESOLVED_REFERENCE!>FunAlias<!> {})
referIsolatedFunFace(<!RESOLUTION_TO_CLASSIFIER!>IsolatedFunFace<!> {})
referIsolatedFunFace(<!RESOLUTION_TO_CLASSIFIER!>FunAlias<!> {})
referIsolatedFunFace(<!ARGUMENT_TYPE_MISMATCH!>{}<!>)
}
@@ -1,32 +0,0 @@
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 C6(val b: Any = Inner())
inner class C7 { val b = Inner() }
inner class C8(val b: Any = Inner())
}
class Outer2 {
class Nested {
fun foo() = Outer2()
fun bar() = Inner()
}
inner class Inner {
fun foo() = Outer2()
fun bar() = Nested()
}
fun foo() {
Nested()
Inner()
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
class Outer1 {
class Nested
@@ -1,36 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
// SKIP_TXT
// FILE: Outer.kt
package abc
class Outer {
inner class Inner() {
constructor(x: Int) : this() {}
}
companion object {
fun baz() {
Inner()
Inner(1)
}
}
}
fun foo() {
Outer.<!UNRESOLVED_REFERENCE!>Inner<!>()
Outer.<!UNRESOLVED_REFERENCE!>Inner<!>(1)
}
// FILE: imported.kt
import abc.Outer
import abc.Outer.Inner
fun bar() {
Inner()
Inner(1)
with(Outer()) {
Inner()
Inner(1)
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
// SKIP_TXT
// FILE: Outer.kt
@@ -12,8 +12,8 @@ class Outer {
fun baz() {
// Diagnostic here could be better (why can't I call the constructor above?)
Inner()
Inner(1)
Inner(<!NO_VALUE_FOR_PARAMETER!>)<!>
Inner(<!ARGUMENT_TYPE_MISMATCH!>1<!>)
Inner("")
}
}
@@ -31,8 +31,8 @@ import abc.Outer.Inner
import abc.Outer.Companion.Inner
fun bar() {
Inner()
Inner(1)
Inner(<!NO_VALUE_FOR_PARAMETER!>)<!>
Inner(<!ARGUMENT_TYPE_MISMATCH!>1<!>)
Inner("")
with(Outer()) {
@@ -10,7 +10,7 @@ class Test {
}
fun more(): InnerClass {
val b = InnerClass()
val b = <!RESOLUTION_TO_CLASSIFIER!>InnerClass<!>()
val testVal = <!UNRESOLVED_REFERENCE!>inClass<!>
<!UNRESOLVED_REFERENCE!>foo<!>()
@@ -10,7 +10,7 @@ class Test {
}
fun more(): InnerClass {
val b = InnerClass()
val b = <!RESOLUTION_TO_CLASSIFIER!>InnerClass<!>()
val testVal = <!UNRESOLVED_REFERENCE!>inClass<!>
<!UNRESOLVED_REFERENCE!>foo<!>()
@@ -1,17 +0,0 @@
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.<!UNRESOLVED_REFERENCE!>Inner<!>()
fun f5() = Outer.Inner.<!UNRESOLVED_REFERENCE!>InnerInner<!>()
fun f6() = Outer().Inner()
fun f7() = Outer().Inner().InnerInner()
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
class Outer {
class Nested {
class NestedNested
@@ -1,25 +0,0 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect class Foo
expect class Bar()
expect class Baz constructor()
expect class FooBar {
constructor()
}
fun test() {
<!UNRESOLVED_REFERENCE!>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,3 +1,4 @@
// FIR_IDENTICAL
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
@@ -1,16 +0,0 @@
// KT-4827 UOE at PackageType.throwException()
// EA-53605
public interface TestInterface {
}
class C {
inner class I {
}
}
fun f() {
<!UNRESOLVED_REFERENCE!>TestInterface<!>()
C.<!UNRESOLVED_REFERENCE!>I<!>()
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// KT-4827 UOE at PackageType.throwException()
// EA-53605
@@ -1,6 +0,0 @@
interface MutableMatrix<T> {
}
fun <T> toMutableMatrix(): MutableMatrix<T> {
return <!UNRESOLVED_REFERENCE!>MutableMatrix<!><T>()
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
interface MutableMatrix<T> {
}
@@ -6,7 +6,7 @@ object B
class C
fun test() {
val interface_as_fun = <!UNRESOLVED_REFERENCE!>A<!>()
val interface_as_fun = <!RESOLUTION_TO_CLASSIFIER!>A<!>()
val interface_as_val = <!NO_COMPANION_OBJECT!>A<!>
val object_as_fun = <!INVISIBLE_REFERENCE!>B<!>()
@@ -8,7 +8,7 @@ object X {
}
fun testX() {
val interface_as_fun = X.<!UNRESOLVED_REFERENCE!>A<!>()
val interface_as_fun = X.<!RESOLUTION_TO_CLASSIFIER!>A<!>()
val interface_as_val = X.<!NO_COMPANION_OBJECT!>A<!>
val object_as_fun = X.<!INVISIBLE_REFERENCE!>B<!>()
@@ -23,7 +23,7 @@ class Y {
}
fun testY() {
val interface_as_fun = Y.<!UNRESOLVED_REFERENCE!>A<!>()
val interface_as_fun = Y.<!RESOLUTION_TO_CLASSIFIER!>A<!>()
val interface_as_val = Y.<!NO_COMPANION_OBJECT!>A<!>
val object_as_fun = Y.<!INVISIBLE_REFERENCE!>B<!>()
@@ -4,7 +4,7 @@ class A(
n: Nested = foo(),
n2: Nested = Nested(),
inn: Inner = null!!,
inn2: Inner = Inner(),
inn2: Inner = <!RESOLUTION_TO_CLASSIFIER!>Inner<!>(),
i: Interface = null!!,
c: Int = CONST,
cc: Int = Companion.CONST,
@@ -19,7 +19,7 @@ class A(
n: Nested = foo(),
n2: Nested = Nested(),
inn: Inner = null!!,
inn2: Inner = Inner(),
inn2: Inner = <!RESOLUTION_TO_CLASSIFIER!>Inner<!>(),
i: Interface = null!!,
c: Int = CONST,
cc: Int = Companion.CONST,
@@ -31,7 +31,7 @@ class A(
foo(),
Nested(),
inn,
Inner(),
<!RESOLUTION_TO_CLASSIFIER!>Inner<!>(),
i,
CONST,
Companion.CONST,
@@ -1,50 +0,0 @@
// !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(),
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,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
interface I
@@ -1,48 +0,0 @@
// !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(),
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,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
open class S(
@@ -17,7 +17,7 @@ class A : S {
constructor() : super(
foo(),
Nested(),
Inner(),
<!RESOLUTION_TO_CLASSIFIER!>Inner<!>(),
CONST,
Companion.CONST,
Nested.CONST,
@@ -35,10 +35,10 @@ class E: A() {
object Z {
init {
B().foo()
B().<!UNRESOLVED_REFERENCE!>bar<!>()
<!RESOLUTION_TO_CLASSIFIER!>B<!>().<!UNRESOLVED_REFERENCE!>foo<!>()
<!RESOLUTION_TO_CLASSIFIER!>B<!>().<!UNRESOLVED_REFERENCE!>bar<!>()
D()
<!RESOLUTION_TO_CLASSIFIER!>D<!>()
<!UNRESOLVED_REFERENCE!>C<!>()
}
}
@@ -60,7 +60,7 @@ class F: A() {
companion object {
init {
B().fas()
D().f()
<!RESOLUTION_TO_CLASSIFIER!>D<!>().<!UNRESOLVED_REFERENCE!>f<!>()
}
}
}
@@ -1,90 +0,0 @@
// 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.<!UNRESOLVED_REFERENCE!>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 {
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<!>()
B_()
B_S()
}
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// FILE: A.java
public interface A {
public class A_S { // static
@@ -1,82 +0,0 @@
// 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.<!UNRESOLVED_REFERENCE!>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,3 +1,4 @@
// FIR_IDENTICAL
// FILE: A.java
public interface A {
class A_S {
@@ -6,6 +6,6 @@ class Outer {
}
constructor(x: Int)
constructor(x: Int, y: Int, z: Int = x + Inner().prop <!OVERLOAD_RESOLUTION_AMBIGUITY!>+<!> <!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>.<!UNRESOLVED_REFERENCE!>Inner<!>().prop) :
this(x + Inner().prop <!OVERLOAD_RESOLUTION_AMBIGUITY!>+<!> <!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>.<!UNRESOLVED_REFERENCE!>Inner<!>().prop)
constructor(x: Int, y: Int, z: Int = <!TYPE_MISMATCH!>x <!OVERLOAD_RESOLUTION_AMBIGUITY!>+<!> <!RESOLUTION_TO_CLASSIFIER!>Inner<!>().<!UNRESOLVED_REFERENCE!>prop<!> + <!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>.<!UNRESOLVED_REFERENCE!>Inner<!>().prop<!>) :
this(<!ARGUMENT_TYPE_MISMATCH!>x <!OVERLOAD_RESOLUTION_AMBIGUITY!>+<!> <!RESOLUTION_TO_CLASSIFIER!>Inner<!>().<!UNRESOLVED_REFERENCE!>prop<!> + <!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>.<!UNRESOLVED_REFERENCE!>Inner<!>().prop<!>)
}
@@ -17,8 +17,8 @@ typealias TI = Interface
object AnObject
typealias TO = AnObject
val test6 = <!UNRESOLVED_REFERENCE!>TI<!>()
val test6a = <!UNRESOLVED_REFERENCE!>Interface<!>()
val test6 = <!RESOLUTION_TO_CLASSIFIER!>TI<!>()
val test6a = <!RESOLUTION_TO_CLASSIFIER!>Interface<!>()
val test7 = <!INVISIBLE_REFERENCE!>TO<!>()
val test7a = <!INVISIBLE_REFERENCE!>AnObject<!>()
@@ -2,5 +2,5 @@ interface IFoo
typealias Test = IFoo
val testAsFunction = <!UNRESOLVED_REFERENCE!>Test<!>()
val testAsValue = Test
val testAsFunction = <!RESOLUTION_TO_CLASSIFIER!>Test<!>()
val testAsValue = Test
@@ -26,8 +26,8 @@ class Outer {
}
typealias Test5 = Outer.Inner
val test5 = <!UNRESOLVED_REFERENCE!>Test5<!>()
val test5a = Outer.<!UNRESOLVED_REFERENCE!>Inner<!>()
val test5 = <!RESOLUTION_TO_CLASSIFIER!>Test5<!>()
val test5a = Outer.<!RESOLUTION_TO_CLASSIFIER!>Inner<!>()
val test5b = Outer.<!UNRESOLVED_REFERENCE!>TestInner<!>()
val test5c = Outer().<!UNRESOLVED_REFERENCE!>TestInner<!>()
val test5d = Outer().Inner()