[FIR] Fix missing receiver type if anonymous function without label

This commit is contained in:
simon.ogorodnik
2020-04-07 23:43:42 +03:00
parent d2fd377605
commit f573719cc1
143 changed files with 249 additions and 766 deletions
@@ -1,25 +0,0 @@
// !CHECK_TYPE
fun foo(x: Cloneable) = x
fun test() {
foo(arrayOf(""))
foo(intArrayOf())
foo(longArrayOf())
foo(shortArrayOf())
foo(byteArrayOf())
foo(charArrayOf())
foo(doubleArrayOf())
foo(floatArrayOf())
foo(booleanArrayOf())
arrayOf("").clone() checkType { <!UNRESOLVED_REFERENCE!>_<!><Array<String>>() }
intArrayOf().clone() checkType { <!UNRESOLVED_REFERENCE!>_<!><IntArray>() }
longArrayOf().clone() checkType { <!UNRESOLVED_REFERENCE!>_<!><LongArray>() }
shortArrayOf().clone() checkType { <!UNRESOLVED_REFERENCE!>_<!><ShortArray>() }
byteArrayOf().clone() checkType { <!UNRESOLVED_REFERENCE!>_<!><ByteArray>() }
charArrayOf().clone() checkType { <!UNRESOLVED_REFERENCE!>_<!><CharArray>() }
doubleArrayOf().clone() checkType { <!UNRESOLVED_REFERENCE!>_<!><DoubleArray>() }
floatArrayOf().clone() checkType { <!UNRESOLVED_REFERENCE!>_<!><FloatArray>() }
booleanArrayOf().clone() checkType { <!UNRESOLVED_REFERENCE!>_<!><BooleanArray>() }
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !CHECK_TYPE
fun foo(x: Cloneable) = x
@@ -10,6 +10,6 @@ fun passLambdaValue(l: ContractBuilder.() -> Unit) {
fun passAnonymousFunction(x: Boolean) {
contract(fun ContractBuilder.() {
<!UNRESOLVED_REFERENCE!>returns<!>() <!UNRESOLVED_REFERENCE!>implies<!> x
returns() implies x
})
}
@@ -1,9 +0,0 @@
// !CHECK_TYPE
import java.io.File
fun test() {
val dir = File("dir")
val files = dir.listFiles()?.toList() ?: listOf() // error
files checkType { <!UNRESOLVED_REFERENCE!>_<!><List<File>>() }
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !CHECK_TYPE
import java.io.File
@@ -1,10 +0,0 @@
// !CHECK_TYPE
fun <T> bar(f: () -> T) : T = f()
fun test(map: MutableMap<Int, Int>) {
val r = bar {
map[1] = 2
}
r checkType { <!UNRESOLVED_REFERENCE!>_<!><Unit>() }
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !CHECK_TYPE
fun <T> bar(f: () -> T) : T = f()
@@ -36,9 +36,9 @@ fun A.forEach() = ""
fun A.forEach(s: String) {}
fun test(a: A) {
a.forEach() checkType { <!UNRESOLVED_REFERENCE!>_<!><String>() }
a.forEach() checkType { _<String>() }
a.forEach(1) checkType { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
a.forEach(1) checkType { _<Int>() }
a.forEach("")
@@ -17,7 +17,7 @@ class B {
fun A.forEach() = this@B
fun test(a: A) {
a.forEach() checkType { <!INAPPLICABLE_CANDIDATE!>_<!><A>() } // todo
a.forEach() checkType { _<A>() } // todo
with(a) {
forEach() checkType { _<A>() } // todo
@@ -34,7 +34,7 @@ fun test2(a: A) {
@kotlin.internal.HidesMembers
fun A.forEach(i: Int) = ""
a.forEach() checkType { <!UNRESOLVED_REFERENCE!>_<!><String>() }
a.forEach() checkType { <!INAPPLICABLE_CANDIDATE!>_<!><String>() }
a.forEach(1)
with(a) {
@@ -25,6 +25,6 @@ public class StaticOverrides {
fun test() {
StaticOverrides.A.<!AMBIGUITY!>foo<!> {} <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><Boolean>() }
StaticOverrides.B.foo {} checkType { <!UNRESOLVED_REFERENCE!>_<!><String>() }
StaticOverrides.C.foo {} checkType { <!UNRESOLVED_REFERENCE!>_<!><Boolean>() }
StaticOverrides.B.foo {} checkType { _<String>() }
StaticOverrides.C.foo {} checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Boolean>() }
}
@@ -44,7 +44,7 @@ fun foo(x: List<String>, y: Throwable, z: A3) {
x.stream()
java.util.ArrayList<String>().stream()
y.fillInStackTrace() checkType { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
y.fillInStackTrace() checkType { _<Int>() }
HashMap<String, Int>().getOrDefault(Any(), null)
@@ -1,7 +0,0 @@
// !CHECK_TYPE
fun test(a: Array<out String>) {
val b = a.toList()
b checkType { <!UNRESOLVED_REFERENCE!>_<!><List<String>>() }
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !CHECK_TYPE
fun test(a: Array<out String>) {