FIR: Mark a pack of tests (53) as FIR_IDENTICAL

This commit is contained in:
Denis.Zharkov
2021-05-24 13:01:57 +03:00
committed by teamcityserver
parent ddbdfafa79
commit dac9d7b17a
106 changed files with 53 additions and 1057 deletions
@@ -1,18 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
import kotlin.reflect.KCallable
class Foo {
fun <T> installRoute(handler: T) where T : (String) -> Any?, T : KCallable<*> {
}
fun <T> installRoute(handler: T) where T : () -> Any?, T : KCallable<*> {
}
fun foo() {
<!NONE_APPLICABLE!>installRoute<!><Any>(::route)
}
}
fun route(s: String): Any? = null
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
import kotlin.reflect.KCallable
@@ -1,10 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
class A {
operator fun get(x: Int) {}
operator fun set(x: String, value: Int) {}
fun d(x: Int) {
this["", 1] = <!TOO_MANY_ARGUMENTS!>1<!>
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
class A {
@@ -1,12 +0,0 @@
// AssertionError for nested ifs with lambdas and Nothing as results
// NI_EXPECTED_FILE
val fn = if (true) {
{ true }
}
else if (true) {
{ true }
}
else {
null!!
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// AssertionError for nested ifs with lambdas and Nothing as results
// NI_EXPECTED_FILE
@@ -1,9 +0,0 @@
// NI_EXPECTED_FILE
val test1 = { if (true) 1 else "" }
val test2 = { { if (true) 1 else "" } }
val test3: (Boolean) -> Any = { if (it) 1 else "" }
val test4: (Boolean) -> Any? = { if (it) 1 else "" }
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// NI_EXPECTED_FILE
val test1 = { if (true) 1 else "" }
@@ -1,15 +0,0 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION
fun use(a: Any?) = a
fun test() {
{ }<!NOT_NULL_ASSERTION_ON_LAMBDA_EXPRESSION!>!!<!>
use({ }<!NOT_NULL_ASSERTION_ON_LAMBDA_EXPRESSION!>!!<!>);
// KT-KT-9070
{ } <!USELESS_ELVIS!>?: 1<!>
use({ 2 } <!USELESS_ELVIS!>?: 1<!>);
1 <!USELESS_ELVIS!>?: { }<!>
use(1 <!USELESS_ELVIS!>?: { }<!>)
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_EXPRESSION
fun use(a: Any?) = a
@@ -1,18 +0,0 @@
// NI_EXPECTED_FILE
val test1 = { when (true) { true -> 1; else -> "" } }
val test2 = { { when (true) { true -> 1; else -> "" } } }
val test3: (Boolean) -> Any = { when (true) { true -> 1; else -> "" } }
val test4: (Boolean) -> Any? = { when (true) { true -> 1; else -> "" } }
fun println() {}
val test5 = {
when (true) {
true -> println()
else -> println()
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// NI_EXPECTED_FILE
val test1 = { when (true) { true -> 1; else -> "" } }
@@ -1,21 +0,0 @@
package foo
import kotlin.reflect.KProperty
open class A {
val B.w: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>MyProperty()<!>
}
val B.r: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>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")
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
package foo
import kotlin.reflect.KProperty
@@ -1,25 +0,0 @@
// FILE: main.kt
package test
import first.*
import second.*
val a12 by <!DELEGATE_SPECIAL_FUNCTION_AMBIGUITY!>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!!
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// FILE: main.kt
package test
@@ -1,14 +0,0 @@
// !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>()
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
object Inference1 {
@@ -1,15 +0,0 @@
package h
//traits to make ambiguity with function literal as an argument
interface A
interface B
interface C: A, B
fun <T> foo(a: A, f: () -> T): T = f()
fun <T> foo(b: B, f: () -> T): T = f()
fun test(c: C) {
<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>(c) f@ {
c<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
package h
//traits to make ambiguity with function literal as an argument
@@ -1,18 +0,0 @@
fun <T, R> Iterable<T>.map(transform: (T) -> R): List<R> = null!!
fun <T> listOf(): List<T> = null!!
fun <T> listOf(vararg values: T): List<T> = null!!
fun commonSystemFailed(a: List<Int>) {
a.map {
if (it == 0) return@map listOf(it)
listOf()
}
a.map {
if (it == 0) return@map listOf()
listOf(it)
}
a.map {
if (it == 0) listOf()
else listOf(it)
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
fun <T, R> Iterable<T>.map(transform: (T) -> R): List<R> = null!!
fun <T> listOf(): List<T> = null!!
fun <T> listOf(vararg values: T): List<T> = null!!
@@ -1,10 +0,0 @@
package m
interface Element
fun test(handlers: Map<String, Element.()->Unit>) {
handlers.getOrElse("name", l@ { return@l null })
}
fun <K,V> Map<K,V>.getOrElse(key: K, defaultValue: ()-> V) : V = throw Exception("$key $defaultValue")
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
package m
interface Element
@@ -1,26 +0,0 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION,-UNUSED_VARIABLE
fun <T : CharSequence?> T.bar1() {}
fun CharSequence?.bar2() {}
fun <T : CharSequence> T.bar3() {}
fun <T : String?> foo(x: T) {
x<!UNSAFE_CALL!>.<!>length
x?.length
if (1 == 1) {
x!!.length
}
x.bar1()
x.bar2()
x?.bar1()
x?.bar2()
x<!UNSAFE_CALL!>.<!>bar3()
x?.let { it.length }
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_EXPRESSION,-UNUSED_VARIABLE
fun <T : CharSequence?> T.bar1() {}
@@ -1,23 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
// NI_EXPECTED_FILE
interface In<in E>
open class A : In<A>
open class B : In<B>
fun <T> select(x: T, y: T) = x
fun foo2() = select(A(), B()) // Type "In<A & B>" is prohibited in return position
open class C : In<C>
open class D : In<D>
open class E : In<E>
open class F : In<F>
open class G : In<G>
open class H : In<H>
fun <S> select8(a: S, b: S, c: S, d: S, e: S, f: S, g: S, h: S) = a
fun foo8() = select8(A(), B(), C(), D(), E(), F(), G(), H())
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
// NI_EXPECTED_FILE
@@ -1,8 +0,0 @@
package f
fun <T> g(i: Int, a: Any): List<T> {throw Exception()}
fun <T> g(a: Any, i: Int): Collection<T> {throw Exception()}
fun <T> test() {
val c: List<T> = <!OVERLOAD_RESOLUTION_AMBIGUITY!>g<!>(1, 1)
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
package f
fun <T> g(i: Int, a: Any): List<T> {throw Exception()}
@@ -1,6 +0,0 @@
package f
fun <R> h(i: Int, a: Any, r: R, f: (Boolean) -> Int) = 1
fun <R> h(a: Any, i: Int, r: R, f: (Boolean) -> Int) = 1
fun test() = <!OVERLOAD_RESOLUTION_AMBIGUITY!>h<!>(1, 1, 1, { b -> 42 })
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
package f
fun <R> h(i: Int, a: Any, r: R, f: (Boolean) -> Int) = 1
@@ -1,10 +0,0 @@
package f
fun <T> f(i: Int, c: Collection<T>): List<T> {throw Exception()}
fun <T> f(a: Any, l: List<T>): Collection<T> {throw Exception()}
fun <T> test(l: List<T>) {
<!OVERLOAD_RESOLUTION_AMBIGUITY!>f<!>(1, emptyList())
}
fun <T> emptyList(): List<T> {throw Exception()}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
package f
fun <T> f(i: Int, c: Collection<T>): List<T> {throw Exception()}
@@ -1,10 +0,0 @@
// !DIAGNOSTICS: -CONFLICTING_JVM_DECLARATIONS
package f
fun <R> h(f: (Boolean) -> R) = 1
fun <R> h(f: (String) -> R) = 2
fun test() = <!OVERLOAD_RESOLUTION_AMBIGUITY!>h<!>{ i -> getAnswer() }
fun getAnswer() = 42
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -CONFLICTING_JVM_DECLARATIONS
package f
@@ -1,7 +0,0 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE
fun <T : Any> nullable(): T? = null
fun test() {
val value = nullable<Int>() ?: nullable()
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_VARIABLE
fun <T : Any> nullable(): T? = null
@@ -1,19 +0,0 @@
package conflictingSubstitutions
//+JDK
import java.util.*
fun <R> elemAndList(r: R, t: MutableList<R>): R = r
fun <R> R.elemAndListWithReceiver(r: R, t: MutableList<R>): R = r
fun test() {
val s = elemAndList(11, list("72"))
val u = 11.elemAndListWithReceiver(4, list("7"))
}
fun <T> list(value: T) : ArrayList<T> {
val list = ArrayList<T>()
list.add(value)
return list
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
package conflictingSubstitutions
//+JDK
@@ -1,31 +0,0 @@
// SKIP_JAVAC
// FILE: MySettings.java
import java.util.Collection
class MySettings<
SS extends MySettings<SS, PS, L>,
PS extends MyComparableSettings,
L extends MySettingsListener<PS>
>
{
public Collection<PS> getLinkedProjectsSettings() {
return null;
}
public static MySettings<?, ?, ?> getSettings() {
return null;
}
}
abstract class MyComparableSettings implements Comparable<MyComparableSettings> {}
abstract class MySettingsListener<S extends MyComparableSettings> {}
// FILE: test.kt
fun test() {
val a = MySettings.getSettings()
a.getLinkedProjectsSettings()
a.linkedProjectsSettings
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// SKIP_JAVAC
// FILE: MySettings.java
@@ -1,6 +0,0 @@
// NI_EXPECTED_FILE
fun <X, Y, Z> foo(f: (Y) -> Z, g: (X) -> Y, x: X): Z = f(g(x))
// TODO: Actually, this is a bug and will work when new inference is enabled
// see ([NI] Select variable with proper non-trivial constraint first) for more details
fun test() = foo({ it + 1 }, { it.length }, "")
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// NI_EXPECTED_FILE
fun <X, Y, Z> foo(f: (Y) -> Z, g: (X) -> Y, x: X): Z = f(g(x))
@@ -1,28 +0,0 @@
// !CHECK_TYPE
// !DIAGNOSTICS: -UNUSED_PARAMETER, -UNUSED_VARIABLE
class AbstractSelector<S, I>
class SelectorFor<S>
inline operator fun <S, I> SelectorFor<S>.invoke(f: S.() -> I): AbstractSelector<S, I> = TODO()
class State(val p1: Double, val p2: () -> Int, val p3: String?)
fun test(s: SelectorFor<State>): Double {
val a = s { p1 }
a checkType { _<AbstractSelector<State, Double>>() }
val b = s { p2 }
b checkType { _<AbstractSelector<State, () -> Int>>()}
val c = s { p3 }
c checkType { _<AbstractSelector<State, String?>>() }
val d = s { }
d checkType { _<AbstractSelector<State, Unit>>() }
val e = s { return p1 }
e checkType { _<AbstractSelector<State, Nothing>>() }
return null!!
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !CHECK_TYPE
// !DIAGNOSTICS: -UNUSED_PARAMETER, -UNUSED_VARIABLE
@@ -1,11 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
fun <K> select2(x: K, y: K): K = TODO()
fun <K> select3(x: K, y: K, z: K): K = TODO()
fun test2(f: ((String) -> Int)?) {
val a0: ((Int) -> Int)? = select2({ it -> it }, null)
val b0: ((Nothing) -> Unit)? = select2({ it -> it }, null)
select3({ it.length }, f, null)
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
fun <K> select2(x: K, y: K): K = TODO()
@@ -1,33 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
// NI_EXPECTED_FILE
interface First {
fun first() {}
}
interface Second
interface Third
interface Fourth
fun chained1(arg: First) = run {
if (arg !is Second) throw Exception()
arg
}.let { third ->
if (third !is Third) throw Exception()
third
}
fun chained2(arg: First) = run {
if (arg !is Second) throw Exception()
arg
}.let { third ->
if (third !is Third) throw Exception()
third
}.let { fourth ->
if (fourth !is Fourth) throw Exception()
fourth
}
fun test(arg: First) {
chained1(arg).<!UNRESOLVED_REFERENCE!>first<!>()
chained2(arg).<!UNRESOLVED_REFERENCE!>first<!>()
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
// NI_EXPECTED_FILE
@@ -1,21 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
// NI_EXPECTED_FILE
interface Base {
fun base() {}
}
interface Base2
interface One : Base, Base2
interface Two : Base, Base2
fun <S: Base> intersectNullable(vararg elements: S): S? = TODO()
fun smartCastAfterIntersection(a: One, b: Two) = run {
val v = intersectNullable(a, b)
if (v == null) throw Exception()
v
}
fun test(one: One, two: Two) {
smartCastAfterIntersection(one, two)<!UNNECESSARY_SAFE_CALL!>?.<!><!UNRESOLVED_REFERENCE!>base<!>()
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
// NI_EXPECTED_FILE
@@ -1,24 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
// NI_EXPECTED_FILE
interface Base {
fun base() {}
}
interface Base2 : Base3
interface Base3
interface One : Base, Base2
interface Two : Base, Base2
interface Three : Base, Base3
object O1 : One
object O2 : Two
object O3 : Three
fun <S: Base> intersect(vararg elements: S): S = TODO()
fun <S> intersectNoBound(vararg elements: S): S = TODO()
fun some(a: One, b: Two, c: Three) = intersectNoBound(intersect(a, b), c)
fun test(arg: Base, arg2: Base) {
some(O1, O2, O3).<!UNRESOLVED_REFERENCE!>base<!>()
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
// NI_EXPECTED_FILE
@@ -1,18 +0,0 @@
// !DIAGNOSTICS: -UNREACHABLE_CODE
//KT-2838 Type inference failed on passing null as a nullable argument
package a
fun <T> foo(a: T, b: Map<T, String>?) = b?.get(a)
fun <T> bar(a: T, b: Map<T, String>) = b.get(a)
fun test(a: Int) {
foo(a, null)
bar(a, <!NULL_FOR_NONNULL_TYPE!>null<!>)
}
fun test1(a: Int) {
foo(a, throw Exception())
}
fun test2(a: Int) {
bar(a, throw Exception())
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNREACHABLE_CODE
//KT-2838 Type inference failed on passing null as a nullable argument
package a
@@ -1,34 +0,0 @@
// !CHECK_TYPE
package s
import checkSubtype
interface In<in T>
interface A
interface B
interface C: A, B
fun <T> foo(in1: In<T>, in2: In<T>): T = throw Exception("$in1 $in2")
fun test(inA: In<A>, inB: In<B>, inC: In<C>) {
foo(inA, inB)
val r = foo(inA, inC)
checkSubtype<C>(r)
val c: C = foo(inA, inB)
use(c)
}
fun <T: C> bar(in1: In<T>): T = throw Exception("$in1")
fun test(inA: In<A>) {
val r = bar(inA)
checkSubtype<C>(r)
}
fun use(vararg a: Any?) = a
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !CHECK_TYPE
package s
@@ -1,11 +0,0 @@
// FILE: C.java
// See KT-10410
public class C {
public <T extends T> C(T t) {
}
}
// FILE: main.kt
fun foo() = C(<!NO_VALUE_FOR_PARAMETER!>)<!>
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// FILE: C.java
// See KT-10410
@@ -1,23 +0,0 @@
// !CHECK_TYPE
// !DIAGNOSTICS: -UNUSED_PARAMETER
// FILE: A.java
public class A {
public static Out<? super CharSequence> foo() { return null; }
public static In<? extends CharSequence> bar() { return null; }
}
// FILE: main.kt
class Out<out E> {
fun x(): E = null!!
}
class In<in F> {
fun y(f: F) {}
}
fun test() {
A.foo().x() checkType { _<Any?>() }
A.bar().y(<!NULL_FOR_NONNULL_TYPE!>null<!>)
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !CHECK_TYPE
// !DIAGNOSTICS: -UNUSED_PARAMETER
// FILE: A.java
@@ -1,19 +0,0 @@
interface A
interface B
fun <R: A> R.f() {
}
fun <R: B> R.f() {
}
class AImpl: A
class BImpl: B
class C: A, B
fun main() {
AImpl().f()
BImpl().f()
C().<!OVERLOAD_RESOLUTION_AMBIGUITY!>f<!>()
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
interface A
interface B
@@ -1,27 +0,0 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE
// FILE: A.java
import java.util.List;
public interface A<T> {
boolean value(T t);
}
// FILE: B.java
class B {
void foo(Runnable runnable, A x);
static A bar() {}
}
// FILE: main.kt
fun main() {
fun println() {}
// All parameters in SAM adapter of `foo` have functional types
B().foo({ println() }, B.bar())
// So you should use SAM constructors when you want to use mix lambdas and Java objects
B().foo(Runnable { println() }, B.bar())
B().foo({ println() }, { it: Any? -> it == null } )
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_VARIABLE
// FILE: A.java
@@ -1,25 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
interface Bar<T> {
val t: T
}
class MyBar<T>(override val t: T) : Bar<T>
class BarR : Bar<BarR> {
override val t: BarR get() = this
}
class Foo<F : Bar<F>>(val f: F)
fun <T> id(t1: T, t2: T) = t2
fun test(foo: Foo<*>, g: Bar<*>) {
id(foo.f, g).t.<!UNRESOLVED_REFERENCE!>t<!>
}
fun main() {
val foo = Foo(BarR())
test(foo, MyBar(2))
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
@@ -1,10 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
fun Int.invoke(i: Int, a: Any) {}
fun Int.invoke(a: Any, i: Int) {}
fun foo(i: Int) {
<!NONE_APPLICABLE!>i<!>(1, 1)
<!NONE_APPLICABLE!>5<!>(1, 2)
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
fun Int.invoke(i: Int, a: Any) {}
@@ -1,22 +0,0 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
class A
fun test(foo: A.() -> Int, a: A) {
val b: Int = foo(a)
val c: Int = (foo)(a)
}
class B {
val foo: A.() -> Int = null!!
init {
val b: Int = foo(A())
}
}
fun foo(): A.() -> Int {
val b: Int = foo()(A())
val c: Int = (foo())(A())
return null!!
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
class A
@@ -1,18 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
interface A
class B : A
val String.ext: A
get() = TODO()
class Cls {
fun take(arg: B) {}
fun test(s: String) {
if (s.ext is B)
take(s.ext)
}
}
fun take(arg: Any) {}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
interface A
@@ -1,10 +0,0 @@
package h
fun foo(i: Int) = i
fun foo(s: String) = s
fun test() {
<!NONE_APPLICABLE!>foo<!>(emptyList())
}
fun <T> emptyList(): List<T> {throw Exception()}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
package h
fun foo(i: Int) = i
@@ -1,16 +0,0 @@
class ResolutionCandidate<A>
class ResolutionTask<B, C : B>(val candidate: ResolutionCandidate<B>)
fun <D, E : D> List<ResolutionTask<D, E>>.bar(t: ResolutionTask<D, E>) = t
public class ResolutionTaskHolder<F, G : F> {
fun test(candidate: ResolutionCandidate<F>, tasks: MutableList<ResolutionTask<F, G>>) {
tasks.bar(ResolutionTask<F, G>(candidate))
tasks.add(ResolutionTask<F, G>(candidate))
//todo the problem is the type of ResolutionTask is inferred as ResolutionTask<F, F> too early
tasks.bar(ResolutionTask(candidate))
tasks.add(ResolutionTask(candidate))
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
class ResolutionCandidate<A>
class ResolutionTask<B, C : B>(val candidate: ResolutionCandidate<B>)
@@ -1,19 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
interface A<T> {
fun foo(x: T)
fun foo(x: String)
fun <E> baz(x: E, y: String)
fun <E> baz(x: String, y: E)
}
fun <E> baz(x: E, y: String) {}
fun <E> baz(x: String, y: E) {}
fun bar(x: A<String>) {
x.<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>("")
x.<!OVERLOAD_RESOLUTION_AMBIGUITY!>baz<!>("", "")
<!OVERLOAD_RESOLUTION_AMBIGUITY!>baz<!>("", "")
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
interface A<T> {
@@ -1,9 +0,0 @@
interface AutoCloseable
interface Closeable : AutoCloseable
fun <T1 : AutoCloseable, R1> T1.myUse(f: (T1) -> R1): R1 = f(this)
fun <T2 : Closeable, R2> T2.myUse(f: (T2) -> R2): R2 = f(this)
fun test1(x: Closeable) = x.myUse { 42 }
fun test2(x: Closeable) = x.myUse<Closeable, Int> { 42 }
fun test3(x: Closeable) = x.myUse<AutoCloseable, Int> { 42 } // TODO KT-10681
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
interface AutoCloseable
interface Closeable : AutoCloseable
@@ -1,15 +0,0 @@
// !CONSTRAINT_SYSTEM_FOR_OVERLOAD_RESOLUTION: CONSTRAINT_SYSTEM_FOR_NEW_INFERENCE
open class A<T>(val value: T)
class B<T>(value: T) : A<T>(value)
fun <T> A<T>.foo(block: (T?) -> Unit) {
block(value)
}
fun <T> B<T>.foo(block: (T) -> Unit) {
block(value)
}
fun main() {
B("string").<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!> { }
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !CONSTRAINT_SYSTEM_FOR_OVERLOAD_RESOLUTION: CONSTRAINT_SYSTEM_FOR_NEW_INFERENCE
open class A<T>(val value: T)
@@ -1,25 +0,0 @@
// !CONSTRAINT_SYSTEM_FOR_OVERLOAD_RESOLUTION: CONSTRAINT_SYSTEM_FOR_NEW_INFERENCE
// !DIAGNOSTICS: -UNUSED_PARAMETER
// FILE: a.kt
package a
enum class A { A1 }
fun <T : Enum<T>> foo(arg: T.() -> Unit) = 1
// FILE: b.kt
package b
fun <T : Any> foo(arg: T.() -> Unit) = 2
// FILE: test.kt
import a.*
import b.*
fun test() {
<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!><A> { }
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !CONSTRAINT_SYSTEM_FOR_OVERLOAD_RESOLUTION: CONSTRAINT_SYSTEM_FOR_NEW_INFERENCE
// !DIAGNOSTICS: -UNUSED_PARAMETER
@@ -1,23 +0,0 @@
// !CONSTRAINT_SYSTEM_FOR_OVERLOAD_RESOLUTION: CONSTRAINT_SYSTEM_FOR_NEW_INFERENCE
// !DIAGNOSTICS: -UNUSED_PARAMETER
// FILE: a.kt
package a
fun <T> foo(block: (T?) -> Unit) {}
// FILE: b.kt
package b
fun <K> foo(block: (K) -> Unit) {}
// FILE: test.kt
import a.*
import b.*
fun main() {
foo<String> { }
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !CONSTRAINT_SYSTEM_FOR_OVERLOAD_RESOLUTION: CONSTRAINT_SYSTEM_FOR_NEW_INFERENCE
// !DIAGNOSTICS: -UNUSED_PARAMETER
@@ -1,28 +0,0 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE
interface A
interface B
interface C: A, B
interface D: A, B
interface E: A, B
fun foo(c: C?, d: D?, e: E?) {
val test1: A? = c ?: d ?: e
val test2: B? = if (false) if (true) c else d else e
val test3: A? = when {
true -> c
else -> when {
true -> d
else -> e
}
}
val test4: B? = when (1) {
1 -> c
2 -> d
else -> e
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_VARIABLE
interface A
@@ -1,40 +0,0 @@
// !LANGUAGE: +BooleanElvisBoundSmartCasts
// See KT-20752
class Unstable {
val first: String? get() = null
}
class StringList {
fun remove(s: String) = s
}
fun StringList.remove(s: String?) = s ?: ""
fun String.isEmpty() = this == ""
fun foo(list: StringList, arg: Unstable) {
list.remove(arg.first)
if (arg.first?.isEmpty() ?: false) {
// Should be still resolved to extension, without smart cast or smart cast impossible
list.remove(arg.first)
}
}
class UnstableBoolean {
val first: Boolean? get() = null
}
class BooleanList {
fun remove(b: Boolean) = b
}
fun BooleanList.remove(b: Boolean?) = b ?: false
fun bar(list: BooleanList, arg: UnstableBoolean) {
list.remove(arg.first)
if (arg.first ?: false) {
// Should be still resolved to extension, without smart cast or smart cast impossible
list.remove(arg.first)
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !LANGUAGE: +BooleanElvisBoundSmartCasts
// See KT-20752
@@ -1,7 +0,0 @@
fun foo() {
var v: String? = "xyz"
// It is possible in principle to provide smart cast here
v<!UNSAFE_CALL!>.<!>length
v = null
v<!UNSAFE_CALL!>.<!>length
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
fun foo() {
var v: String? = "xyz"
// It is possible in principle to provide smart cast here
@@ -1,18 +0,0 @@
// FILE: foo.kt
package foo
fun <T> f(l: List<T>) {}
// FILE: bar.kt
package bar
fun <T> f(l: List<T>) {}
// FILE: main.kt
import foo.*
import bar.*
fun <T> test(l: List<T>) {
<!OVERLOAD_RESOLUTION_AMBIGUITY!>f<!>(l)
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// FILE: foo.kt
package foo
@@ -1,40 +0,0 @@
// NI_EXPECTED_FILE
interface Ref<T> {
var x: T
}
class LateInitNumRef<NN: Number>() : Ref<NN> {
constructor(x: NN) : this() { this.x = x }
private var xx: NN? = null
override var x: NN
get() = xx!!
set(value) {
xx = value
}
}
typealias LateNR<Nt> = LateInitNumRef<Nt>
fun <V, R : Ref<in V>> update(r: R, v: V): R {
r.x = v
return r
}
val r1 = update(LateInitNumRef(), 1)
val r1a = update(LateNR(), 1)
val r2 = update(LateInitNumRef(1), 1)
val r2a = update(LateNR(1), 1)
val r3 = LateInitNumRef(1)
val r3a = LateNR(1)
fun test() {
r1.x = r1.x
r1a.x = r1a.x
r2.x = r2.x
r2a.x = r2a.x
r3.x = r3.x
r3a.x = r3a.x
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// NI_EXPECTED_FILE
interface Ref<T> {
@@ -1,16 +0,0 @@
// NI_EXPECTED_FILE
class Foo<A : Number>
class Bar<B : CharSequence>
class Hr<A, B, C, D>(val a: A, val b: B)
typealias Test<A, B> = Hr<A, B, Foo<A>, Bar<B>>
val test1 = Test(1, "")
val test2 = Test(1, 2)
typealias Bas<T> = Hr<T, T, Foo<T>, Bar<T>>
val test3 = Bas(1, 1)
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// NI_EXPECTED_FILE
class Foo<A : Number>

Some files were not shown because too many files have changed in this diff Show More