[Test] Disable UNUSED_* diagnostics in tests which are not belong to contolFlowAnalysis suite
This commit is contained in:
committed by
TeamCityServer
parent
85949b387e
commit
cd890d5833
+3
-3
@@ -1,9 +1,9 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
package f
|
||||
|
||||
fun <T> g(<!UNUSED_PARAMETER!>i<!>: Int, <!UNUSED_PARAMETER!>a<!>: Any): List<T> {throw Exception()}
|
||||
fun <T> g(<!UNUSED_PARAMETER!>a<!>: Any, <!UNUSED_PARAMETER!>i<!>: Int): Collection<T> {throw Exception()}
|
||||
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 <!UNUSED_VARIABLE!>c<!>: List<T> = <!CANNOT_COMPLETE_RESOLVE{OI}, OVERLOAD_RESOLUTION_AMBIGUITY{NI}!>g<!>(1, 1)
|
||||
val c: List<T> = <!CANNOT_COMPLETE_RESOLVE{OI}, OVERLOAD_RESOLUTION_AMBIGUITY{NI}!>g<!>(1, 1)
|
||||
}
|
||||
|
||||
Vendored
+3
-3
@@ -1,7 +1,7 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
package f
|
||||
|
||||
fun <R> h(<!UNUSED_PARAMETER!>i<!>: Int, <!UNUSED_PARAMETER!>a<!>: Any, <!UNUSED_PARAMETER!>r<!>: R, <!UNUSED_PARAMETER!>f<!>: (Boolean) -> Int) = 1
|
||||
fun <R> h(<!UNUSED_PARAMETER!>a<!>: Any, <!UNUSED_PARAMETER!>i<!>: Int, <!UNUSED_PARAMETER!>r<!>: R, <!UNUSED_PARAMETER!>f<!>: (Boolean) -> Int) = 1
|
||||
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() = <!CANNOT_COMPLETE_RESOLVE{OI}, OVERLOAD_RESOLUTION_AMBIGUITY{NI}!>h<!>(1, 1, 1, { <!CANNOT_INFER_PARAMETER_TYPE{OI}, UNUSED_ANONYMOUS_PARAMETER!>b<!> -> 42 })
|
||||
fun test() = <!CANNOT_COMPLETE_RESOLVE{OI}, OVERLOAD_RESOLUTION_AMBIGUITY{NI}!>h<!>(1, 1, 1, { <!CANNOT_INFER_PARAMETER_TYPE{OI}!>b<!> -> 42 })
|
||||
|
||||
+3
-3
@@ -1,10 +1,10 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
package f
|
||||
|
||||
fun <T> f(<!UNUSED_PARAMETER!>i<!>: Int, <!UNUSED_PARAMETER!>c<!>: Collection<T>): List<T> {throw Exception()}
|
||||
fun <T> f(<!UNUSED_PARAMETER!>a<!>: Any, <!UNUSED_PARAMETER!>l<!>: List<T>): Collection<T> {throw Exception()}
|
||||
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(<!UNUSED_PARAMETER!>l<!>: List<T>) {
|
||||
fun <T> test(l: List<T>) {
|
||||
<!CANNOT_COMPLETE_RESOLVE{OI}, OVERLOAD_RESOLUTION_AMBIGUITY{NI}!>f<!>(1, <!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER{OI}!>emptyList<!>())
|
||||
}
|
||||
|
||||
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
package f
|
||||
|
||||
fun <T> f(i: Int, t: T, c: MutableCollection<T>) {}
|
||||
fun <T> f(a: Any, t: T, l: MutableList<T>) {}
|
||||
|
||||
fun test(l: List<Int>) {
|
||||
<!NONE_APPLICABLE!>f<!>(1, "", l)
|
||||
}
|
||||
+3
-2
@@ -1,7 +1,8 @@
|
||||
// FIR_IDENTICAL
|
||||
package f
|
||||
|
||||
fun <T> f(<!UNUSED_PARAMETER!>i<!>: Int, <!UNUSED_PARAMETER!>t<!>: T, <!UNUSED_PARAMETER!>c<!>: MutableCollection<T>) {}
|
||||
fun <T> f(<!UNUSED_PARAMETER!>a<!>: Any, <!UNUSED_PARAMETER!>t<!>: T, <!UNUSED_PARAMETER!>l<!>: MutableList<T>) {}
|
||||
fun <T> f(i: Int, t: T, c: MutableCollection<T>) {}
|
||||
fun <T> f(a: Any, t: T, l: MutableList<T>) {}
|
||||
|
||||
fun test(l: List<Int>) {
|
||||
<!NONE_APPLICABLE!>f<!>(1, "", l)
|
||||
|
||||
+3
-4
@@ -2,10 +2,9 @@
|
||||
// !DIAGNOSTICS: -CONFLICTING_JVM_DECLARATIONS
|
||||
package f
|
||||
|
||||
fun <R> h(<!UNUSED_PARAMETER!>f<!>: (Boolean) -> R) = 1
|
||||
fun <R> h(<!UNUSED_PARAMETER!>f<!>: (String) -> R) = 2
|
||||
fun <R> h(f: (Boolean) -> R) = 1
|
||||
fun <R> h(f: (String) -> R) = 2
|
||||
|
||||
fun test() = <!CANNOT_COMPLETE_RESOLVE{OI}, OVERLOAD_RESOLUTION_AMBIGUITY{NI}!>h<!>{ <!CANNOT_INFER_PARAMETER_TYPE{OI}, UNUSED_ANONYMOUS_PARAMETER!>i<!> -> getAnswer() }
|
||||
fun test() = <!CANNOT_COMPLETE_RESOLVE{OI}, OVERLOAD_RESOLUTION_AMBIGUITY{NI}!>h<!>{ <!CANNOT_INFER_PARAMETER_TYPE{OI}!>i<!> -> getAnswer() }
|
||||
|
||||
fun getAnswer() = 42
|
||||
|
||||
|
||||
+1
-2
@@ -1,8 +1,7 @@
|
||||
|
||||
fun <T> Array<out T>.intersect(other: Iterable<T>) {
|
||||
val set = toMutableSet()
|
||||
set.retainAll(other)
|
||||
}
|
||||
|
||||
fun <X> Array<out X>.toMutableSet(): MutableSet<X> = TODO()
|
||||
fun <Y> MutableCollection<in Y>.retainAll(<!UNUSED_PARAMETER!>elements<!>: Iterable<Y>) {}
|
||||
fun <Y> MutableCollection<in Y>.retainAll(elements: Iterable<Y>) {}
|
||||
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
fun <V, R, M : MutableMap<in R, out V>> mapKeysTo(destination: M): Inv3<R, V, M> {
|
||||
val foo = associateByTo(destination)
|
||||
|
||||
return foo
|
||||
}
|
||||
|
||||
fun < Y, Z, T : MutableMap<in Y, out Z>> associateByTo(destination: T): Inv3<Y, Z, T> = TODO()
|
||||
|
||||
interface Inv3<A, B, C>
|
||||
+2
-1
@@ -1,9 +1,10 @@
|
||||
// FIR_IDENTICAL
|
||||
fun <V, R, M : MutableMap<in R, out V>> mapKeysTo(destination: M): Inv3<R, V, M> {
|
||||
val foo = associateByTo(destination)
|
||||
|
||||
return foo
|
||||
}
|
||||
|
||||
fun < Y, Z, T : MutableMap<in Y, out Z>> associateByTo(<!UNUSED_PARAMETER!>destination<!>: T): Inv3<Y, Z, T> = TODO()
|
||||
fun < Y, Z, T : MutableMap<in Y, out Z>> associateByTo(destination: T): Inv3<Y, Z, T> = TODO()
|
||||
|
||||
interface Inv3<A, B, C>
|
||||
|
||||
Vendored
+1
-1
@@ -8,4 +8,4 @@ fun <Y: X, X : Inv<out String>> foo(x: X, y: Y) {
|
||||
rY.length
|
||||
}
|
||||
|
||||
fun <Y> bar(<!UNUSED_PARAMETER!>l<!>: Inv<Y>): Y = TODO()
|
||||
fun <Y> bar(l: Inv<Y>): Y = TODO()
|
||||
|
||||
+1
-1
@@ -6,5 +6,5 @@ fun <T> foo(array: Array<Array<T>>): Array<Array<T>> = array
|
||||
fun test(array: Array<Array<out Int>>) {
|
||||
<!TYPE_INFERENCE_PARAMETER_CONSTRAINT_ERROR{OI}!>foo<!>(<!TYPE_MISMATCH{NI}, TYPE_MISMATCH{NI}!>array<!>)
|
||||
|
||||
val f: Array<out Array<out Int>> = <!TYPE_INFERENCE_PARAMETER_CONSTRAINT_ERROR{OI}!>foo<!>(<!TYPE_MISMATCH{NI}, TYPE_MISMATCH!>array<!>)
|
||||
val f: Array<out Array<out Int>> = <!TYPE_INFERENCE_PARAMETER_CONSTRAINT_ERROR{OI}!>foo<!>(<!TYPE_MISMATCH, TYPE_MISMATCH!>array<!>)
|
||||
}
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@ fun foo(): String? {
|
||||
if (true)
|
||||
return@run
|
||||
else
|
||||
if (true) <!UNUSED_EXPRESSION!>42<!>
|
||||
if (true) 42
|
||||
}
|
||||
|
||||
run {
|
||||
@@ -39,4 +39,4 @@ fun foo(): String? {
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
-14
@@ -1,14 +0,0 @@
|
||||
// SKIP_TXT
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// !LANGUAGE: +NewInference
|
||||
|
||||
fun foo(f: () -> Unit) {}
|
||||
fun bar(): Int = 42
|
||||
fun test() {
|
||||
foo {
|
||||
::bar // should be fine
|
||||
}
|
||||
foo {
|
||||
{ "something" } // should be fine
|
||||
}
|
||||
}
|
||||
+3
-2
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// SKIP_TXT
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// !LANGUAGE: +NewInference
|
||||
@@ -6,9 +7,9 @@ fun foo(f: () -> Unit) {}
|
||||
fun bar(): Int = 42
|
||||
fun test() {
|
||||
foo {
|
||||
<!UNUSED_EXPRESSION!>::bar<!> // should be fine
|
||||
::bar // should be fine
|
||||
}
|
||||
foo {
|
||||
<!UNUSED_LAMBDA_EXPRESSION!>{ "something" }<!> // should be fine
|
||||
{ "something" } // should be fine
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+4
-4
@@ -29,7 +29,7 @@ fun test(i: Inv<Nothing>, iUnit: Inv<Unit>) {
|
||||
run<Nothing?> { null }
|
||||
}
|
||||
launch {
|
||||
run { <!UNUSED_EXPRESSION!>null<!> }
|
||||
run { null }
|
||||
}
|
||||
launch {
|
||||
run(i) { TODO() }
|
||||
@@ -38,16 +38,16 @@ fun test(i: Inv<Nothing>, iUnit: Inv<Unit>) {
|
||||
run(A.flexible(i)) { TODO() }
|
||||
}
|
||||
launch {
|
||||
run(A.flexible(iUnit)) { <!UNUSED_EXPRESSION!>42<!> }
|
||||
run(A.flexible(iUnit)) { 42 }
|
||||
}
|
||||
launch {
|
||||
@Suppress("UNSUPPORTED")
|
||||
run<dynamic> { <!UNUSED_EXPRESSION!>""<!> }
|
||||
run<dynamic> { "" }
|
||||
}
|
||||
|
||||
if (iUnit is <!INCOMPATIBLE_TYPES!>String<!>) {
|
||||
launch {
|
||||
run(A.flexible(iUnit)) { <!UNUSED_EXPRESSION!>42<!> }
|
||||
run(A.flexible(iUnit)) { 42 }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -8,7 +8,7 @@ val a: () -> Unit = l@{
|
||||
|
||||
// Expected type here is Unit, but it also implies coercion,
|
||||
// so we can end lambda body with statement
|
||||
if (true) <!UNUSED_EXPRESSION!>42<!>
|
||||
if (true) 42
|
||||
}
|
||||
|
||||
val b: () -> Unit = l@{
|
||||
@@ -16,7 +16,7 @@ val b: () -> Unit = l@{
|
||||
if (true) return@l <!TYPE_MISMATCH!>"hello"<!>
|
||||
|
||||
// However, this is OK, because here coercion is applied
|
||||
<!UNUSED_EXPRESSION!>"hello"<!>
|
||||
"hello"
|
||||
}
|
||||
|
||||
val c: () -> Unit = {
|
||||
|
||||
Vendored
+4
-4
@@ -3,16 +3,16 @@
|
||||
fun <T> materialize(): T = TODO()
|
||||
|
||||
fun implicitCoercion() {
|
||||
val <!UNUSED_VARIABLE!>a<!> = {
|
||||
val a = {
|
||||
// Block is implicitly Unit-coerced, so it is allowed to place statement at the end of lambda
|
||||
if (true) <!UNUSED_EXPRESSION!>42<!>
|
||||
if (true) 42
|
||||
}
|
||||
|
||||
val <!UNUSED_VARIABLE!>b<!> = l@{
|
||||
val b = l@{
|
||||
return@l
|
||||
}
|
||||
|
||||
val <!UNUSED_VARIABLE!>c<!> = l@{
|
||||
val c = l@{
|
||||
// Error: block doesn't have an expected type, so call can't be inferred!
|
||||
return@l <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER{NI}, TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER{OI}!>materialize<!>()
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -5,7 +5,7 @@ fun <T> materialize(): T = TODO()
|
||||
fun a(): Unit = run {
|
||||
run {
|
||||
// Ok, block is coerced, because it has (indirectly) Unit-expected type
|
||||
<!UNUSED_EXPRESSION{NI}!>"hello"<!>
|
||||
"hello"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ fun bar(block: () -> String) {}
|
||||
|
||||
fun test_5(b: Boolean) {
|
||||
bar {
|
||||
<!TYPE_MISMATCH{NI}, TYPE_MISMATCH!>if (b) {
|
||||
<!TYPE_MISMATCH, TYPE_MISMATCH!>if (b) {
|
||||
println("meh")
|
||||
}<!>
|
||||
}
|
||||
|
||||
@@ -10,17 +10,17 @@ fun noCoercionLastExpressionUsedAsReturnArgument() {
|
||||
}
|
||||
|
||||
fun noCoercionBlockHasExplicitType() {
|
||||
val <!UNUSED_VARIABLE!>b<!>: () -> Int = {
|
||||
<!TYPE_MISMATCH!>if (true) <!UNUSED_EXPRESSION!>42<!><!>
|
||||
val b: () -> Int = {
|
||||
<!TYPE_MISMATCH!>if (true) 42<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun noCoercionBlockHasExplicitReturn() {
|
||||
val <!UNUSED_VARIABLE!>c<!> = l@{
|
||||
val c = l@{
|
||||
if (true) return@l 42
|
||||
|
||||
<!INVALID_IF_AS_EXPRESSION!>if<!> (true) 239
|
||||
}
|
||||
}
|
||||
|
||||
fun noCoercionInExpressionBody(): Unit = <!TYPE_MISMATCH!>"hello"<!>
|
||||
fun noCoercionInExpressionBody(): Unit = <!TYPE_MISMATCH!>"hello"<!>
|
||||
|
||||
+2
-2
@@ -5,11 +5,11 @@ package d
|
||||
|
||||
import checkSubtype
|
||||
|
||||
fun <T: Any> joinT(<!UNUSED_PARAMETER!>x<!>: Int, vararg <!UNUSED_PARAMETER!>a<!>: T): T? {
|
||||
fun <T: Any> joinT(x: Int, vararg a: T): T? {
|
||||
return null
|
||||
}
|
||||
|
||||
fun <T: Any> joinT(<!UNUSED_PARAMETER!>x<!>: Comparable<*>, <!UNUSED_PARAMETER!>y<!>: T): T? {
|
||||
fun <T: Any> joinT(x: Comparable<*>, y: T): T? {
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
@@ -4,13 +4,13 @@ package conflictingSubstitutions
|
||||
|
||||
import java.util.*
|
||||
|
||||
fun <R> elemAndList(r: R, <!UNUSED_PARAMETER!>t<!>: MutableList<R>): R = r
|
||||
fun <R> R.elemAndListWithReceiver(r: R, <!UNUSED_PARAMETER!>t<!>: MutableList<R>): R = r
|
||||
fun <R> elemAndList(r: R, t: MutableList<R>): R = r
|
||||
fun <R> R.elemAndListWithReceiver(r: R, t: MutableList<R>): R = r
|
||||
|
||||
fun test() {
|
||||
val <!UNUSED_VARIABLE!>s<!> = <!TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS{OI}!>elemAndList<!>(11, list("72"))
|
||||
val s = <!TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS{OI}!>elemAndList<!>(11, list("72"))
|
||||
|
||||
val <!UNUSED_VARIABLE!>u<!> = 11.<!TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS{OI}!>elemAndListWithReceiver<!>(4, list("7"))
|
||||
val u = 11.<!TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS{OI}!>elemAndListWithReceiver<!>(4, list("7"))
|
||||
}
|
||||
|
||||
fun <T> list(value: T) : ArrayList<T> {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
class A<X, Y : X>
|
||||
|
||||
class B<X, Y : X>(<!UNUSED_PARAMETER!>foo<!>: A<X, Y>) {
|
||||
class B<X, Y : X>(foo: A<X, Y>) {
|
||||
fun test1(a: A<X, Y>) {
|
||||
B(a)
|
||||
val b: B<X, Y> = B(a)
|
||||
@@ -14,7 +14,7 @@ class B<X, Y : X>(<!UNUSED_PARAMETER!>foo<!>: A<X, Y>) {
|
||||
|
||||
class C<X, Z, Y : X>
|
||||
|
||||
class D<X, Z, Y : X>(<!UNUSED_PARAMETER!>foo<!>: C<X, Z, Y>) {
|
||||
class D<X, Z, Y : X>(foo: C<X, Z, Y>) {
|
||||
fun test(a: C<Y, Y, Y>) {
|
||||
val d: D<X, Y, Y> = <!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH{OI}, TYPE_MISMATCH{NI}, TYPE_MISMATCH{NI}!>D(a)<!>
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -28,5 +28,5 @@ abstract class MySettingsListener<S extends MyComparableSettings> {}
|
||||
fun test() {
|
||||
val a = MySettings.getSettings()
|
||||
a.getLinkedProjectsSettings()
|
||||
a.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE{OI}, TYPE_INFERENCE_UPPER_BOUND_VIOLATED{OI}, UNRESOLVED_REFERENCE_WRONG_RECEIVER!>linkedProjectsSettings<!>
|
||||
a.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE{OI}, TYPE_INFERENCE_UPPER_BOUND_VIOLATED{OI}, UNRESOLVED_REFERENCE_WRONG_RECEIVER{NI}!>linkedProjectsSettings<!>
|
||||
}
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
package h
|
||||
//+JDK
|
||||
import java.util.*
|
||||
import checkSubtype
|
||||
|
||||
fun <T> id(t: T) : T = t
|
||||
|
||||
fun <T> id1(t: T) = t
|
||||
|
||||
fun <R> elem(t: List<R>): R = t.get(0)
|
||||
|
||||
fun <R> elemAndList(r: R, t: List<R>): R = t.get(0)
|
||||
|
||||
fun <T> both(t1: T, t2: T) : T = t1
|
||||
|
||||
fun test1() {
|
||||
val a = elem(list(2))
|
||||
val b = id(elem(list(2)))
|
||||
val c = id(id1(id(id1(list(33)))))
|
||||
checkSubtype<Int>(a)
|
||||
checkSubtype<Int>(b)
|
||||
checkSubtype<List<Int>>(c)
|
||||
|
||||
val d : ArrayList<Int> = newList()
|
||||
val e : ArrayList<Int> = id(newList())
|
||||
val f : ArrayList<Int> = id(id1(id(id1(newList()))))
|
||||
|
||||
checkSubtype<List<Int>>(d)
|
||||
checkSubtype<List<Int>>(e)
|
||||
checkSubtype<List<Int>>(f)
|
||||
|
||||
val g = elemAndList("", newList())
|
||||
val h = elemAndList<Long>(1, newList<Long>())
|
||||
|
||||
checkSubtype<String>(g)
|
||||
checkSubtype<Long>(h)
|
||||
|
||||
val i = both(1, "")
|
||||
val j = both(id(1), id(""))
|
||||
checkSubtype<Any>(i)
|
||||
checkSubtype<Any>(j)
|
||||
}
|
||||
|
||||
fun <T> list(value: T) : ArrayList<T> {
|
||||
val list = ArrayList<T>()
|
||||
list.add(value)
|
||||
return list
|
||||
}
|
||||
|
||||
fun <S> newList() : ArrayList<S> {
|
||||
return ArrayList<S>()
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
|
||||
package h
|
||||
@@ -11,9 +12,9 @@ fun <T> id1(t: T) = t
|
||||
|
||||
fun <R> elem(t: List<R>): R = t.get(0)
|
||||
|
||||
fun <R> elemAndList(<!UNUSED_PARAMETER!>r<!>: R, t: List<R>): R = t.get(0)
|
||||
fun <R> elemAndList(r: R, t: List<R>): R = t.get(0)
|
||||
|
||||
fun <T> both(t1: T, <!UNUSED_PARAMETER!>t2<!>: T) : T = t1
|
||||
fun <T> both(t1: T, t2: T) : T = t1
|
||||
|
||||
fun test1() {
|
||||
val a = elem(list(2))
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
package a
|
||||
|
||||
class MyList<T>(<!UNUSED_PARAMETER!>t<!>: T) {}
|
||||
class MyList<T>(t: T) {}
|
||||
|
||||
fun <T> getMyList(t: T) : MyList< T> = MyList(t)
|
||||
fun <T> getMyListToWriteTo(t: T) : MyList< in T> = MyList(t)
|
||||
fun <T> getMyListToReadFrom(t: T) : MyList<out T> = MyList(t)
|
||||
|
||||
fun <T> useMyList (<!UNUSED_PARAMETER!>l<!>: MyList< T>, <!UNUSED_PARAMETER!>t<!>: T) {}
|
||||
fun <T> writeToMyList (<!UNUSED_PARAMETER!>l<!>: MyList< in T>, <!UNUSED_PARAMETER!>t<!>: T) {}
|
||||
fun <T> readFromMyList(<!UNUSED_PARAMETER!>l<!>: MyList<out T>, <!UNUSED_PARAMETER!>t<!>: T) {}
|
||||
fun <T> useMyList (l: MyList< T>, t: T) {}
|
||||
fun <T> writeToMyList (l: MyList< in T>, t: T) {}
|
||||
fun <T> readFromMyList(l: MyList<out T>, t: T) {}
|
||||
|
||||
fun test1(int: Int, any: Any) {
|
||||
val a0 : MyList<Any> = getMyList(int)
|
||||
@@ -25,16 +25,16 @@ fun test1(int: Int, any: Any) {
|
||||
val a5 : MyList<in Int> = getMyListToWriteTo(any)
|
||||
|
||||
|
||||
val a6 : MyList<in Any> = <!TYPE_MISMATCH{NI}, TYPE_MISMATCH!>getMyList<Int>(int)<!>
|
||||
val a6 : MyList<in Any> = <!TYPE_MISMATCH, TYPE_MISMATCH!>getMyList<Int>(int)<!>
|
||||
val a7 : MyList<in Any> = getMyList(int)
|
||||
|
||||
val a8 : MyList<in Any> = <!TYPE_MISMATCH{NI}, TYPE_MISMATCH!>getMyListToReadFrom<Int>(int)<!>
|
||||
val a8 : MyList<in Any> = <!TYPE_MISMATCH, TYPE_MISMATCH!>getMyListToReadFrom<Int>(int)<!>
|
||||
val a9 : MyList<in Any> = <!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH{OI}, TYPE_MISMATCH{NI}, TYPE_MISMATCH{NI}!>getMyListToReadFrom(int)<!>
|
||||
|
||||
val a10 : MyList<out Int> = <!TYPE_MISMATCH{NI}, TYPE_MISMATCH!>getMyList<Any>(any)<!>
|
||||
val a10 : MyList<out Int> = <!TYPE_MISMATCH, TYPE_MISMATCH!>getMyList<Any>(any)<!>
|
||||
val a11 : MyList<out Int> = <!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH{OI}, TYPE_MISMATCH{NI}, TYPE_MISMATCH{NI}!>getMyList(any)<!>
|
||||
|
||||
val a12 : MyList<out Int> = <!TYPE_MISMATCH{NI}, TYPE_MISMATCH!>getMyListToWriteTo<Any>(any)<!>
|
||||
val a12 : MyList<out Int> = <!TYPE_MISMATCH, TYPE_MISMATCH!>getMyListToWriteTo<Any>(any)<!>
|
||||
val a13 : MyList<out Int> = <!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH{OI}, TYPE_MISMATCH{NI}, TYPE_MISMATCH{NI}!>getMyListToWriteTo(any)<!>
|
||||
|
||||
useMyList(getMyList(int), int)
|
||||
|
||||
+2
-2
@@ -5,10 +5,10 @@ import java.util.*
|
||||
import java.util.Collections.*
|
||||
|
||||
fun foo(list: List<String>) : String {
|
||||
val w : String = max(list, comparator<String?> {<!UNUSED_ANONYMOUS_PARAMETER!>o1<!>, <!UNUSED_ANONYMOUS_PARAMETER!>o2<!> -> 1
|
||||
val w : String = max(list, comparator<String?> {o1, o2 -> 1
|
||||
})
|
||||
return w
|
||||
}
|
||||
|
||||
//from library
|
||||
fun <T> comparator(<!UNUSED_PARAMETER!>fn<!>: (T,T) -> Int): Comparator<T> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
fun <T> comparator(fn: (T,T) -> Int): Comparator<T> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
@@ -6,13 +6,13 @@ class X<S> {
|
||||
}
|
||||
|
||||
fun test(x: X<Number>) {
|
||||
val <!UNUSED_VARIABLE!>y<!> = x.foo() as Int
|
||||
val y = x.foo() as Int
|
||||
}
|
||||
|
||||
fun <S, D: S> g() {
|
||||
fun <T : S> foo(): T = TODO()
|
||||
|
||||
val <!UNUSED_VARIABLE!>y<!> = <!TYPE_INFERENCE_UPPER_BOUND_VIOLATED{OI}, TYPE_MISMATCH!>foo<!>() as Int
|
||||
val y = <!TYPE_INFERENCE_UPPER_BOUND_VIOLATED{OI}, TYPE_MISMATCH{NI}!>foo<!>() as Int
|
||||
|
||||
val <!UNUSED_VARIABLE!>y2<!> = foo() as D
|
||||
val y2 = foo() as D
|
||||
}
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
|
||||
// completion order here: X, Y, WHEN_VARIABLE
|
||||
fun <T> List<T>.optimizeReadOnlyList() = when (size) {
|
||||
0 -> emptyList() // here type variable Y will be fixed to Nothing
|
||||
1 -> listOf(this[0])
|
||||
else -> this
|
||||
}
|
||||
fun <X> listOf(<!UNUSED_PARAMETER!>element<!>: X): List<X> = TODO()
|
||||
fun <X> listOf(element: X): List<X> = TODO()
|
||||
fun <Y> emptyList(): List<Y> = TODO()
|
||||
|
||||
|
||||
fun test(l: List<String>): List<String> {
|
||||
val foo = l.optimizeReadOnlyList()
|
||||
return foo
|
||||
}
|
||||
}
|
||||
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
class R<T>
|
||||
|
||||
fun <T> f(): R<T> = R<T>()
|
||||
|
||||
operator fun Int.plusAssign(y: R<Int>) {}
|
||||
|
||||
fun box() {
|
||||
1 += f()
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
// FIR_IDENTICAL
|
||||
class R<T>
|
||||
|
||||
fun <T> f(): R<T> = R<T>()
|
||||
|
||||
operator fun Int.plusAssign(<!UNUSED_PARAMETER!>y<!>: R<Int>) {}
|
||||
operator fun Int.plusAssign(y: R<Int>) {}
|
||||
|
||||
fun box() {
|
||||
1 += f()
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package n
|
||||
|
||||
fun <T> foo(<!UNUSED_PARAMETER!>t<!>: T, <!UNUSED_PARAMETER!>t1<!>: T) {}
|
||||
fun <T> foo(t: T, t1: T) {}
|
||||
|
||||
fun test() {
|
||||
//no type inference error
|
||||
foo(<!UNRESOLVED_REFERENCE!>aaab<!>, <!UNRESOLVED_REFERENCE!>bbb<!>)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
package n
|
||||
|
||||
//+JDK
|
||||
import java.util.*
|
||||
|
||||
fun <T> expected(t: T, f: () -> T) : T = t
|
||||
|
||||
fun test(arrayList: ArrayList<Int>, list: List<Int>) {
|
||||
val t = expected(arrayList, { list.reverse() })
|
||||
}
|
||||
|
||||
fun <T> List<T>.reverse() : List<T> = this
|
||||
@@ -1,12 +1,13 @@
|
||||
// FIR_IDENTICAL
|
||||
package n
|
||||
|
||||
//+JDK
|
||||
import java.util.*
|
||||
|
||||
fun <T> expected(t: T, <!UNUSED_PARAMETER!>f<!>: () -> T) : T = t
|
||||
fun <T> expected(t: T, f: () -> T) : T = t
|
||||
|
||||
fun test(arrayList: ArrayList<Int>, list: List<Int>) {
|
||||
val <!UNUSED_VARIABLE!>t<!> = expected(arrayList, { list.reverse() })
|
||||
val t = expected(arrayList, { list.reverse() })
|
||||
}
|
||||
|
||||
fun <T> List<T>.reverse() : List<T> = this
|
||||
fun <T> List<T>.reverse() : List<T> = this
|
||||
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
package n
|
||||
|
||||
//+JDK
|
||||
import java.util.*
|
||||
|
||||
fun <T> expected(t: T, f: () -> T) : T = t
|
||||
|
||||
fun test(arrayList: ArrayList<Int>, list: List<Int>) {
|
||||
val t = expected(arrayList, l@ {return@l list.reverse() })
|
||||
}
|
||||
|
||||
fun <T> List<T>.reverse() : List<T> = this
|
||||
+4
-3
@@ -1,12 +1,13 @@
|
||||
// FIR_IDENTICAL
|
||||
package n
|
||||
|
||||
//+JDK
|
||||
import java.util.*
|
||||
|
||||
fun <T> expected(t: T, <!UNUSED_PARAMETER!>f<!>: () -> T) : T = t
|
||||
fun <T> expected(t: T, f: () -> T) : T = t
|
||||
|
||||
fun test(arrayList: ArrayList<Int>, list: List<Int>) {
|
||||
val <!UNUSED_VARIABLE!>t<!> = expected(arrayList, l@ {return@l list.reverse() })
|
||||
val t = expected(arrayList, l@ {return@l list.reverse() })
|
||||
}
|
||||
|
||||
fun <T> List<T>.reverse() : List<T> = this
|
||||
fun <T> List<T>.reverse() : List<T> = this
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
fun foo(<!UNUSED_PARAMETER!>a<!>: Any) {
|
||||
foo({ <!CANNOT_INFER_PARAMETER_TYPE, UNUSED_ANONYMOUS_PARAMETER!>index<!> -> } { })
|
||||
}
|
||||
fun foo(a: Any) {
|
||||
foo({ <!CANNOT_INFER_PARAMETER_TYPE!>index<!> -> } { })
|
||||
}
|
||||
|
||||
+2
-2
@@ -5,8 +5,8 @@ package kt1293
|
||||
|
||||
fun main() {
|
||||
val intArray = arrayOfNulls<Int>(10)
|
||||
val <!UNUSED_VARIABLE!>i<!> : Int = <!TYPE_MISMATCH!>intArray[0]<!>
|
||||
val i : Int = <!TYPE_MISMATCH!>intArray[0]<!>
|
||||
requiresInt(<!TYPE_MISMATCH!>intArray[0]<!>)
|
||||
}
|
||||
|
||||
fun requiresInt(<!UNUSED_PARAMETER!>i<!>: Int) {}
|
||||
fun requiresInt(i: Int) {}
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
package a
|
||||
//+JDK
|
||||
import java.util.*
|
||||
import checkSubtype
|
||||
|
||||
fun <A> cons(x: A, xs: List<A>): List<A> = xs
|
||||
|
||||
fun <B> nil(): List<B> = arrayList()
|
||||
|
||||
fun test() {
|
||||
val xs = cons(1, nil())
|
||||
val xs1 = cons("", nil())
|
||||
val xs2 = cons(1, nil<Any>())
|
||||
|
||||
checkSubtype<List<Int>>(xs)
|
||||
checkSubtype<List<String>>(xs1)
|
||||
checkSubtype<List<Any>>(xs2)
|
||||
}
|
||||
|
||||
|
||||
// ---------------------
|
||||
// copy from kotlin util
|
||||
|
||||
fun <T> arrayList(vararg values: T) : ArrayList<T> = values.toCollection(ArrayList<T>(values.size))
|
||||
|
||||
fun <T, C: MutableCollection<in T>> Array<T>.toCollection(result: C) : C {
|
||||
for (element in this) result.add(element)
|
||||
return result
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
|
||||
package a
|
||||
@@ -5,7 +6,7 @@ package a
|
||||
import java.util.*
|
||||
import checkSubtype
|
||||
|
||||
fun <A> cons(<!UNUSED_PARAMETER!>x<!>: A, xs: List<A>): List<A> = xs
|
||||
fun <A> cons(x: A, xs: List<A>): List<A> = xs
|
||||
|
||||
fun <B> nil(): List<B> = arrayList()
|
||||
|
||||
|
||||
@@ -31,6 +31,6 @@ fun foo() {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <T> array(vararg t : T) : Array<T> = t as Array<T>
|
||||
|
||||
infix fun <T, R> Array<T>.map(<!UNUSED_PARAMETER!>transform<!> : (T) -> R) : List<R> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
infix fun <T, R> Array<T>.map(transform : (T) -> R) : List<R> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
infix fun <T, R> Iterable<T>.map(<!UNUSED_PARAMETER!>transform<!> : (T) -> R) : List<R> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
infix fun <T, R> Iterable<T>.map(transform : (T) -> R) : List<R> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
+2
-2
@@ -6,8 +6,8 @@ package i
|
||||
import java.util.*
|
||||
import checkSubtype
|
||||
|
||||
fun <T, R> Collection<T>.map1(<!UNUSED_PARAMETER!>f<!> : (T) -> R) : List<R> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
fun <T, R> <!PLATFORM_CLASS_MAPPED_TO_KOTLIN!>java.lang.Iterable<T><!>.map1(<!UNUSED_PARAMETER!>f<!> : (T) -> R) : List<R> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
fun <T, R> Collection<T>.map1(f : (T) -> R) : List<R> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
fun <T, R> <!PLATFORM_CLASS_MAPPED_TO_KOTLIN!>java.lang.Iterable<T><!>.map1(f : (T) -> R) : List<R> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
fun test(list: List<Int>) {
|
||||
val res = list.map1 { it }
|
||||
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
package j
|
||||
|
||||
interface MyFunc<T> {}
|
||||
|
||||
class A(val b: B) {
|
||||
}
|
||||
|
||||
class B {
|
||||
operator fun <T> invoke(f: (T) -> T): MyFunc<T> = throw Exception()
|
||||
}
|
||||
|
||||
fun <R> id(r: R) = r
|
||||
|
||||
fun foo(a: A) {
|
||||
val r : MyFunc<Int> = id (a.b { x -> x + 14 })
|
||||
}
|
||||
compiler/testData/diagnostics/tests/inference/nestedCalls/completeNestedForVariableAsFunctionCall.kt
Vendored
+4
-3
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
package j
|
||||
|
||||
interface MyFunc<T> {}
|
||||
@@ -6,11 +7,11 @@ class A(val b: B) {
|
||||
}
|
||||
|
||||
class B {
|
||||
operator fun <T> invoke(<!UNUSED_PARAMETER!>f<!>: (T) -> T): MyFunc<T> = throw Exception()
|
||||
operator fun <T> invoke(f: (T) -> T): MyFunc<T> = throw Exception()
|
||||
}
|
||||
|
||||
fun <R> id(r: R) = r
|
||||
|
||||
fun foo(a: A) {
|
||||
val <!UNUSED_VARIABLE!>r<!> : MyFunc<Int> = id (a.b { x -> x + 14 })
|
||||
}
|
||||
val r : MyFunc<Int> = id (a.b { x -> x + 14 })
|
||||
}
|
||||
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
class A<T> {
|
||||
fun <S> foo(s: S): S = s
|
||||
fun <U> bar(s: U): List<T> = null!!
|
||||
|
||||
fun test() = foo(bar(""))
|
||||
}
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
// FIR_IDENTICAL
|
||||
class A<T> {
|
||||
fun <S> foo(s: S): S = s
|
||||
fun <U> bar(<!UNUSED_PARAMETER!>s<!>: U): List<T> = null!!
|
||||
fun <U> bar(s: U): List<T> = null!!
|
||||
|
||||
fun test() = foo(bar(""))
|
||||
}
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
//KT-3395 mapOf function can't be used as literal
|
||||
package b
|
||||
|
||||
import java.util.ArrayList
|
||||
|
||||
public fun <T> query(t: T, args: Map<String, Any>): List<T> {
|
||||
return ArrayList<T>()
|
||||
}
|
||||
|
||||
fun test(pair: Pair<String, Int>) {
|
||||
val id = "Hello" // variable is marked as unused
|
||||
|
||||
println("Some" + query(0, mapOf(id to 1)))
|
||||
|
||||
println("Some" + query(0, mapOf(pair)))
|
||||
}
|
||||
|
||||
|
||||
//from standard library
|
||||
fun <K, V> mapOf(vararg values: Pair<K, V>): Map<K, V> { throw Exception() }
|
||||
|
||||
infix fun <A,B> A.to(that: B): Pair<A, B> { throw Exception() }
|
||||
|
||||
fun println(message : Any?) { throw Exception() }
|
||||
|
||||
class Pair<out A, out B> () {}
|
||||
|
||||
//short example
|
||||
fun <T> foo(t: T) = t
|
||||
|
||||
fun test(t: String) {
|
||||
|
||||
println("Some" + foo(t)) // t was marked with black square
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
// FIR_IDENTICAL
|
||||
//KT-3395 mapOf function can't be used as literal
|
||||
package b
|
||||
|
||||
import java.util.ArrayList
|
||||
|
||||
public fun <T> query(<!UNUSED_PARAMETER!>t<!>: T, <!UNUSED_PARAMETER!>args<!>: Map<String, Any>): List<T> {
|
||||
public fun <T> query(t: T, args: Map<String, Any>): List<T> {
|
||||
return ArrayList<T>()
|
||||
}
|
||||
|
||||
@@ -17,11 +18,11 @@ fun test(pair: Pair<String, Int>) {
|
||||
|
||||
|
||||
//from standard library
|
||||
fun <K, V> mapOf(vararg <!UNUSED_PARAMETER!>values<!>: Pair<K, V>): Map<K, V> { throw Exception() }
|
||||
fun <K, V> mapOf(vararg values: Pair<K, V>): Map<K, V> { throw Exception() }
|
||||
|
||||
infix fun <A,B> A.to(<!UNUSED_PARAMETER!>that<!>: B): Pair<A, B> { throw Exception() }
|
||||
infix fun <A,B> A.to(that: B): Pair<A, B> { throw Exception() }
|
||||
|
||||
fun println(<!UNUSED_PARAMETER!>message<!> : Any?) { throw Exception() }
|
||||
fun println(message : Any?) { throw Exception() }
|
||||
|
||||
class Pair<out A, out B> () {}
|
||||
|
||||
@@ -32,4 +33,3 @@ fun test(t: String) {
|
||||
|
||||
println("Some" + foo(t)) // t was marked with black square
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -5,11 +5,11 @@ class F {
|
||||
fun p(): String? = null
|
||||
}
|
||||
|
||||
fun foo(<!UNUSED_PARAMETER!>s<!>: String) {}
|
||||
fun foo(s: String) {}
|
||||
|
||||
fun r(): Int? = null
|
||||
|
||||
fun test() {
|
||||
foo(<!TYPE_MISMATCH!>F().p()<!>)
|
||||
foo(<!TYPE_MISMATCH!>r()<!>)
|
||||
}
|
||||
}
|
||||
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
package a
|
||||
|
||||
fun foo(l: List<Int>): Int = l.get(0)
|
||||
|
||||
fun <T> emptyList(): List<T> = throw Exception()
|
||||
|
||||
fun <T: Any> makeNullable(t: T): T? = null
|
||||
|
||||
fun bar(i: Int) = i
|
||||
fun bar(a: Any) = a
|
||||
|
||||
fun test(array: Array<Int>) {
|
||||
bar(array[foo(emptyList())])
|
||||
|
||||
bar(foo(emptyList()) + foo(a.emptyList()))
|
||||
|
||||
bar(makeNullable(foo(emptyList())) ?: 0)
|
||||
}
|
||||
+3
-2
@@ -1,10 +1,11 @@
|
||||
// FIR_IDENTICAL
|
||||
package a
|
||||
|
||||
fun foo(l: List<Int>): Int = l.get(0)
|
||||
|
||||
fun <T> emptyList(): List<T> = throw Exception()
|
||||
|
||||
fun <T: Any> makeNullable(<!UNUSED_PARAMETER!>t<!>: T): T? = null
|
||||
fun <T: Any> makeNullable(t: T): T? = null
|
||||
|
||||
fun bar(i: Int) = i
|
||||
fun bar(a: Any) = a
|
||||
@@ -15,4 +16,4 @@ fun test(array: Array<Int>) {
|
||||
bar(foo(emptyList()) + foo(a.emptyList()))
|
||||
|
||||
bar(makeNullable(foo(emptyList())) ?: 0)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@ package noInformationForParameter
|
||||
import java.util.*
|
||||
|
||||
fun test() {
|
||||
val <!UNUSED_VARIABLE!>n<!> = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER{NI}, TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER{OI}!>newList<!>()
|
||||
val n = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER{NI}, TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER{OI}!>newList<!>()
|
||||
|
||||
val <!UNUSED_VARIABLE!>n1<!> : List<String> = newList()
|
||||
val n1 : List<String> = newList()
|
||||
}
|
||||
|
||||
fun <S> newList() : ArrayList<S> {
|
||||
|
||||
Vendored
+3
-3
@@ -15,7 +15,7 @@ fun testAny() {
|
||||
|
||||
fun testAnyCall() {
|
||||
callAny {
|
||||
<!CANNOT_INFER_PARAMETER_TYPE, UNUSED_ANONYMOUS_PARAMETER{NI}!>error<!> -> <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE{OI}!><!DEBUG_INFO_MISSING_UNRESOLVED{NI}!>error<!>()<!>
|
||||
<!CANNOT_INFER_PARAMETER_TYPE!>error<!> -> <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE{OI}!><!DEBUG_INFO_MISSING_UNRESOLVED{NI}!>error<!>()<!>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,10 +27,10 @@ fun testParam() {
|
||||
|
||||
fun testParamCall() {
|
||||
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER{NI}, TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER{OI}!>callParam<!> {
|
||||
<!CANNOT_INFER_PARAMETER_TYPE, UNUSED_ANONYMOUS_PARAMETER{NI}!>param<!> -> <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE{OI}!><!DEBUG_INFO_MISSING_UNRESOLVED{NI}!>param<!>()<!>
|
||||
<!CANNOT_INFER_PARAMETER_TYPE!>param<!> -> <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE{OI}!><!DEBUG_INFO_MISSING_UNRESOLVED{NI}!>param<!>()<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun testNoContext() {
|
||||
<!UNUSED_LAMBDA_EXPRESSION!>{ <!CANNOT_INFER_PARAMETER_TYPE!>it<!> -> <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>it<!> }<!>
|
||||
{ <!CANNOT_INFER_PARAMETER_TYPE!>it<!> -> <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>it<!> }
|
||||
}
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ fun <K> select3(x: K, y: K, z: K): K = TODO()
|
||||
|
||||
fun test2(f: ((String) -> Int)?) {
|
||||
val a0: ((Int) -> Int)? = select2(<!TYPE_MISMATCH{OI}!>{ <!CANNOT_INFER_PARAMETER_TYPE{OI}!>it<!> -> <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE{OI}!>it<!> }<!>, null)
|
||||
val b0: ((Nothing) -> Unit)? = select2(<!TYPE_MISMATCH{OI}!>{ <!CANNOT_INFER_PARAMETER_TYPE{OI}!>it<!> -> <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE{OI}, UNUSED_EXPRESSION{NI}!>it<!> }<!>, null)
|
||||
val b0: ((Nothing) -> Unit)? = select2(<!TYPE_MISMATCH{OI}!>{ <!CANNOT_INFER_PARAMETER_TYPE{OI}!>it<!> -> <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE{OI}!>it<!> }<!>, null)
|
||||
|
||||
select3({ it.length }, f, null)
|
||||
}
|
||||
|
||||
+6
-6
@@ -3,7 +3,7 @@ fun <S : Any> foo1(x: Array<out S?>, y: Array<in S?>) {
|
||||
val yo = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Array<S>")!>inANullable(y)<!>
|
||||
|
||||
var <!ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE!>f<!>: Array<S> = xo
|
||||
<!UNUSED_VALUE!>f =<!> yo
|
||||
f = yo
|
||||
}
|
||||
|
||||
fun <S : Any> foo2(x: Array<out S>, y: Array<in S>) {
|
||||
@@ -11,7 +11,7 @@ fun <S : Any> foo2(x: Array<out S>, y: Array<in S>) {
|
||||
val yo = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Array<S>")!>inA(y)<!>
|
||||
|
||||
var <!ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE!>f<!>: Array<S> = xo
|
||||
<!UNUSED_VALUE!>f =<!> yo
|
||||
f = yo
|
||||
}
|
||||
|
||||
class A1<S : Any>(x: Array<out S?>, y: Array<in S?>) {
|
||||
@@ -24,8 +24,8 @@ class A2<S : Any>(x: Array<out S>, y: Array<in S>) {
|
||||
val yo = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Array<S>")!>inA(y)<!>
|
||||
}
|
||||
|
||||
fun <X : Any> outANullable(<!UNUSED_PARAMETER!>x<!>: Array<out X?>): Array<X> = TODO()
|
||||
fun <Y : Any> inANullable(<!UNUSED_PARAMETER!>x<!>: Array<in Y?>): Array<Y> = TODO()
|
||||
fun <X : Any> outANullable(x: Array<out X?>): Array<X> = TODO()
|
||||
fun <Y : Any> inANullable(x: Array<in Y?>): Array<Y> = TODO()
|
||||
|
||||
fun <X : Any> outA(<!UNUSED_PARAMETER!>x<!>: Array<out X>): Array<X> = TODO()
|
||||
fun <Y : Any> inA(<!UNUSED_PARAMETER!>x<!>: Array<in Y>): Array<Y> = TODO()
|
||||
fun <X : Any> outA(x: Array<out X>): Array<X> = TODO()
|
||||
fun <Y : Any> inA(x: Array<in Y>): Array<Y> = TODO()
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package o
|
||||
|
||||
fun foo(): String? {
|
||||
return accept(JV<String?, Unit?>())
|
||||
}
|
||||
|
||||
fun <R, D> accept(v: JV<R, D>): R? = null
|
||||
|
||||
open class JV<R, D>()
|
||||
@@ -1,9 +1,10 @@
|
||||
// FIR_IDENTICAL
|
||||
package o
|
||||
|
||||
fun foo(): String? {
|
||||
return accept(JV<String?, Unit?>())
|
||||
}
|
||||
|
||||
fun <R, D> accept(<!UNUSED_PARAMETER!>v<!>: JV<R, D>): R? = null
|
||||
fun <R, D> accept(v: JV<R, D>): R? = null
|
||||
|
||||
open class JV<R, D>()
|
||||
open class JV<R, D>()
|
||||
|
||||
+4
-4
@@ -3,12 +3,12 @@ package a
|
||||
|
||||
import java.util.*
|
||||
|
||||
fun <T> g (<!UNUSED_PARAMETER!>f<!>: () -> List<T>) : T {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
fun <T> g (f: () -> List<T>) : T {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
fun test() {
|
||||
//here possibly can be a cycle on constraints
|
||||
val <!UNUSED_VARIABLE!>x<!> = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER{NI}!>g<!> { Collections.<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER{NI}, TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER{OI}!>emptyList<!>() }
|
||||
val x = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER{NI}!>g<!> { Collections.<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER{NI}, TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER{OI}!>emptyList<!>() }
|
||||
|
||||
val <!UNUSED_VARIABLE!>y<!> = g<Int> { Collections.emptyList() }
|
||||
val <!UNUSED_VARIABLE!>z<!> : List<Int> = g { Collections.<!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER{OI}!>emptyList<!>() }
|
||||
val y = g<Int> { Collections.emptyList() }
|
||||
val z : List<Int> = g { Collections.<!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER{OI}!>emptyList<!>() }
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
class Item(val name: String, val rating: Int): Comparable<Item> {
|
||||
public override fun compareTo(other: Item): Int {
|
||||
return compareBy(this, other, { rating }, { name })
|
||||
}
|
||||
}
|
||||
|
||||
// from standard library
|
||||
fun <T : Any> compareBy(a: T?, b: T?,
|
||||
vararg functions: T.() -> Comparable<*>?): Int = throw Exception()
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
class Item(val name: String, val rating: Int): Comparable<Item> {
|
||||
public override fun compareTo(other: Item): Int {
|
||||
return compareBy(this, other, { rating }, { name })
|
||||
@@ -5,5 +6,5 @@ class Item(val name: String, val rating: Int): Comparable<Item> {
|
||||
}
|
||||
|
||||
// from standard library
|
||||
fun <T : Any> compareBy(<!UNUSED_PARAMETER!>a<!>: T?, <!UNUSED_PARAMETER!>b<!>: T?,
|
||||
vararg <!UNUSED_PARAMETER!>functions<!>: T.() -> Comparable<*>?): Int = throw Exception()
|
||||
fun <T : Any> compareBy(a: T?, b: T?,
|
||||
vararg functions: T.() -> Comparable<*>?): Int = throw Exception()
|
||||
|
||||
@@ -5,10 +5,10 @@ package i
|
||||
|
||||
import checkSubtype
|
||||
|
||||
public fun<T> from(<!UNUSED_PARAMETER!>yielder<!>: ()->Iterable<T>) : Iterable<T> {
|
||||
public fun<T> from(yielder: ()->Iterable<T>) : Iterable<T> {
|
||||
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
public infix fun<T> Iterable<T>.where(<!UNUSED_PARAMETER!>predicate<!> : (T)->Boolean) : ()->Iterable<T> {
|
||||
public infix fun<T> Iterable<T>.where(predicate : (T)->Boolean) : ()->Iterable<T> {
|
||||
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
fun a() {
|
||||
|
||||
@@ -6,10 +6,10 @@ package i
|
||||
import java.util.ArrayList
|
||||
import checkSubtype
|
||||
|
||||
public infix fun<TItem> Iterable<TItem>.where(<!UNUSED_PARAMETER!>predicate<!> : (TItem)->Boolean) : ()->Iterable<TItem> {
|
||||
public infix fun<TItem> Iterable<TItem>.where(predicate : (TItem)->Boolean) : ()->Iterable<TItem> {
|
||||
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
public fun<TItem, TResult> select(<!UNUSED_PARAMETER!>yielder<!>: ()->Iterable<TItem>, <!UNUSED_PARAMETER!>selector<!> : (TItem)->TResult) : ()->Iterable<TResult> {
|
||||
public fun<TItem, TResult> select(yielder: ()->Iterable<TItem>, selector : (TItem)->TResult) : ()->Iterable<TResult> {
|
||||
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
fun a() {
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
package d
|
||||
|
||||
fun <T> asList(<!UNUSED_PARAMETER!>t<!>: T) : List<T>? {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
fun <T> asList(t: T) : List<T>? {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
fun main() {
|
||||
val <!UNUSED_VARIABLE!>list<!> : List<String> = <!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH{OI}, TYPE_MISMATCH{NI}, TYPE_MISMATCH{NI}!>asList("")<!>
|
||||
val list : List<String> = <!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH{OI}, TYPE_MISMATCH{NI}, TYPE_MISMATCH{NI}!>asList("")<!>
|
||||
}
|
||||
|
||||
@@ -12,6 +12,6 @@ fun test(numbers: Iterable<Int>) {
|
||||
}
|
||||
|
||||
//from library
|
||||
fun <T, R> Iterable<T>.map(<!UNUSED_PARAMETER!>transform<!> : (T) -> R) : List<R> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
fun <T, R> Iterable<T>.map(transform : (T) -> R) : List<R> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
fun <T> Iterable<T>.fold(<!UNUSED_PARAMETER!>initial<!>: T, <!UNUSED_PARAMETER!>operation<!>: (T, T) -> T): T {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
fun <T> Iterable<T>.fold(initial: T, operation: (T, T) -> T): T {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
@@ -25,4 +25,4 @@ fun test(result: MutableList<in Any>, collection: MutableCollection<String>, pre
|
||||
}
|
||||
|
||||
//from library
|
||||
fun String.startsWith(<!UNUSED_PARAMETER!>prefix<!>: String) : Boolean {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
fun String.startsWith(prefix: String) : Boolean {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
@@ -14,5 +14,5 @@ fun test() {
|
||||
}
|
||||
|
||||
//from library
|
||||
fun <T> arrayList(vararg <!UNUSED_PARAMETER!>values<!>: T) : ArrayList<T> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
operator fun <T> Iterable<T>.plus(<!UNUSED_PARAMETER!>elements<!>: Iterable<T>): List<T> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
fun <T> arrayList(vararg values: T) : ArrayList<T> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
operator fun <T> Iterable<T>.plus(elements: Iterable<T>): List<T> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
@@ -6,8 +6,8 @@ package n
|
||||
import checkSubtype
|
||||
|
||||
fun main() {
|
||||
val <!UNUSED_VARIABLE!>a<!> = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER{NI}, TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER{OI}!>array<!>(<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER{NI}, TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER{OI}!>array<!>())
|
||||
val <!UNUSED_VARIABLE!>a0<!> : Array<Array<Int>> = array(array())
|
||||
val a = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER{NI}, TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER{OI}!>array<!>(<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER{NI}, TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER{OI}!>array<!>())
|
||||
val a0 : Array<Array<Int>> = array(array())
|
||||
val a1 = array(array<Int>())
|
||||
checkSubtype<Array<Array<Int>>>(a1)
|
||||
val a2 = array<Array<Int>>(array())
|
||||
|
||||
@@ -5,10 +5,10 @@ package a
|
||||
|
||||
interface Foo<A>
|
||||
|
||||
fun <A, B> Foo<A>.map(<!UNUSED_PARAMETER!>f<!>: (A) -> B): Foo<B> = object : Foo<B> {}
|
||||
fun <A, B> Foo<A>.map(f: (A) -> B): Foo<B> = object : Foo<B> {}
|
||||
|
||||
|
||||
fun foo() {
|
||||
val l: Foo<String> = object : Foo<String> {}
|
||||
val <!UNUSED_VARIABLE!>m<!>: Foo<String> = l.<!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH{OI}!>map { <!UNUSED_ANONYMOUS_PARAMETER!>ppp<!> -> <!CONSTANT_EXPECTED_TYPE_MISMATCH{NI}, CONSTANT_EXPECTED_TYPE_MISMATCH{NI}!>1<!> }<!>
|
||||
val m: Foo<String> = l.<!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH{OI}!>map { ppp -> <!CONSTANT_EXPECTED_TYPE_MISMATCH{NI}, CONSTANT_EXPECTED_TYPE_MISMATCH{NI}!>1<!> }<!>
|
||||
}
|
||||
|
||||
@@ -25,4 +25,4 @@ abstract class Buggy {
|
||||
}
|
||||
|
||||
//from library
|
||||
fun <T: Any> Iterable<T>.find(<!UNUSED_PARAMETER!>predicate<!>: (T) -> Boolean) : T? {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
fun <T: Any> Iterable<T>.find(predicate: (T) -> Boolean) : T? {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
//KT-2320 failure of complex case of type inference
|
||||
package i
|
||||
|
||||
interface NotMap<B>
|
||||
|
||||
interface Entry<B> {
|
||||
fun getValue(): B
|
||||
}
|
||||
|
||||
|
||||
fun <V, R> NotMap<V>.mapValuesOriginal(ff: (Entry<V>) -> R): NotMap<R> = throw Exception()
|
||||
|
||||
fun <B, C> NotMap<B>.mapValuesOnly(f: (B) -> C) = mapValuesOriginal { e -> f(e.getValue()) }
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
//KT-2320 failure of complex case of type inference
|
||||
package i
|
||||
|
||||
@@ -8,6 +9,6 @@ interface Entry<B> {
|
||||
}
|
||||
|
||||
|
||||
fun <V, R> NotMap<V>.mapValuesOriginal(<!UNUSED_PARAMETER!>ff<!>: (Entry<V>) -> R): NotMap<R> = throw Exception()
|
||||
fun <V, R> NotMap<V>.mapValuesOriginal(ff: (Entry<V>) -> R): NotMap<R> = throw Exception()
|
||||
|
||||
fun <B, C> NotMap<B>.mapValuesOnly(f: (B) -> C) = mapValuesOriginal { e -> f(e.getValue()) }
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
//KT-2324 Can't resolve generic by type of function result
|
||||
package i
|
||||
|
||||
//+JDK
|
||||
import java.util.*
|
||||
import checkSubtype
|
||||
|
||||
fun <T, K> someFunction(list: List<T>, transform: (T) -> K): List<K> {
|
||||
val result = arrayList<K>()
|
||||
for (i in list) {
|
||||
result.add(transform(i))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
fun testSomeFunction() {
|
||||
val result1 = someFunction(arrayList<Int>(1, 2), {checkSubtype<Int>(it)}) //type of result1 is List<Int>
|
||||
assertEquals(1, result1.get(0)); //OK
|
||||
|
||||
val result2 = someFunction(arrayList<Int>(1, 2), {it}) // type of result2 is List<DONT_CARE>
|
||||
checkSubtype<List<Int>>(result2)
|
||||
assertEquals(1, result2.get(0)); //resolved to error element
|
||||
}
|
||||
|
||||
//---------------------------------
|
||||
fun assertEquals(expected: Any?, actual: Any?, message: String = "") {
|
||||
}
|
||||
|
||||
fun <T> arrayList(vararg values: T) : ArrayList<T> = values.toCollection(ArrayList<T>(values.size))
|
||||
|
||||
fun <T, C: MutableCollection<in T>> Array<T>.toCollection(result: C) : C {
|
||||
for (element in this) result.add(element)
|
||||
return result
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
|
||||
//KT-2324 Can't resolve generic by type of function result
|
||||
@@ -25,7 +26,7 @@ fun testSomeFunction() {
|
||||
}
|
||||
|
||||
//---------------------------------
|
||||
fun assertEquals(<!UNUSED_PARAMETER!>expected<!>: Any?, <!UNUSED_PARAMETER!>actual<!>: Any?, <!UNUSED_PARAMETER!>message<!>: String = "") {
|
||||
fun assertEquals(expected: Any?, actual: Any?, message: String = "") {
|
||||
}
|
||||
|
||||
fun <T> arrayList(vararg values: T) : ArrayList<T> = values.toCollection(ArrayList<T>(values.size))
|
||||
|
||||
@@ -12,8 +12,8 @@ fun test() {
|
||||
}
|
||||
|
||||
//from library
|
||||
fun <T> arrayList(vararg <!UNUSED_PARAMETER!>values<!>: T) : ArrayList<T> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
fun <T> arrayList(vararg values: T) : ArrayList<T> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
fun <T, R> Collection<T>.map(<!UNUSED_PARAMETER!>transform<!> : (T) -> R) : List<R> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
fun <T, R> Collection<T>.map(transform : (T) -> R) : List<R> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
fun <T> Iterable<T>.fold(<!UNUSED_PARAMETER!>initial<!>: T, <!UNUSED_PARAMETER!>operation<!>: (T, T) -> T): T {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
fun <T> Iterable<T>.fold(initial: T, operation: (T, T) -> T): T {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
@@ -7,4 +7,4 @@ class B<T>(val x: List<T>)
|
||||
fun <T> f(x: T): B<T> = B(arrayList(x))
|
||||
|
||||
// from standard library
|
||||
fun <T> arrayList(vararg <!UNUSED_PARAMETER!>values<!>: T) : ArrayList<T> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
fun <T> arrayList(vararg values: T) : ArrayList<T> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
|
||||
package a
|
||||
|
||||
fun <T, R: Comparable<R>> Iterable<T>._sortBy(<!UNUSED_PARAMETER!>f<!>: (T) -> R): List<T> = throw Exception()
|
||||
fun <T> _arrayList(vararg <!UNUSED_PARAMETER!>values<!>: T) : List<T> = throw Exception()
|
||||
fun <T, R: Comparable<R>> Iterable<T>._sortBy(f: (T) -> R): List<T> = throw Exception()
|
||||
fun <T> _arrayList(vararg values: T) : List<T> = throw Exception()
|
||||
|
||||
class _Pair<A>(val a: A)
|
||||
|
||||
fun test() {
|
||||
_arrayList(_Pair(1))._sortBy <!TYPE_MISMATCH{NI}, TYPE_MISMATCH{NI}!>{ <!UNUSED_ANONYMOUS_PARAMETER!>it<!> -> <!UNRESOLVED_REFERENCE!>xxx<!> }<!>
|
||||
_arrayList(_Pair(1))._sortBy <!TYPE_MISMATCH{NI}, TYPE_MISMATCH{NI}!>{ it -> <!UNRESOLVED_REFERENCE!>xxx<!> }<!>
|
||||
}
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
|
||||
package a
|
||||
|
||||
interface Closeable {}
|
||||
class C : Closeable {}
|
||||
|
||||
public inline fun <T: Closeable, R> T.use1(block: (T)-> R) : R {
|
||||
return block(this)
|
||||
}
|
||||
|
||||
fun main() {
|
||||
C().use1 {
|
||||
w -> // ERROR here
|
||||
<!UNRESOLVED_REFERENCE!>x<!>
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !WITH_NEW_INFERENCE
|
||||
|
||||
package a
|
||||
@@ -11,7 +12,7 @@ public inline fun <T: Closeable, R> T.use1(block: (T)-> R) : R {
|
||||
|
||||
fun main() {
|
||||
C().use1 {
|
||||
<!UNUSED_ANONYMOUS_PARAMETER!>w<!> -> // ERROR here
|
||||
w -> // ERROR here
|
||||
<!UNRESOLVED_REFERENCE!>x<!>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,15 +19,15 @@ fun foo(){
|
||||
fun <T> bar(t: T): T = t
|
||||
|
||||
fun test() {
|
||||
|
||||
|
||||
doAction { bar(12) }
|
||||
|
||||
val u: Unit = bar(11)
|
||||
}
|
||||
|
||||
fun testWithoutInference(col: MutableCollection<Int>) {
|
||||
|
||||
|
||||
doAction { col.add(2) }
|
||||
|
||||
|
||||
val u: Unit = col.add(2)
|
||||
}
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
//KT-2883 Type inference fails due to non-Unit value returned
|
||||
package a
|
||||
|
||||
public fun doAction(<!UNUSED_PARAMETER!>action<!> : () -> Unit){
|
||||
public fun doAction(action : () -> Unit){
|
||||
}
|
||||
|
||||
class Y<TItem>(val itemToString: (TItem) -> String){
|
||||
}
|
||||
|
||||
fun <TItem> bar(<!UNUSED_PARAMETER!>context<!> : Y<TItem>) : TItem{
|
||||
fun <TItem> bar(context : Y<TItem>) : TItem{
|
||||
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
fun foo(){
|
||||
@@ -19,15 +19,15 @@ fun foo(){
|
||||
fun <T> bar(t: T): T = t
|
||||
|
||||
fun test() {
|
||||
|
||||
|
||||
doAction { bar(12) }
|
||||
|
||||
val <!UNUSED_VARIABLE!>u<!>: Unit = <!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH{OI}, TYPE_MISMATCH{NI}, TYPE_MISMATCH{NI}!>bar(11)<!>
|
||||
val u: Unit = <!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH{OI}, TYPE_MISMATCH{NI}, TYPE_MISMATCH{NI}!>bar(11)<!>
|
||||
}
|
||||
|
||||
fun testWithoutInference(col: MutableCollection<Int>) {
|
||||
|
||||
|
||||
doAction { col.add(2) }
|
||||
|
||||
val <!UNUSED_VARIABLE!>u<!>: Unit = <!TYPE_MISMATCH!>col.add(2)<!>
|
||||
|
||||
val u: Unit = <!TYPE_MISMATCH!>col.add(2)<!>
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ enum class SomeEnum {
|
||||
|
||||
// Doesn't work
|
||||
fun Iterable<Int>.some() {
|
||||
this.fold(SomeEnum.FIRST, {res : SomeEnum, <!UNUSED_ANONYMOUS_PARAMETER!>value<!> ->
|
||||
this.fold(SomeEnum.FIRST, {res : SomeEnum, value ->
|
||||
if (res == SomeEnum.FIRST) SomeEnum.FIRST else SomeEnum.SECOND
|
||||
})
|
||||
}
|
||||
@@ -19,7 +19,7 @@ fun tempFun() : SomeEnum {
|
||||
|
||||
// Doesn't work
|
||||
fun Iterable<Int>.someSimpleWithFun() {
|
||||
this.fold(SomeEnum.FIRST, {<!UNUSED_ANONYMOUS_PARAMETER!>res<!> : SomeEnum, <!UNUSED_ANONYMOUS_PARAMETER!>value<!> ->
|
||||
this.fold(SomeEnum.FIRST, {res : SomeEnum, value ->
|
||||
tempFun()
|
||||
})
|
||||
}
|
||||
@@ -27,17 +27,17 @@ fun Iterable<Int>.someSimpleWithFun() {
|
||||
|
||||
// Works
|
||||
fun Iterable<Int>.someSimple() {
|
||||
this.fold(SomeEnum.FIRST, {<!UNUSED_ANONYMOUS_PARAMETER!>res<!> : SomeEnum, <!UNUSED_ANONYMOUS_PARAMETER!>value<!> ->
|
||||
this.fold(SomeEnum.FIRST, {res : SomeEnum, value ->
|
||||
SomeEnum.FIRST
|
||||
})
|
||||
}
|
||||
|
||||
// Works
|
||||
fun Iterable<Int>.someInt() {
|
||||
this.fold(0, {res : Int, <!UNUSED_ANONYMOUS_PARAMETER!>value<!> ->
|
||||
this.fold(0, {res : Int, value ->
|
||||
if (res == 0) 1 else 0
|
||||
})
|
||||
}
|
||||
|
||||
//from standard library
|
||||
fun <T,R> Iterable<T>.fold(<!UNUSED_PARAMETER!>initial<!>: R, <!UNUSED_PARAMETER!>operation<!>: (R, T) -> R): R {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
fun <T,R> Iterable<T>.fold(initial: R, operation: (R, T) -> R): R {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
package aa
|
||||
|
||||
class Some<T>
|
||||
|
||||
class SomeTemplate {
|
||||
fun <T> query(some: Class<T>) = some
|
||||
|
||||
|
||||
// Uncomment this to get CANNOT_COMPLETE_RESOLVE error
|
||||
fun <T> query1(some: Class<T>) = some
|
||||
fun <T> query1(some: Some<T>) = some
|
||||
}
|
||||
|
||||
fun SomeTemplate.query(f: (i: Int) -> Unit) = f
|
||||
fun SomeTemplate.query1(f: (i: Int) -> Unit) = f
|
||||
|
||||
fun test() {
|
||||
val mapperFunction = { i: Int -> }
|
||||
SomeTemplate().query(mapperFunction)
|
||||
|
||||
// TYPE_MISMATCH: Required Class<[ERROR: CANT_INFER]>, Found (kotlin.Int) -> Unit
|
||||
SomeTemplate().query { i: Int -> }
|
||||
SomeTemplate().query1 { i: Int -> }
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
package aa
|
||||
|
||||
class Some<T>
|
||||
@@ -15,10 +16,10 @@ fun SomeTemplate.query(f: (i: Int) -> Unit) = f
|
||||
fun SomeTemplate.query1(f: (i: Int) -> Unit) = f
|
||||
|
||||
fun test() {
|
||||
val mapperFunction = { <!UNUSED_ANONYMOUS_PARAMETER!>i<!>: Int -> }
|
||||
val mapperFunction = { i: Int -> }
|
||||
SomeTemplate().query(mapperFunction)
|
||||
|
||||
// TYPE_MISMATCH: Required Class<[ERROR: CANT_INFER]>, Found (kotlin.Int) -> Unit
|
||||
SomeTemplate().query { <!UNUSED_ANONYMOUS_PARAMETER!>i<!>: Int -> }
|
||||
SomeTemplate().query1 { <!UNUSED_ANONYMOUS_PARAMETER!>i<!>: Int -> }
|
||||
SomeTemplate().query { i: Int -> }
|
||||
SomeTemplate().query1 { i: Int -> }
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ interface B
|
||||
object CAB : A, B
|
||||
object DAB : A, B
|
||||
|
||||
fun m(<!UNUSED_PARAMETER!>args<!> : Array<A>) {
|
||||
fun m(args : Array<A>) {
|
||||
|
||||
}
|
||||
|
||||
@@ -17,4 +17,4 @@ fun test122() {
|
||||
}
|
||||
|
||||
//from library
|
||||
fun <T> array(vararg <!UNUSED_PARAMETER!>t<!>: T): Array<T> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
fun <T> array(vararg t: T): Array<T> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
// KT-3496 Type inference bug on y[""]
|
||||
|
||||
class B<T> {
|
||||
fun <S> x (y: B<Iterable<S>>) {
|
||||
val z: S = y[""] // does not work with [], but works with .get()
|
||||
}
|
||||
operator fun <S> get(s : String): S = throw Exception()
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
// KT-3496 Type inference bug on y[""]
|
||||
|
||||
@@ -5,5 +6,5 @@ class B<T> {
|
||||
fun <S> x (y: B<Iterable<S>>) {
|
||||
val z: S = y[""] // does not work with [], but works with .get()
|
||||
}
|
||||
operator fun <S> get(<!UNUSED_PARAMETER!>s<!> : String): S = throw Exception()
|
||||
}
|
||||
operator fun <S> get(s : String): S = throw Exception()
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
|
||||
import java.util.ArrayList
|
||||
|
||||
class F<T> {
|
||||
fun <T, V> x (y: F<ArrayList<T>>, w: ArrayList<V>) {
|
||||
val z: ArrayList<T> = y["", w]
|
||||
}
|
||||
}
|
||||
operator fun <V, T> Any.get(s: String, w: ArrayList<V>): ArrayList<T> = throw Exception()
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
|
||||
@@ -8,4 +9,4 @@ class F<T> {
|
||||
val z: ArrayList<T> = y["", w]
|
||||
}
|
||||
}
|
||||
operator fun <V, T> Any.get(<!UNUSED_PARAMETER!>s<!>: String, <!UNUSED_PARAMETER!>w<!>: ArrayList<V>): ArrayList<T> = throw Exception()
|
||||
operator fun <V, T> Any.get(s: String, w: ArrayList<V>): ArrayList<T> = throw Exception()
|
||||
|
||||
@@ -20,4 +20,4 @@ fun foo(lines: List<String>) {
|
||||
//standard library
|
||||
fun <T : Any> T?.sure() : T = this!!
|
||||
|
||||
public inline fun <T> comparator(<!UNUSED_PARAMETER!>fn<!>: (T,T) -> Int): Comparator<T> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
public inline fun <T> comparator(fn: (T,T) -> Int): Comparator<T> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
interface In<in I>
|
||||
|
||||
interface B : In<B>
|
||||
|
||||
interface C<I, T>
|
||||
|
||||
fun <I, T> In<I>.foo(f: () -> C<I, T>) {}
|
||||
fun <I, T, Self: In<I>> Self.foo2(f: () -> C<I, T>) {}
|
||||
|
||||
class E : B // e <: In<B> <: In<E>
|
||||
|
||||
fun test(c: C<E, Int>, e: E) {
|
||||
e.foo<E, Int> { c }
|
||||
e.foo { c } // error here: expected C<B, ???> but must be C<??? : B, ???>
|
||||
e.foo2 { c }
|
||||
e.foo2 ({ c })
|
||||
}
|
||||
@@ -1,11 +1,12 @@
|
||||
// FIR_IDENTICAL
|
||||
interface In<in I>
|
||||
|
||||
interface B : In<B>
|
||||
|
||||
interface C<I, T>
|
||||
|
||||
fun <I, T> In<I>.foo(<!UNUSED_PARAMETER!>f<!>: () -> C<I, T>) {}
|
||||
fun <I, T, Self: In<I>> Self.foo2(<!UNUSED_PARAMETER!>f<!>: () -> C<I, T>) {}
|
||||
fun <I, T> In<I>.foo(f: () -> C<I, T>) {}
|
||||
fun <I, T, Self: In<I>> Self.foo2(f: () -> C<I, T>) {}
|
||||
|
||||
class E : B // e <: In<B> <: In<E>
|
||||
|
||||
@@ -14,4 +15,4 @@ fun test(c: C<E, Int>, e: E) {
|
||||
e.foo { c } // error here: expected C<B, ???> but must be C<??? : B, ???>
|
||||
e.foo2 { c }
|
||||
e.foo2 ({ c })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ fun <T> emptyList() : List<T>? = ArrayList<T>()
|
||||
|
||||
fun foo() {
|
||||
// type arguments shouldn't be required
|
||||
val <!UNUSED_VARIABLE!>l<!> : List<Int> = emptyList()!!
|
||||
val <!UNUSED_VARIABLE!>l1<!> = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER{NI}, TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER{OI}!>emptyList<!>()!!
|
||||
val l : List<Int> = emptyList()!!
|
||||
val l1 = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER{NI}, TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER{OI}!>emptyList<!>()!!
|
||||
|
||||
checkSubtype<List<Int>>(emptyList()!!)
|
||||
checkSubtype<List<Int>?>(emptyList())
|
||||
|
||||
Vendored
+2
-2
@@ -1,7 +1,7 @@
|
||||
fun <T, U> T.map(f: (T) -> U) = f(this)
|
||||
|
||||
fun consume(<!UNUSED_PARAMETER!>s<!>: String) {}
|
||||
fun consume(s: String) {}
|
||||
|
||||
fun test() {
|
||||
consume(1.map(::<!UNRESOLVED_REFERENCE!>foo<!>))
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+2
-3
@@ -1,9 +1,8 @@
|
||||
package a
|
||||
|
||||
fun <T, R, S> foo(block: (T)-> R, <!UNUSED_PARAMETER!>second<!>: (T)-> S) = block
|
||||
fun <T, R, S> foo(block: (T)-> R, second: (T)-> S) = block
|
||||
|
||||
fun main() {
|
||||
val fff = { <!UNUSED_ANONYMOUS_PARAMETER!>x<!>: Int -> <!UNRESOLVED_REFERENCE!>aaa<!> }
|
||||
val fff = { x: Int -> <!UNRESOLVED_REFERENCE!>aaa<!> }
|
||||
foo(<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>fff<!>, { x -> x + 1 })
|
||||
}
|
||||
|
||||
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
|
||||
package a
|
||||
|
||||
interface Closeable {}
|
||||
class C : Closeable {}
|
||||
|
||||
fun <T: Closeable, R> T.foo(block: (T)-> R) = block
|
||||
|
||||
fun <T: Closeable, R> T.foo(block: (T, T)-> R) = block
|
||||
|
||||
fun main() {
|
||||
C().foo { // no ambiguity here
|
||||
www ->
|
||||
<!UNRESOLVED_REFERENCE!>xs<!>
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !WITH_NEW_INFERENCE
|
||||
|
||||
package a
|
||||
@@ -11,8 +12,7 @@ fun <T: Closeable, R> T.foo(block: (T, T)-> R) = block
|
||||
|
||||
fun main() {
|
||||
C().foo { // no ambiguity here
|
||||
<!UNUSED_ANONYMOUS_PARAMETER!>www<!> ->
|
||||
www ->
|
||||
<!UNRESOLVED_REFERENCE!>xs<!>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -5,13 +5,13 @@ fun <T, R> foo(block: (T)-> R) = block
|
||||
|
||||
fun test1() {
|
||||
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER{NI}, TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER{OI}!>foo<!> {
|
||||
<!CANNOT_INFER_PARAMETER_TYPE, UNUSED_ANONYMOUS_PARAMETER!>x<!> -> // here we have 'cannot infer parameter type' error
|
||||
<!CANNOT_INFER_PARAMETER_TYPE!>x<!> -> // here we have 'cannot infer parameter type' error
|
||||
43
|
||||
}
|
||||
}
|
||||
|
||||
fun bar(<!UNUSED_PARAMETER!>f<!>: (<!UNRESOLVED_REFERENCE!>A<!>)->Unit) {}
|
||||
fun bar(f: (<!UNRESOLVED_REFERENCE!>A<!>)->Unit) {}
|
||||
|
||||
fun test2() {
|
||||
bar { <!UNUSED_ANONYMOUS_PARAMETER!>a<!> -> } // here we don't have 'cannot infer parameter type' error
|
||||
bar { a -> } // here we don't have 'cannot infer parameter type' error
|
||||
}
|
||||
|
||||
+1
-1
@@ -10,6 +10,6 @@ fun main2() = if (true) <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>Foo::<!UNR
|
||||
|
||||
fun main3() = if (true) { Foo::<!UNRESOLVED_REFERENCE!>minus<!> } else { Foo::<!UNRESOLVED_REFERENCE!>times<!> }
|
||||
|
||||
fun main4() = try { Foo::<!UNRESOLVED_REFERENCE!>minus<!> } finally { <!UNUSED_EXPRESSION!>Foo::<!UNRESOLVED_REFERENCE!>times<!><!> }
|
||||
fun main4() = try { Foo::<!UNRESOLVED_REFERENCE!>minus<!> } finally { Foo::<!UNRESOLVED_REFERENCE!>times<!> }
|
||||
|
||||
fun main5() = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>Foo::<!UNRESOLVED_REFERENCE!>minus<!><!> ?: <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>Foo::<!UNRESOLVED_REFERENCE!>times<!><!>
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fun test() {
|
||||
val <!UNUSED_VARIABLE!>a<!> = <!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>-<!>false
|
||||
val a = <!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>-<!>false
|
||||
}
|
||||
|
||||
operator fun A.unaryMinus() {}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user