Introduce FIR_IDENTICAL for FIR vs old frontend tests #KT-36879 Fixed

This commit is contained in:
Mikhail Glukhikh
2020-03-04 17:54:33 +03:00
parent 186e0b0cba
commit 8884cbe415
2268 changed files with 1175 additions and 19754 deletions
@@ -1,15 +0,0 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
fun foo(s: String) {}
object Scope {
fun foo(a: Int) {}
fun foo(b: Boolean) {}
fun <T> bar(f: (T) -> Unit): T = TODO()
fun test() {
val s: String = bar(::foo)
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
@@ -1,10 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
fun foo() {}
fun foo(s: String) {}
fun fn(f: () -> Unit) {}
fun test() {
fn(::foo)
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
fun foo() {}
@@ -1,16 +0,0 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER
import kotlin.reflect.KFunction2
class Foo
fun test(fn: KFunction2<Foo, Array<out String>, String>) = null
fun Foo.bar(vararg x: String) = ""
fun Foo.bar(vararg x: Int) = ""
fun actualTest() {
test(Foo::bar)
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER
@@ -1,14 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
fun test() {
foo(String::extensionReceiver)
foo(::valueParameter)
}
fun CharSequence.extensionReceiver(): CharSequence = TODO()
fun String.extensionReceiver(): String = TODO()
fun valueParameter(c: CharSequence): CharSequence = TODO()
fun valueParameter(s: String): CharSequence = TODO()
fun <R> foo(f: (String) -> R) {}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
fun test() {
@@ -1,18 +0,0 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER
import kotlin.reflect.KProperty1
class Inv<T>
fun <T, R : Number> foo(prop: KProperty1<T, R>, p: String = "") {}
fun <T, R> foo(prop: KProperty1<T, Inv<R>>, p: Int = 42) {}
class A {
val prop = 42
}
fun test() {
foo(A::prop)
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER
@@ -1,12 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
class Klass {
constructor(a: Int) {}
constructor(a: String) {}
}
fun user(f: (Int) -> Klass) {}
fun fn() {
user(::Klass)
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
class Klass {
@@ -1,13 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER, -UNUSED_VARIABLE
abstract class A {
inner class InnerInA
}
abstract class B : A()
fun foo(a: A) {
if (a is B) {
val v = a::InnerInA
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER, -UNUSED_VARIABLE
abstract class A {
@@ -1,11 +0,0 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER
class OverloadTest {
fun foo(bar: Boolean) {}
fun foo(bar: Any?) {}
}
inline fun <T : Any> OverloadTest.overload(value: T?, function: (T) -> Unit) {
}
fun OverloadTest.overloadBoolean(value: Boolean?) = overload(value, OverloadTest()::foo)
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER
class OverloadTest {
@@ -1,15 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
// KT-12751 Type inference failed with forEach and bound reference
class L<out T>
fun <T> L<T>.foo(action: (T) -> Unit): Unit {}
class B {
fun remove(charSequence: CharSequence) {}
}
fun foo(list: L<CharSequence>, b: B) {
list.foo(b::remove)
list.foo<CharSequence>(b::remove)
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
// KT-12751 Type inference failed with forEach and bound reference
@@ -1,13 +0,0 @@
// SKIP_TXT
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER
import kotlin.reflect.KProperty0
import kotlin.reflect.KProperty1
object A
fun <T : Any, TProperty : Any?> property(property: KProperty1<T, TProperty>) = A
fun <TProperty> property(property: KProperty0<TProperty>) = A
val <K> K.key get() : A = property(Map.Entry<K, *>::key) // overload resolution ambiguity in the NI, OK in the OI
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// SKIP_TXT
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER
@@ -1,25 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
// KT-8596 Rewrite at slice LEXICAL_SCOPE for nested class constructor reference in an argument position
class K {
class Nested
}
fun foo(f: Any) {}
fun test1() {
foo(K::Nested)
}
// KT-10567 Error: Rewrite at slice LEXICAL_SCOPE key: REFERENCE_EXPRESSION
class Foo(val a: String, val b: String)
fun test2() {
val prop : Foo.() -> String = if (true) {
Foo::a
} else {
Foo::b
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
// KT-8596 Rewrite at slice LEXICAL_SCOPE for nested class constructor reference in an argument position
@@ -1,16 +0,0 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER
interface Base
class Inv<K> : Base
fun foo(x: Int): Inv<Int> = TODO()
fun foo(y: String): Inv<String> = TODO()
fun <T, R : Number> bar(f: (T) -> Inv<R>, p: String = "") {}
fun <T, R : Base> bar(f: (T) -> Inv<R>, p: Int = 4) {}
fun test() {
bar(::foo)
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER
@@ -1,16 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
import kotlin.reflect.KProperty0
import kotlin.reflect.KProperty1
fun <R> property(property: KProperty0<R>): Int = 1
fun <T, R> property(property: KProperty1<T, R>): String = ""
val subject = ""
class O {
val subject = ""
}
val someProperty0 = property(::subject)
val someProperty1 = property(O::subject)
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
import kotlin.reflect.KProperty0
@@ -1,11 +0,0 @@
// !CHECK_TYPE
// KT-12322 Overload resolution ambiguity with constructor references when class has a companion object
class Foo {
companion object
}
fun test() {
val a = ::Foo
checkSubtype<() -> Foo>(a)
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !CHECK_TYPE
// KT-12322 Overload resolution ambiguity with constructor references when class has a companion object
@@ -1,13 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
// KT-12799 Bound callable references not resolved for overload
class C {
fun xf1(){}
fun xf1(s: String){}
}
fun foo(p: (String) -> Unit){}
fun bar(c: C) {
foo(c::xf1)
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
// KT-12799 Bound callable references not resolved for overload
@@ -1,16 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
// KT-9601 Chose maximally specific function in callable reference
open class A {
fun foo(a: Any) {}
fun fas(a: Int) {}
}
class B: A() {
fun foo(a: Int) {}
fun fas(a: Any) {}
}
fun test() {
B::foo
B::fas
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
// KT-9601 Chose maximally specific function in callable reference
@@ -1,19 +0,0 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
interface A
interface B
fun foo(i: A) {}
fun foo(b: B) {}
fun <T> bar1(f: (T) -> Unit): T = TODO()
fun <T> bar2(f: (T) -> Unit, e: T) {}
fun test(a: A, b: B) {
val expectedType1: A = bar1(::foo)
val expectedType2: B = bar1(::foo)
bar2(::foo, a)
bar2(::foo, b)
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
@@ -1,11 +0,0 @@
// !LANGUAGE: +NewInference
interface Base
fun <K> materialize(): K = TODO()
fun <T : Base> Base.transform(): T = materialize()
fun test(child: Base) {
child == child.transform()
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !LANGUAGE: +NewInference
interface Base
@@ -1,11 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
import kotlin.reflect.*
class A {
val x = 1
fun x() {}
}
fun f1(): KProperty<Int> = A::x // ok, property
fun f2(): (A) -> Unit = A::x // ok, function
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
import kotlin.reflect.*