[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,14 @@
// !WITH_NEW_INFERENCE
// !DIAGNOSTICS: -UNUSED_PARAMETER
object CommonCase {
interface Fas<D, E, R>
fun <D, E, R> delegate() : Fas<D, E, R> = TODO()
operator fun <D, E, R> Fas<D, E, R>.provideDelegate(host: D, p: Any?): Fas<D, E, R> = TODO()
operator fun <D, E, R> Fas<D, E, R>.getValue(receiver: E, p: Any?): R = TODO()
val Long.test1: String by delegate() // common test, not working because of Inference1
val Long.test2: String by delegate<CommonCase, Long, String>() // should work
}
@@ -0,0 +1,13 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
class Cell<out V>(val value: V)
class GenericDelegate<V>(val value: V)
operator fun <T> T.provideDelegate(a: Any?, p: Any?) = GenericDelegate(this)
operator fun <W> GenericDelegate<W>.getValue(a: Any?, p: Any?) = Cell(value)
val test1: Cell<String> by "OK"
val test2: Cell<Any> by "OK"
val test3 by "OK"
@@ -0,0 +1,9 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
object T1 {
operator fun Int.provideDelegate(host: T1, p: Any): Long = 2
operator fun Long.getValue(receiver: String, p: Any): Double = 1.0
val String.test1 by 1
val test2 by 1
}
@@ -0,0 +1,14 @@
// !WITH_NEW_INFERENCE
// !DIAGNOSTICS: -UNUSED_PARAMETER
object T2 {
interface Foo<T>
fun <T> delegate(): Foo<T> = TODO()
operator fun <T> Foo<T>.provideDelegate(host: T2, p: Any?): Foo<T> = TODO()
operator fun <T> Foo<T>.getValue(receiver: String, p: Any?): T = TODO()
val String.test1: String by delegate()
val test2: String by delegate()
}
@@ -0,0 +1,12 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
object T3 {
interface Foo<T>
fun <T> delegate(): Foo<T> = TODO()
operator fun <T> Foo<T>.provideDelegate(host: T3, p: Any?): Foo<T> = TODO()
operator fun <T> Foo<T>.getValue(receiver: T3, p: Any?): T = TODO()
val test1: String by delegate()
}
@@ -0,0 +1,15 @@
// !WITH_NEW_INFERENCE
// !DIAGNOSTICS: -UNUSED_PARAMETER
object Inference1 {
interface Foo<T>
fun <T> delegate(): Foo<T> = TODO()
operator fun <T> Foo<T>.getValue(receiver: T, p: Any?): String = TODO()
// not working because resulting descriptor for getValue contains type `???` instead of `T`
val test1: String by delegate()
val test2: String by delegate<Inference1>()
}
@@ -0,0 +1,14 @@
// !WITH_NEW_INFERENCE
// !DIAGNOSTICS: -UNUSED_PARAMETER
object Inference2 {
interface Foo<T>
fun <T> delegate(): Foo<T> = TODO()
operator fun <T> Foo<T>.provideDelegate(host: T, p: Any?): Foo<T> = TODO()
operator fun <T> Foo<T>.getValue(receiver: Inference2, p: Any?): String = TODO()
val test1: String by delegate() // same story like in Inference1
val test2: String by delegate<Inference2>()
}
@@ -0,0 +1,11 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
import kotlin.reflect.KProperty
operator fun String.provideDelegate(a: Any?, p: KProperty<*>) = this
operator fun String.getValue(a: Any?, p: KProperty<*>) = this
fun test(): String {
val result by "OK"
return result
}
@@ -0,0 +1,18 @@
// !WITH_NEW_INFERENCE
// !DIAGNOSTICS: -UNUSED_PARAMETER
import kotlin.reflect.KProperty
class StringDelegate(val s: String) {
operator fun getValue(a: Any?, p: KProperty<*>): Int = 42
}
// NB no operator
fun String.provideDelegate(a: Any?, p: KProperty<*>) = StringDelegate(this)
operator fun String.getValue(a: Any?, p: KProperty<*>) = this
val test1: String by "OK"
val test2: Int by "OK"
val test3 by "OK"
@@ -0,0 +1,19 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_VARIABLE
import kotlin.reflect.KProperty
object Foo
object Bar
object Baz
operator fun Foo.provideDelegate(receiver: Any?, property: KProperty<*>) = this
operator fun Bar.provideDelegate(receiver: Any?, property: KProperty<*>) = this
operator fun Foo.getValue(nothing: Any?, property: KProperty<*>): Any = TODO()
operator fun Bar.getValue(nothing: Any?, property: KProperty<*>): Any = TODO()
operator fun Baz.getValue(nothing: Any?, property: KProperty<*>): Any = TODO()
fun test() {
val bar by Baz
}
@@ -0,0 +1,32 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
import kotlin.reflect.KProperty
operator fun provideDelegate(x: Any?, p: KProperty<*>) {}
operator fun Any.provideDelegate(x: Any?, p: KProperty<*>) {}
operator fun Any.provideDelegate(x: Any?, p: Any) {}
operator fun Any.provideDelegate(x: Any?, p: Int) {}
class Host1 {
operator fun provideDelegate(x: Any?, p: KProperty<*>) {}
}
class Host2 {
operator fun Any.provideDelegate(x: Any?, p: KProperty<*>) {}
}
class Host3 {
operator fun provideDelegate(x: Any?, p: KProperty<*>, foo: Int) {}
}
class Host4 {
operator fun provideDelegate(x: Any?, p: KProperty<*>, foo: Int = 0) {}
}
class Host5 {
operator fun provideDelegate(x: Any?, p: KProperty<*>, vararg foo: Int) {}
}
@@ -0,0 +1,17 @@
// !WITH_NEW_INFERENCE
// !DIAGNOSTICS: -UNUSED_PARAMETER
class Delegate<T>
operator fun Delegate<*>.getValue(receiver: Any?, p: Any): String = ""
operator fun <T> Delegate<T>.setValue(receiver: Any?, p: Any, value: T) {}
operator fun <T> String.provideDelegate(receiver: Any?, p: Any) = Delegate<T>()
var test1: String by Delegate()
var test2: String by Delegate<String>()
var test3: String by "OK"
var test4: String by "OK".provideDelegate(null, "")
var test5: String by "OK".provideDelegate<String>(null, "")
@@ -0,0 +1,10 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
import kotlin.reflect.KProperty
operator fun String.provideDelegate(a: Any?, p: KProperty<*>) = this
operator fun String.getValue(a: Any?, p: KProperty<*>) = this
val test1: String by "OK"
val test2 by "OK"
@@ -0,0 +1,15 @@
// !WITH_NEW_INFERENCE
// !DIAGNOSTICS: -UNUSED_PARAMETER
// !LANGUAGE: -OperatorProvideDelegate
class WrongDelegate(val x: Int) {
operator fun getValue(thisRef: Any?, prop: Any): Int = x
}
operator fun String.provideDelegate(thisRef: Any?, prop: Any) = WrongDelegate(this.length)
operator fun String.getValue(thisRef: Any?, prop: Any) = this
val test1: String by "OK"
val test2: Int by "OK"
val test3 by "OK"