[FIR] Implement FUNCTION_EXPECTED
This commit is contained in:
@@ -50,25 +50,25 @@ fun main(args : Array<String>) {
|
||||
checkSubtype<Int>(b)
|
||||
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>fooT2<!>()(1) // : Any?
|
||||
|
||||
<!UNRESOLVED_REFERENCE!>1<!>()
|
||||
<!UNRESOLVED_REFERENCE!>1<!>{}
|
||||
<!UNRESOLVED_REFERENCE!>1<!>(){}
|
||||
<!FUNCTION_EXPECTED!>1<!>()
|
||||
<!FUNCTION_EXPECTED!>1<!>{}
|
||||
<!FUNCTION_EXPECTED!>1<!>(){}
|
||||
}
|
||||
|
||||
fun f() : Int.() -> Unit = {}
|
||||
|
||||
fun main1() {
|
||||
1.(<!UNRESOLVED_REFERENCE!>fun Int.() = 1<!>)();
|
||||
1.(<!FUNCTION_EXPECTED!>fun Int.() = 1<!>)();
|
||||
{1}();
|
||||
(fun (x : Int) = x)(1)
|
||||
1.(<!UNRESOLVED_REFERENCE!>fun Int.(x : Int) = x<!>)(1);
|
||||
1.(<!FUNCTION_EXPECTED!>fun Int.(x : Int) = x<!>)(1);
|
||||
l@{1}()
|
||||
1.((<!UNRESOLVED_REFERENCE!>fun Int.() = 1<!>))()
|
||||
1.(<!UNRESOLVED_REFERENCE!>f()<!>)()
|
||||
1.<!UNRESOLVED_REFERENCE!>if(true){f()}else{f()}<!>()
|
||||
1.<!UNRESOLVED_REFERENCE!>if(true)(fun Int.() {})else{f()}<!>()
|
||||
1.((<!FUNCTION_EXPECTED!>fun Int.() = 1<!>))()
|
||||
1.(<!FUNCTION_EXPECTED!>f()<!>)()
|
||||
1.<!FUNCTION_EXPECTED!>if(true){f()}else{f()}<!>()
|
||||
1.<!FUNCTION_EXPECTED!>if(true)(fun Int.() {})else{f()}<!>()
|
||||
|
||||
1.<!UNRESOLVED_REFERENCE!>"sdf"<!>()
|
||||
1.<!FUNCTION_EXPECTED!>"sdf"<!>()
|
||||
|
||||
1.<!ILLEGAL_SELECTOR!>"sdf"<!>
|
||||
1.<!ILLEGAL_SELECTOR!>{}<!>
|
||||
@@ -78,7 +78,7 @@ fun main1() {
|
||||
fun test() {
|
||||
{x : Int -> 1}(<!NO_VALUE_FOR_PARAMETER!>)<!>;
|
||||
(fun Int.() = 1)(<!NO_VALUE_FOR_PARAMETER!>)<!>
|
||||
"sd".(<!UNRESOLVED_REFERENCE!>fun Int.() = 1<!>)()
|
||||
"sd".(<!FUNCTION_EXPECTED!>fun Int.() = 1<!>)()
|
||||
val i : Int? = null
|
||||
i.(<!UNRESOLVED_REFERENCE!>fun Int.() = 1<!>)();
|
||||
<!INAPPLICABLE_CANDIDATE!>{}<!><Int>()
|
||||
|
||||
@@ -14,7 +14,7 @@ fun test(t: T) {
|
||||
}
|
||||
|
||||
fun test1(t: T?) {
|
||||
t.<!UNRESOLVED_REFERENCE!>f<!>(1) // todo resolve f as value and report UNSAFE_CALL
|
||||
t.<!FUNCTION_EXPECTED!>f<!>(1) // todo resolve f as value and report UNSAFE_CALL
|
||||
t?.<!UNSAFE_IMPLICIT_INVOKE_CALL!>f<!>(1)
|
||||
t<!UNSAFE_CALL!>.<!>f?.invoke(1)
|
||||
t?.f?.invoke(1)
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ fun test4() {
|
||||
// should be an error on receiver, shouldn't be thrown away
|
||||
|
||||
fun test5() {
|
||||
1.(<!UNRESOLVED_REFERENCE!>fun String.()=1<!>)()
|
||||
1.(<!FUNCTION_EXPECTED!>fun String.()=1<!>)()
|
||||
}
|
||||
|
||||
fun <R: Any> R?.sure() : R = this!!
|
||||
|
||||
@@ -12,7 +12,7 @@ fun x(f : Foo) {
|
||||
f.<!FUNCTION_CALL_EXPECTED!>prop<!>
|
||||
f.<!FUNCTION_CALL_EXPECTED!>bar<!>
|
||||
|
||||
f.<!UNRESOLVED_REFERENCE!>a<!>()
|
||||
f.<!FUNCTION_EXPECTED!>a<!>()
|
||||
<!UNRESOLVED_REFERENCE!>c<!>()
|
||||
<!INVISIBLE_REFERENCE!>R<!>()
|
||||
}
|
||||
|
||||
+1
-1
@@ -33,4 +33,4 @@ fun bar() {
|
||||
Inner()
|
||||
Inner(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
|
||||
fun f(c: LongRange): Int {
|
||||
return c.<!UNRESOLVED_REFERENCE!>start<!>()
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
|
||||
fun f(c: LongRange): Int {
|
||||
return c.<!FUNCTION_EXPECTED!>start<!>()
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION
|
||||
fun foo(i: Int) {
|
||||
<!UNRESOLVED_REFERENCE!>i<!>()
|
||||
<!UNRESOLVED_REFERENCE!>1<!>()
|
||||
}
|
||||
<!FUNCTION_EXPECTED!>1<!>()
|
||||
}
|
||||
|
||||
Vendored
+3
-3
@@ -1,7 +1,7 @@
|
||||
|
||||
fun test1() {
|
||||
1. (<!UNRESOLVED_REFERENCE!>fun String.(i: Int) = i<!> )(1)
|
||||
1.(<!UNRESOLVED_REFERENCE!>label@ fun String.(i: Int) = i<!> )(1)
|
||||
1. (<!FUNCTION_EXPECTED!>fun String.(i: Int) = i<!> )(1)
|
||||
1.(<!FUNCTION_EXPECTED!>label@ fun String.(i: Int) = i<!> )(1)
|
||||
}
|
||||
|
||||
fun test2(f: String.(Int) -> Unit) {
|
||||
@@ -12,5 +12,5 @@ fun test2(f: String.(Int) -> Unit) {
|
||||
fun test3() {
|
||||
fun foo(): String.(Int) -> Unit = {}
|
||||
|
||||
1.(<!UNRESOLVED_REFERENCE!>foo()<!>)(1)
|
||||
1.(<!FUNCTION_EXPECTED!>foo()<!>)(1)
|
||||
}
|
||||
|
||||
+2
-2
@@ -2,11 +2,11 @@ class A(val x: (String.() -> Unit)?)
|
||||
|
||||
fun test(a: A) {
|
||||
if (a.x != null) {
|
||||
"".(<!UNRESOLVED_REFERENCE!>a.x<!>)()
|
||||
"".(<!FUNCTION_EXPECTED!>a.x<!>)()
|
||||
a.x("") // todo
|
||||
(a.x)("")
|
||||
}
|
||||
"".(<!UNRESOLVED_REFERENCE!>a.x<!>)()
|
||||
"".(<!FUNCTION_EXPECTED!>a.x<!>)()
|
||||
a.<!UNSAFE_IMPLICIT_INVOKE_CALL!>x<!>("")
|
||||
<!UNSAFE_IMPLICIT_INVOKE_CALL!>(a.x)<!>("")
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ val Cls.extensionProperty: MemberInvokeOwner
|
||||
|
||||
fun testNullableReceiver(nullable: Cls?) {
|
||||
nullable?.extensionProperty()
|
||||
nullable.<!UNRESOLVED_REFERENCE!>extensionProperty<!>()
|
||||
nullable.<!FUNCTION_EXPECTED!>extensionProperty<!>()
|
||||
}
|
||||
|
||||
fun testNotNullableReceiver(notNullable: Cls) {
|
||||
|
||||
Vendored
+1
-1
@@ -5,7 +5,7 @@ class D : C {
|
||||
{
|
||||
val s = ""
|
||||
<!UNRESOLVED_REFERENCE!>s<!>()
|
||||
<!UNRESOLVED_REFERENCE!>""<!>()
|
||||
<!FUNCTION_EXPECTED!>""<!>()
|
||||
42
|
||||
}())
|
||||
|
||||
|
||||
Vendored
+2
-2
@@ -12,5 +12,5 @@ public fun foo(xx: Any): Int {
|
||||
y.length
|
||||
} while (true)
|
||||
// We could have smart cast here but with break it's hard to detect
|
||||
return x.<!UNRESOLVED_REFERENCE!>length<!>()
|
||||
}
|
||||
return x.<!FUNCTION_EXPECTED!>length<!>()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
fun x(): Boolean { return true }
|
||||
|
||||
public fun foo(pp: Any): Int {
|
||||
var p = pp
|
||||
while(true) {
|
||||
(p as String).length
|
||||
if (x()) break
|
||||
p = 42
|
||||
}
|
||||
// Smart cast is NOT possible here
|
||||
// (we could provide it but p = 42 makes it difficult to understand)
|
||||
return p.<!FUNCTION_EXPECTED!>length<!>()
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
// FIR_IDENTICAL
|
||||
fun x(): Boolean { return true }
|
||||
|
||||
public fun foo(pp: Any): Int {
|
||||
@@ -11,4 +10,4 @@ public fun foo(pp: Any): Int {
|
||||
// Smart cast is NOT possible here
|
||||
// (we could provide it but p = 42 makes it difficult to understand)
|
||||
return p.<!UNRESOLVED_REFERENCE!>length<!>()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user