[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,18 @@
// FILE: 1.kt
package a
import b.B.*
import kotlin.reflect.KClass
class Companion
val f: KClass<a.Companion> = Companion::class
// FILE: 2.kt
package b
class B {
companion object Companion
}
@@ -0,0 +1,19 @@
// FILE: 1.kt
package a
import b.*
import kotlin.reflect.KClass
class A
object B
val f: KClass<a.A> = A::class
val g: KClass<a.B> = B::class
// FILE: 2.kt
package b
object A
object B
@@ -0,0 +1,39 @@
// !CHECK_TYPE
// !DIAGNOSTICS: -UNUSED_EXPRESSION
package test
class C {
companion object {
fun foo(): String = "companion"
fun bar() {}
}
fun foo(): Int = 0
}
fun test() {
val r1 = C::foo
checkSubtype<(C) -> Int>(r1)
val r2 = test.C::foo
checkSubtype<(C) -> Int>(r2)
val r3 = C.Companion::foo
checkSubtype<() -> String>(r3)
val r4 = test.C.Companion::foo
checkSubtype<() -> String>(r4)
val r5 = (C)::foo
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><() -> String>(r5)
val r6 = (test.C)::foo
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><() -> String>(r6)
val c = C.Companion
val r7 = c::foo
checkSubtype<() -> String>(r7)
C::bar
}
@@ -0,0 +1,22 @@
fun unusedExpression(s: String) {
s::hashCode
s::class
}
fun noUnusedParameter(s: String): Int {
val f = s::hashCode
return f()
}
fun unreachableCode(): Int {
(if (true) return 1 else return 0)::toString
return 0
}
fun unreachableCodeInLoop(): Int {
while (true) {
(break)::toString
return 1
}
return 2
}
@@ -0,0 +1,13 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE
import kotlin.reflect.KClass
fun f1(x: String?): String {
x!!::hashCode
return x
}
fun f2(y: String?): String {
val f: KClass<*> = (y ?: return "")::class
return y
}
@@ -0,0 +1,14 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE
import kotlin.reflect.KClass
fun test(s: String) {
val f: () -> Int = s::hashCode
val g: () -> String = s::toString
val h: (Any?) -> Boolean = s::equals
val k: KClass<out String> = s::class
val l: KClass<*> = s::class
val m: KClass<String> = String::class
val n: KClass<Unit> = Unit::class
}
@@ -0,0 +1,15 @@
// FILE: J.java
public interface J {
String platformString();
}
// FILE: test.kt
fun f1(x: Int?): Any = x::hashCode
fun <T> f2(t: T): Any = t::hashCode
fun <S : String?> f3(s: S): Any = s::hashCode
fun <U : Any> f4(u: U?): Any = u::hashCode
fun f5(c: List<*>): Any = c[0]::hashCode
fun f6(j: J): Any = j.platformString()::hashCode
@@ -0,0 +1 @@
fun test() = ("").<!UNRESOLVED_REFERENCE!>hashCode<!>::hashCode
@@ -0,0 +1,9 @@
class Outer {
class Nested
inner class Inner
}
fun test() {
Outer()::Inner
Outer()::Nested
}
@@ -0,0 +1,6 @@
class Foo {
fun bar() {}
fun f() = <!UNRESOLVED_REFERENCE!>Unresolved<!>()::bar
}
val f: () -> Unit = <!UNRESOLVED_REFERENCE!>Unresolved<!>()::foo
@@ -0,0 +1,3 @@
open class A(val x: Any)
class B : A(this::class)
@@ -0,0 +1,11 @@
// !CHECK_TYPE
object Obj {
fun foo() {}
val bar = 2
}
fun test() {
checkSubtype<() -> Unit>(Obj::foo)
checkSubtype<() -> Int>(Obj::bar)
}
@@ -0,0 +1,24 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE
class Foo<out T>(name: T) {
private var prop: T = name
private set
fun testProp() {
val ok1 = this::prop
val ok2 = this@Foo::prop
val ok3 = object { val y: Any = this@Foo::prop }
val fail1 = Foo(prop)::prop
}
fun testFunc() {
val ok1 = this::func
val ok2 = this@Foo::func
val ok3 = object { val y: Any = this@Foo::func }
val fail1 = Foo(prop)::func
}
private fun func(t: T): T = t
}
@@ -0,0 +1,14 @@
// FILE: A.java
public class A {
public static void test() {}
}
// FILE: test.kt
enum class E { EN }
fun test() {
A()::test
E.EN::valueOf
}
@@ -0,0 +1,33 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE
package test
object ClassMemberMarker
class a<T> {
fun foo() = ClassMemberMarker
}
class b<T1, T2> {
fun foo() = ClassMemberMarker
}
fun Int.foo() {}
class Test {
val <T> List<T>.a: Int get() = size
val <T> List<T>.b: Int? get() = size
fun <T> List<T>.testCallable1(): () -> Unit = a<T>::foo
fun <T> List<T>.testCallable2(): () -> Unit = b?::foo
fun <T> List<T>.testCallable3(): () -> Unit = b<T, Any>::foo
fun <T> List<T>.testCallable4(): () -> Unit = b<T>?::foo
fun <T> List<T>.testClassLiteral1() = a<T>::class
fun <T> List<T>.testClassLiteral2() = b?::class
fun <T> List<T>.testClassLiteral3() = b<T, Any>::class
fun <T> List<T>.testUnresolved1() = <!UNRESOLVED_REFERENCE!>unresolved<!><T>::foo
fun <T> List<T>.testUnresolved2() = a<unresolved>::foo
fun <T> List<T>.testUnresolved3() = a<<!SYNTAX!><!>>::foo
fun <T> List<T>.testUnresolved4() = <!UNRESOLVED_REFERENCE!>unresolved<!>?::foo
}
@@ -0,0 +1,7 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE
package test
fun nullableFun(): Int? = null
fun Int.foo() {}
val test1 = nullableFun()?::foo
@@ -0,0 +1,29 @@
// !WITH_NEW_INFERENCE
// !DIAGNOSTICS: -UNUSED_VARIABLE
package test
object Wrong
object Right
class a {
class b<T> {
class c {
fun foo() = Wrong
}
}
}
fun Int.foo() = Right
class Test {
val a: List<Int> = null!!
val <T> List<T>.b: Int get() = 42
val Int.c: Int get() = 42
val test1: () -> Right = a.b<Int>.c::foo
val test1a: () -> Right = a.b.c::foo
val test2: () -> Right = a.b<Int>.c?::foo
}
@@ -0,0 +1,13 @@
// FILE: A.java
class A {
public CharSequence getFoo() { return null; }
}
// FILE: test.kt
fun test() {
with (A()) {
foo::toString
}
}
@@ -0,0 +1,3 @@
fun <T: Any> get(t: T): () -> String {
return t::toString
}