[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,18 +0,0 @@
// !CHECK_TYPE
// FILE: A.java
public class A {
public java.util.List<? extends CharSequence> foo() {}
}
// FILE: main.kt
fun foo2(x: A, y: MutableList<out CharSequence>) {
x.foo().isEmpty()
x.foo().get(0) checkType { <!UNRESOLVED_REFERENCE!>_<!><CharSequence>() }
x.foo().iterator() checkType { <!UNRESOLVED_REFERENCE!>_<!><MutableIterator<CharSequence>>() }
y.isEmpty()
y.get(0) checkType { <!UNRESOLVED_REFERENCE!>_<!><CharSequence>() }
y.iterator() checkType { <!UNRESOLVED_REFERENCE!>_<!><MutableIterator<CharSequence>>() }
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !CHECK_TYPE
// FILE: A.java
@@ -1,14 +0,0 @@
// !CHECK_TYPE
public abstract class A<E> {
fun bar(): String = ""
}
public class B<F> : A<B<F>>()
fun test(b: B<*>) {
// Here `bar` could have dispatch receiver parameter type 'A<B<Captured(*)>>', but it wouldn't work as
// since 'b' has type 'A<out B<*>>', so we should approximate dispatch receiver PARAMETER type to make it accept original receiver
b.bar()
b.bar() checkType { <!UNRESOLVED_REFERENCE!>_<!><String>() }
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !CHECK_TYPE
public abstract class A<E> {
@@ -11,5 +11,5 @@ fun main() {
val c : ListOfLists<*> = b
val d : ArrayList<ArrayList<*>> = c.x
c.x checkType { <!UNRESOLVED_REFERENCE!>_<!><ArrayList<out ArrayList<*>>>() }
c.x checkType { <!INAPPLICABLE_CANDIDATE!>_<!><ArrayList<out ArrayList<*>>>() }
}
@@ -9,12 +9,12 @@ public class Clazz<T> {
// FILE: main.kt
fun test(clazz: Clazz<*>) {
clazz.t checkType { <!UNRESOLVED_REFERENCE!>_<!><Any?>() }
clazz.getSuperClass() checkType { <!UNRESOLVED_REFERENCE!>_<!><Clazz<*>?>() }
clazz.getSuperClass().t checkType { <!UNRESOLVED_REFERENCE!>_<!><Any?>() }
clazz.t checkType { _<Any?>() }
clazz.getSuperClass() checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Clazz<*>?>() }
clazz.getSuperClass().t checkType { _<Any?>() }
clazz.superClass checkType { <!UNRESOLVED_REFERENCE!>_<!><Clazz<*>?>() }
clazz.superClass.t checkType { <!UNRESOLVED_REFERENCE!>_<!><Any?>() }
clazz.superClass checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Clazz<*>?>() }
clazz.superClass.t checkType { _<Any?>() }
// See KT-9294
if (clazz.superClass == null) {
@@ -11,6 +11,6 @@ fun acceptA(a: A) {
}
fun main(i: I<*>) {
i.foo() checkType { <!UNRESOLVED_REFERENCE!>_<!><A?>() }
i.foo() checkType { _<A?>() }
<!INAPPLICABLE_CANDIDATE!>acceptA<!>(i.foo()) // i.foo() should be nullable but isn't
}
@@ -5,5 +5,5 @@ interface A<T : A<T?>?> {
fun foo(): T?
}
fun testA(a: A<*>) {
a.foo() checkType { <!UNRESOLVED_REFERENCE!>_<!><A<*>?>() }
a.foo() checkType { <!INAPPLICABLE_CANDIDATE!>_<!><A<*>?>() }
}
@@ -6,7 +6,7 @@ interface Clazz<T> {
}
fun test(clazz: Clazz<*>) {
clazz.t checkType { <!UNRESOLVED_REFERENCE!>_<!><Any?>() }
clazz.getSuperClass() checkType { <!UNRESOLVED_REFERENCE!>_<!><Clazz<*>>() }
clazz.getSuperClass().t checkType { <!UNRESOLVED_REFERENCE!>_<!><Any?>() }
clazz.t checkType { _<Any?>() }
clazz.getSuperClass() checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Clazz<*>>() }
clazz.getSuperClass().t checkType { _<Any?>() }
}