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,30 +0,0 @@
//!DIAGNOSTICS: -UNUSED_PARAMETER
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
fun <R> Iterable<*>.filterIsInstance1(): List<@kotlin.internal.NoInfer R> = throw Exception()
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
fun <R> List<*>.filterIsInstance2(): @kotlin.internal.NoInfer List<R> = throw Exception()
fun test(list: List<Int>) {
list.filterIsInstance1<Int>().map { it * 2 }
list.filterIsInstance2<Int>().filter { it > 10 }
}
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
fun <R> foo(t: R): List<@kotlin.internal.NoInfer R> = throw Exception("$t")
fun test() {
foo(1).map { it * 2 }
}
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
fun <R> List<R>.foo(): @kotlin.internal.NoInfer R = throw Exception()
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
fun <R> bar(r: R, f: Function1<@kotlin.internal.NoInfer R, Unit>): Nothing = throw Exception()
fun test1() {
listOf("").foo().length
bar(1) { x -> x + 1 }
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
//!DIAGNOSTICS: -UNUSED_PARAMETER
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@@ -1,12 +0,0 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
annotation class Anno
fun test(a: List<Class<Anno>>) {
strictSelect(a, emptyList<Anno>().map { it.annotationClass.java })
}
fun <@kotlin.internal.OnlyInputTypes S> strictSelect(arg1: S, arg2: S): S = TODO()
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER
@@ -1,18 +0,0 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER
// FILE: TestBase.java
public class TestBase<T> { }
// FILE: Test.java
public class Test<K> extends TestBase<K> { }
// FILE: main.kt
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
fun <@kotlin.internal.OnlyInputTypes K> TestBase<out K>.foo(key: K) = null
fun foo(result: Test<*>) {
result.foo("sd") // Type inference failed (NI), OK in OI
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER
@@ -1,24 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
interface IFace<K, out V>
fun <@kotlin.internal.OnlyInputTypes K, V> IFace<out K, V>.get(key: K): V? = TODO()
fun <@kotlin.internal.OnlyInputTypes I> id(arg: I): I = arg
interface InvBase<B>
class DerivedInv : InvBase<DerivedInv>
class InvRecursive<E : InvBase<E>>
fun test1(argument: InvRecursive<*>, receiver: IFace<InvRecursive<DerivedInv>, Any>) {
receiver.get(argument)
}
fun test2(arg: InvRecursive<out DerivedInv>) {
id(arg)
}
fun test3(arg: InvRecursive<in DerivedInv>) {
id(arg)
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@@ -1,19 +0,0 @@
//!DIAGNOSTICS: -UNUSED_PARAMETER
//FILE:Foo.java
public class Foo {
public static String foo() {
return null;
}
}
//FILE:Bar.kt
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
fun <@kotlin.internal.OnlyInputTypes T> assertEquals1(t1: T, t2: T) {}
fun test() {
assertEquals1(null, Foo.foo())
assertEquals1("", Foo.foo())
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
//!DIAGNOSTICS: -UNUSED_PARAMETER
//FILE:Foo.java
@@ -1,26 +0,0 @@
fun test1(ns: String?, vararg nullableStrs: String?) {
nullableStrs.contains("x")
nullableStrs.contains(ns)
"x" in nullableStrs
ns in nullableStrs
}
fun test2(ns: String?, vararg nonNullableStrs: String) {
nonNullableStrs.contains("x")
nonNullableStrs.contains(ns)
"x" in nonNullableStrs
ns in nonNullableStrs
}
fun test3(ns: String?, nullableStrs: Array<out String?>, nonNullableStrs: Array<out String>) {
nullableStrs.contains("x")
nonNullableStrs.contains("x")
nullableStrs.contains(ns)
nonNullableStrs.contains(ns)
"x" in nullableStrs
"x" in nonNullableStrs
ns in nullableStrs
ns in nonNullableStrs
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
fun test1(ns: String?, vararg nullableStrs: String?) {
nullableStrs.contains("x")
nullableStrs.contains(ns)
@@ -1,25 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
private object TopLevelTypeVariable {
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
fun <T> foo(): @kotlin.internal.NoInfer T = TODO()
fun <K> bar(k: K) {}
fun test() {
bar(foo<Int>())
}
}
private object NestedTypeVariable {
class Inv<T>
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
fun <T> foo(): Inv<@kotlin.internal.NoInfer T> = TODO()
fun <K> bar(p: Inv<K>) {}
fun test() {
bar(foo<String>())
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
private object TopLevelTypeVariable {
@@ -1,14 +0,0 @@
// !CHECK_TYPE
package b
fun bar() {
val a1 = Array(1, {i: Int -> i})
val a2 = Array(1, {i: Int -> "$i"})
val a3 = Array(1, {it})
checkSubtype<Array<Int>>(a1)
checkSubtype<Array<String>>(a2)
checkSubtype<Array<Int>>(a3)
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !CHECK_TYPE
package b
@@ -1,17 +0,0 @@
// !LANGUAGE: +NewInference
// !WITH_NEW_INFERENCE
// !DIAGNOSTICS: -UNUSED_PARAMETER
// ISSUE: KT-31219
import kotlin.reflect.KProperty
interface Intf
interface GenericIntf<T>
class Foo {
private val generic1 by lazy {
abstract class LocalIntf : GenericIntf<CharSequence>
object : LocalIntf() {}
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !LANGUAGE: +NewInference
// !WITH_NEW_INFERENCE
// !DIAGNOSTICS: -UNUSED_PARAMETER
@@ -1,20 +0,0 @@
// !LANGUAGE: +NewInference
// !WITH_NEW_INFERENCE
// !DIAGNOSTICS: -UNUSED_PARAMETER
// ISSUE: KT-31679
import kotlin.reflect.KProperty
class MyDelegate<T>(p: () -> T) {
operator fun getValue(thisRef: Any?, property: KProperty<*>): T = TODO()
}
private val privateObj by MyDelegate {
object {
val x = 42
}
}
fun test() {
privateObj.x
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !LANGUAGE: +NewInference
// !WITH_NEW_INFERENCE
// !DIAGNOSTICS: -UNUSED_PARAMETER
@@ -1,18 +0,0 @@
// !LANGUAGE: +NewInference
// !WITH_NEW_INFERENCE
// !DIAGNOSTICS: -UNUSED_PARAMETER
// ISSUE: KT-32249
import kotlin.properties.ReadOnlyProperty
import kotlin.reflect.KProperty
class Wrapper<T>(val name: String, val defaultValue: T)
private fun <T> wrapper(defaultValue: T) = object : ReadOnlyProperty<Any, Wrapper<T>> {
override fun getValue(thisRef: Any, property: KProperty<*>): Wrapper<T> = null!!
}
object Foo {
val x by wrapper(true)
val y: Wrapper<Boolean> by wrapper(true)
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !LANGUAGE: +NewInference
// !WITH_NEW_INFERENCE
// !DIAGNOSTICS: -UNUSED_PARAMETER
@@ -1,12 +0,0 @@
// !LANGUAGE: +NewInference
import kotlin.test.assertEquals
fun test() {
val u = when (true) {
true -> 42
else -> 1.0
}
assertEquals(42, u)
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !LANGUAGE: +NewInference
import kotlin.test.assertEquals
@@ -1,5 +0,0 @@
// !LANGUAGE: +NewInference
fun test(ls: List<String>) {
ls.takeIf(Collection<*>::isNotEmpty)
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !LANGUAGE: +NewInference
fun test(ls: List<String>) {
@@ -1,17 +0,0 @@
// SKIP_TXT
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER
import kotlin.reflect.KProperty1
import kotlin.reflect.KFunction1
fun <T, R> has(property: KFunction1<T, R>) = null
fun <T, R> has(property: KProperty1<T, R>) = null
fun toInt(s: String) = 10
object A {
fun main() {
has(::toInt) // throwing an exception here
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// SKIP_TXT
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER