[FIR-TEST] Add new testdata generated after changes in previous commit

This commit is contained in:
Dmitriy Novozhilov
2019-12-11 16:16:22 +03:00
parent e9c02a1cca
commit 2536fa0cd5
4578 changed files with 104067 additions and 1 deletions
@@ -0,0 +1,17 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER
import kotlin.reflect.KProperty
class Inv2<T, K>
fun <T, K> create(g: (T) -> K): Inv2<T, K> = TODO()
operator fun <S1, V1> Inv2<S1, V1>.getValue(o: Sample, desc: KProperty<*>): V1 = TODO()
operator fun <S2, V2> Inv2<S2, V2>.setValue(o: Sample, desc: KProperty<*>, value: V2) {}
class Version(val version: Int)
class Sample {
var version: Version by create(::Version)
}
@@ -0,0 +1,22 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE, -UNUSED_PARAMETER
import kotlin.reflect.KProperty
fun test(i: Int) {
val bad by myLazyDelegate {
createSample(i) { it.toString() }
}
<!INAPPLICABLE_CANDIDATE!>takeSample<!>(bad)
}
fun <T> myLazyDelegate(i: () -> T): LazyDelegate<T> = LazyDelegate(i())
class LazyDelegate<T>(val v: T) {
operator fun getValue(thisRef: Any?, property: KProperty<*>): T = TODO()
}
class Sample<K, V>
fun takeSample(g: Sample<Int, String>) {}
fun <T, S> createSample(i: T, a: (T) -> S): Sample<T, S> = TODO()
@@ -0,0 +1,53 @@
// !WITH_NEW_INFERENCE
package baz
import kotlin.reflect.KProperty
class A(outer: Outer) {
var i: String by + getMyConcreteProperty()
var d: String by getMyConcreteProperty() - 1
var c: String by O.getMyProperty()
var g: String by outer.getContainer().getMyProperty()
var b: String by foo(getMyProperty())
var r: String by foo(outer.getContainer().getMyProperty())
var e: String by + foo(getMyProperty())
var f: String by foo(getMyProperty()) - 1
}
fun <A, B> foo(a: Any?) = MyProperty<A, B>()
fun <A, B> getMyProperty() = MyProperty<A, B>()
fun getMyConcreteProperty() = MyProperty<Any?, String>()
class MyProperty<R, T> {
operator fun getValue(thisRef: R, desc: KProperty<*>): T {
println("get $thisRef ${desc.name}")
return null as T
}
operator fun setValue(thisRef: R, desc: KProperty<*>, value: T) {
println("set $thisRef ${desc.name} $value")
}
}
operator fun <R, T> MyProperty<R, T>.unaryPlus() = MyProperty<R, T>()
operator fun <R, T> MyProperty<R, T>.minus(i: Int) = MyProperty<R, T>()
object O {
fun <A, B> getMyProperty() = MyProperty<A, B>()
}
interface MyPropertyContainer {
fun <R, T> getMyProperty(): MyProperty<R, T>
}
interface Outer {
fun getContainer(): MyPropertyContainer
}
// -----------------
fun println(a: Any?) = a
@@ -0,0 +1,35 @@
package foo
import kotlin.reflect.KProperty
class A1 {
val a: String by MyProperty1()
}
class MyProperty1 {}
operator fun MyProperty1.getValue(thisRef: Any?, desc: KProperty<*>): String {
throw Exception("$thisRef $desc")
}
//--------------------
class A2 {
val a: String by MyProperty2()
}
class MyProperty2<T> {}
operator fun <T> MyProperty2<T>.getValue(thisRef: Any?, desc: KProperty<*>): T {
throw Exception("$thisRef $desc")
}
//--------------------
class A3 {
val a: String by MyProperty3()
class MyProperty3<T> {}
operator fun <T> MyProperty3<T>.getValue(thisRef: Any?, desc: KProperty<*>): T {
throw Exception("$thisRef $desc")
}
}
@@ -0,0 +1,22 @@
// !WITH_NEW_INFERENCE
package foo
import kotlin.reflect.KProperty
open class A {
val B.w: Int by MyProperty()
}
val B.r: Int by MyProperty()
val A.e: Int by MyProperty()
class B {
val A.f: Int by MyProperty()
}
class MyProperty<R : A, T> {
operator fun getValue(thisRef: R, desc: KProperty<*>): T {
throw Exception("$thisRef $desc")
}
}
@@ -0,0 +1,28 @@
// !WITH_NEW_INFERENCE
// !DIAGNOSTICS: -UNUSED_PARAMETER
import kotlin.reflect.KProperty
class A<R>() {
operator fun <T> getValue(t: Any?, p: KProperty<*>): T = null!!
operator fun <T> setValue(t: Any?, p: KProperty<*>, x: T) = Unit
}
var a1: Int by A()
var a2: Int by A<String>()
class B<R>() {
operator fun <T> getValue(t: Any?, p: KProperty<*>): T = null!!
operator fun setValue(t: Any?, p: KProperty<*>, x: R) = Unit
}
var b1: Int by B()
var b2: Int by B<Number>()
class C<R>() {
operator fun getValue(t: Any?, p: KProperty<*>): R = null!!
operator fun <T> setValue(t: Any?, p: KProperty<*>, x: T) = Unit
}
var c1: Int by C()
var c2: Int by C<Number>()
@@ -0,0 +1,27 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
// !WITH_NEW_INFERENCE
// NI_EXPECTED_FILE
import kotlin.reflect.KProperty
var a: Int by A()
var a1 by A()
var b: Int by B()
val cObj = C()
var c: String by cObj
class A {
operator fun <T> getValue(t: Any?, p: KProperty<*>): T = null!!
operator fun <T> setValue(t: Any?, p: KProperty<*>, x: T) = Unit
}
class B
operator fun <T> B.getValue(t: Any?, p: KProperty<*>): T = null!!
operator fun <T> B.setValue(t: Any?, p: KProperty<*>, x: T) = Unit
class C
operator inline fun <reified T> C.getValue(t: Any?, p: KProperty<*>): T = null!!
operator inline fun <reified T> C.setValue(t: Any?, p: KProperty<*>, x: T) = Unit
@@ -0,0 +1,11 @@
import kotlin.reflect.KProperty
class A3 {
val a: String by l@ MyProperty()
class MyProperty<T> {}
operator fun <T> MyProperty<T>.getValue(thisRef: Any?, desc: KProperty<*>): T {
throw Exception("$thisRef $desc")
}
}
@@ -0,0 +1,26 @@
// !WITH_NEW_INFERENCE
// FILE: main.kt
package test
import first.*
import second.*
val a12 by A()
// FILE: first.kt
package first
import kotlin.reflect.KProperty
class A
public operator fun <T> A.getValue(thisRef: Any?, property: KProperty<*>): T = null!!
// FILE: second.kt
package second
import first.A
import kotlin.reflect.KProperty
public operator fun <T> A.getValue(thisRef: Any?, property: KProperty<*>): T = null!!
@@ -0,0 +1,45 @@
// !WITH_NEW_INFERENCE
package foo
import kotlin.reflect.KProperty
class A {
var a5: String by MyProperty1()
var b5: String by getMyProperty1()
}
fun <A, B> getMyProperty1() = MyProperty1<A, B>()
class MyProperty1<T, R> {
operator fun getValue(thisRef: R, desc: KProperty<*>): T {
throw Exception()
}
operator fun setValue(i: Int, j: Any, k: Int) {
println("set")
}
}
// -----------------
class B {
var a5: String by MyProperty2()
var b5: String by getMyProperty2()
}
fun <A, B> getMyProperty2() = MyProperty2<A, B>()
class MyProperty2<T, R> {
operator fun getValue(thisRef: R, desc: KProperty<*>): T {
throw Exception()
}
operator fun setValue(i: Int) {
println("set")
}
}
// -----------------
fun println(a: Any?) = a
@@ -0,0 +1,18 @@
// !WITH_NEW_INFERENCE
// NI_EXPECTED_FILE
import kotlin.reflect.KProperty
class A {
var a by MyProperty()
}
class MyProperty<T, R> {
operator fun getValue(thisRef: R, desc: KProperty<*>): T {
throw Exception("$thisRef $desc")
}
operator fun setValue(thisRef: R, desc: KProperty<*>, t: T) {
throw Exception("$thisRef $desc $t")
}
}
@@ -0,0 +1,17 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
import kotlin.reflect.KProperty
class A<E>
class B<E, F>
fun <K, V> A<K>.toB(f: (V) -> K, g: (K) -> V): B<K, V> = B()
operator fun <T1, E1> B<T1, E1>.getValue(o: Any, desc: KProperty<*>): E1 = TODO()
operator fun <T2, E2> B<T2, E2>.setValue(o: Any, desc: KProperty<*>, value: E2) {}
val q = A<String>()
class Test {
var prop by q.toB({ "abc" }, { "cde" })
}
@@ -0,0 +1,29 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
import kotlin.reflect.KProperty
val b: First by lazy {
object : First { }
}
private val withoutType by lazy {
object : First { }
}
private val withTwoSupertypes by lazy {
object : First, Second { }
}
class A<T> {
val a: First by lazy {
object : First { }
}
}
interface First
interface Second
fun <T> lazy(initializer: () -> T): Lazy<T> = TODO()
interface Lazy<out T> {
operator fun getValue(thisRef: Any?, property: KProperty<*>): T = TODO()
}
@@ -0,0 +1,15 @@
// !CHECK_TYPE
import kotlin.reflect.KProperty
class A {
val a by MyProperty()
fun test() {
checkSubtype<Int>(a)
}
}
class MyProperty<R> {
operator fun getValue(thisRef: R, desc: KProperty<*>): Int = throw Exception("$thisRef $desc")
}
@@ -0,0 +1,76 @@
package foo
import kotlin.reflect.KProperty
class A1 {
var a1: String by MyProperty1()
var b1: String by getMyProperty1()
}
var c1: String by getMyProperty1()
var d1: String by MyProperty1()
fun <A, B> getMyProperty1() = MyProperty1<A, B>()
class MyProperty1<R, T> {
operator fun getValue(thisRef: R, desc: KProperty<*>): T {
println("get $thisRef ${desc.name}")
throw Exception()
}
operator fun setValue(thisRef: R, desc: KProperty<*>, value: T) {
println("set $thisRef ${desc.name} $value")
}
}
//--------------------------
class A2 {
var a2: String by MyProperty2()
var b2: String by getMyProperty2()
}
var c2: String by getMyProperty2()
var d2: String by MyProperty2()
fun <A> getMyProperty2() = MyProperty2<A>()
class MyProperty2<T> {
operator fun getValue(thisRef: Any?, desc: KProperty<*>): T {
println("get $thisRef ${desc.name}")
throw Exception()
}
operator fun setValue(thisRef: Any?, desc: KProperty<*>, value: T) {
println("set $thisRef ${desc.name} $value")
}
}
//--------------------------
class A3 {
var a3: String by MyProperty3()
var b3: String by getMyProperty3()
}
var c3: String by getMyProperty3()
var d3: String by MyProperty3()
fun <A> getMyProperty3() = MyProperty3<A>()
class MyProperty3<T> {
operator fun getValue(thisRef: T, desc: KProperty<*>): String {
println("get $thisRef ${desc.name}")
return ""
}
operator fun setValue(thisRef: Any?, desc: KProperty<*>, value: T) {
println("set $thisRef ${desc.name} $value")
}
}
//--------------------------
fun println(a: Any?) = a
@@ -0,0 +1,64 @@
package foo
import kotlin.reflect.KProperty
class A1 {
val a1: String by MyProperty1()
val b1: String by getMyProperty1()
}
val c1: String by getMyProperty1()
val d1: String by MyProperty1()
fun <A, B> getMyProperty1() = MyProperty1<A, B>()
class MyProperty1<R, T> {
operator fun getValue(thisRef: R, desc: KProperty<*>): T {
println("get $thisRef ${desc.name}")
throw Exception()
}
}
//--------------------------
class A2 {
val a2: String by MyProperty2()
val b2: String by getMyProperty2()
}
val c2: String by getMyProperty2()
val d2: String by MyProperty2()
fun <A> getMyProperty2() = MyProperty2<A>()
class MyProperty2<T> {
operator fun getValue(thisRef: Any?, desc: KProperty<*>): T {
println("get $thisRef ${desc.name}")
throw Exception()
}
}
//--------------------------
class A3 {
val a3: String by MyProperty3()
val b3: String by getMyProperty3()
}
val c3: String by getMyProperty3()
val d3: String by MyProperty3()
fun <A> getMyProperty3() = MyProperty3<A>()
class MyProperty3<T> {
operator fun getValue(thisRef: T, desc: KProperty<*>): String {
println("get $thisRef ${desc.name}")
return ""
}
}
//--------------------------
fun println(a: Any?) = a