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 @@
// !CHECK_TYPE
import kotlin.reflect.KProperty1
open class Base {
val foo: Int = 42
}
open class Derived : Base()
fun test() {
val o = Base::foo
checkSubtype<KProperty1<Base, Int>>(o)
checkSubtype<Int>(o.get(Derived()))
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !CHECK_TYPE
import kotlin.reflect.KProperty1
@@ -1,12 +0,0 @@
// !DIAGNOSTICS:-UNUSED_VARIABLE
import kotlin.reflect.*
class A(var g: A) {
val f: Int = 0
fun test() {
val fRef: KProperty1<A, Int> = A::f
val gRef: KMutableProperty1<A, A> = A::g
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS:-UNUSED_VARIABLE
import kotlin.reflect.*
@@ -1,10 +0,0 @@
// !CHECK_TYPE
val Any?.meaning: Int
get() = 42
fun test() {
val f = Any?::meaning
checkSubtype<Int>(f.get(null))
checkSubtype<Int>(f.get(""))
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !CHECK_TYPE
val Any?.meaning: Int
@@ -1,14 +0,0 @@
// SKIP_TXT
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER
fun check1(p: kotlin.reflect.KProperty1<*, *>) {}
fun check2(p: kotlin.reflect.KProperty1<in String, *>) {}
val CharSequence.x: Any get() = this
val BooleanArray.x: Any get() = this
fun box() {
check1(CharSequence::x) // error in NI, ok in OI
check2(CharSequence::x)
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// SKIP_TXT
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER
@@ -1,16 +0,0 @@
// !CHECK_TYPE
import kotlin.reflect.KProperty1
class A<T>(val t: T) {
val foo: T = t
}
fun bar() {
val x = A<String>::foo
checkSubtype<KProperty1<A<String>, String>>(x)
checkSubtype<KProperty1<A<String>, Any?>>(x)
val y = A<*>::foo
checkSubtype<KProperty1<A<*>, Any?>>(y)
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !CHECK_TYPE
import kotlin.reflect.KProperty1
@@ -1,12 +0,0 @@
import kotlin.reflect.*
fun <T> checkSubtype(t: T) = t
class A(var g: A) {
val f: Int = 0
fun test() {
checkSubtype<KProperty1<A, Int>>(A::f)
checkSubtype<KMutableProperty1<A, A>>(A::g)
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
import kotlin.reflect.*
fun <T> checkSubtype(t: T) = t
@@ -1,22 +0,0 @@
// KT-12982 Incorrect type inference when accessing mutable protected property via reflection
import kotlin.reflect.KMutableProperty1
class Foo {
protected var x = 0
fun baz(p: KMutableProperty1<Foo, Int>) = p
fun print() = baz(Foo::x)
}
open class A {
protected fun a() {}
}
open class B : A() {
val x = C::a
val y = C()::a
}
class C : B()
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// KT-12982 Incorrect type inference when accessing mutable protected property via reflection
import kotlin.reflect.KMutableProperty1
@@ -1,8 +0,0 @@
import kotlin.reflect.KProperty1
fun <T, R> getProperty(x: T, property: KProperty1<T, R>): R =
property.get(x)
class Person(val name: String)
val name1 = getProperty(Person("John Smith"), Person::name)
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
import kotlin.reflect.KProperty1
fun <T, R> getProperty(x: T, property: KProperty1<T, R>): R =