[FIR] Fix missing receiver type if anonymous function without label
This commit is contained in:
@@ -1,15 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
// SKIP_TXT
|
||||
fun test(b: S) {
|
||||
b.collect(toList()) checkType { <!UNRESOLVED_REFERENCE!>_<!><Inv<String>>() }
|
||||
}
|
||||
|
||||
interface S {
|
||||
fun <R> collect(collector: C<in String, R>): R
|
||||
}
|
||||
|
||||
class C<X, Y>
|
||||
|
||||
fun <T> toList(): C<T, Inv<T>> = null!!
|
||||
|
||||
class Inv<Q>
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
// SKIP_TXT
|
||||
fun test(b: S) {
|
||||
|
||||
Vendored
+2
-2
@@ -19,8 +19,8 @@ class A : Outer<Double, Short>() {
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
Derived().foo() checkType { <!UNRESOLVED_REFERENCE!>_<!><Outer<String, Int>.Inner<Char>>() }
|
||||
Derived().foo() checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Outer<String, Int>.Inner<Char>>() }
|
||||
Derived().baz() <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><Map<Char, String>>() }
|
||||
A.B().bar() checkType { <!UNRESOLVED_REFERENCE!>_<!><Outer<Float, Long>.Inner<String>>() }
|
||||
A.B().bar() checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Outer<Float, Long>.Inner<String>>() }
|
||||
A.B().x() <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><Map<String, Float>>() }
|
||||
}
|
||||
|
||||
+2
-2
@@ -42,7 +42,7 @@ fun test() {
|
||||
var x = foobar<String>()
|
||||
x = foobar<String>()
|
||||
|
||||
x().foo().a() checkType { <!UNRESOLVED_REFERENCE!>_<!><A<String, Double, Short, Long>>() }
|
||||
x().foo().a() checkType { <!INAPPLICABLE_CANDIDATE!>_<!><A<String, Double, Short, Long>>() }
|
||||
x().bar() <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><A<String, Double, Short, Char>>() }
|
||||
|
||||
x = foobar<Int>()
|
||||
@@ -50,6 +50,6 @@ fun test() {
|
||||
var y = noParameters()
|
||||
y = noParameters()
|
||||
|
||||
y().foo().a() checkType { <!UNRESOLVED_REFERENCE!>_<!><A<Any, Double, Short, Long>>() }
|
||||
y().foo().a() checkType { <!INAPPLICABLE_CANDIDATE!>_<!><A<Any, Double, Short, Long>>() }
|
||||
y().bar() <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><A<Any, Double, Short, Char>>() }
|
||||
}
|
||||
|
||||
+1
-1
@@ -14,6 +14,6 @@ class Derived : BaseDerived2<Int>() {
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
Derived().foo() checkType { <!UNRESOLVED_REFERENCE!>_<!><Outer<Int, String>.Inner<Char>>() }
|
||||
Derived().foo() checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Outer<Int, String>.Inner<Char>>() }
|
||||
Derived().baz() <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><Map<Char, Int>>() }
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -14,5 +14,5 @@ class DerivedOuter : Outer<String>() {
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
DerivedOuter().DerivedInner().foo() checkType { <!UNRESOLVED_REFERENCE!>_<!><Outer<String>.Inner<Int>.Inner2<Char>>() }
|
||||
DerivedOuter().DerivedInner().foo() checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Outer<String>.Inner<Int>.Inner2<Char>>() }
|
||||
}
|
||||
|
||||
@@ -24,23 +24,23 @@ fun <T> B<T>.bar() = ""
|
||||
|
||||
fun foo(l: A<String>?) {
|
||||
// No errors should be here
|
||||
foo(l?.bar()) checkType { <!UNRESOLVED_REFERENCE!>_<!><String?>() }
|
||||
foo(l?.gav()) checkType { <!UNRESOLVED_REFERENCE!>_<!><String?>() }
|
||||
foo(l?.bar()) checkType { _<String?>() }
|
||||
foo(l?.gav()) checkType { _<String?>() }
|
||||
if (l != null) {
|
||||
foo(l?.bar()) checkType { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
foo(l?.gav()) checkType { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
foo(l?.bar()) checkType { <!INAPPLICABLE_CANDIDATE!>_<!><String>() }
|
||||
foo(l?.gav()) checkType { <!INAPPLICABLE_CANDIDATE!>_<!><String>() }
|
||||
}
|
||||
}
|
||||
|
||||
fun fooNotNull(l: A<String>) {
|
||||
// No errors should be here
|
||||
foo(l?.bar()) checkType { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
foo(l?.gav()) checkType { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
foo(l?.bar()) checkType { <!INAPPLICABLE_CANDIDATE!>_<!><String>() }
|
||||
foo(l?.gav()) checkType { <!INAPPLICABLE_CANDIDATE!>_<!><String>() }
|
||||
}
|
||||
|
||||
fun bar() {
|
||||
val l = B.create<String>()
|
||||
foo(l?.bar()) checkType { <!UNRESOLVED_REFERENCE!>_<!><String?>() }
|
||||
foo(l?.gav()) checkType { <!UNRESOLVED_REFERENCE!>_<!><String?>() }
|
||||
foo(l?.bar()) checkType { _<String?>() }
|
||||
foo(l?.gav()) checkType { _<String?>() }
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Vendored
-14
@@ -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>() }
|
||||
}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
|
||||
public abstract class A<E> {
|
||||
|
||||
+1
-1
@@ -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<*>>>() }
|
||||
}
|
||||
|
||||
+5
-5
@@ -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) {
|
||||
|
||||
+1
-1
@@ -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
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -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<*>?>() }
|
||||
}
|
||||
|
||||
+3
-3
@@ -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?>() }
|
||||
}
|
||||
|
||||
+3
-3
@@ -13,9 +13,9 @@ class Inv2<T : Inv2<in T>>(val x: T)
|
||||
fun main(a: A<*>, j: JavaClass<*>, i2: Inv2<*>) {
|
||||
// Probably it's too restrictive to suppose star projection type here as Any?,
|
||||
// but looks like we can refine it later
|
||||
a.foo() checkType { <!UNRESOLVED_REFERENCE!>_<!><Any?>() }
|
||||
j.foo() checkType { <!UNRESOLVED_REFERENCE!>_<!><Any?>() }
|
||||
i2.x checkType { <!UNRESOLVED_REFERENCE!>_<!><Any?>() }
|
||||
a.foo() checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Any?>() }
|
||||
j.foo() checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Any?>() }
|
||||
i2.x checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Any?>() }
|
||||
|
||||
j.<!INAPPLICABLE_CANDIDATE!>bar<!>(1, 2, Any())
|
||||
j.bar(null)
|
||||
|
||||
Vendored
+1
-1
@@ -6,5 +6,5 @@ interface Tr<T> {
|
||||
|
||||
fun test(t: Tr<*>) {
|
||||
t.v = t
|
||||
t.v checkType { <!UNRESOLVED_REFERENCE!>_<!><Tr<*>>() }
|
||||
t.v checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Tr<*>>() }
|
||||
}
|
||||
+1
-1
@@ -10,5 +10,5 @@ fun test(t: Tr<*>) {
|
||||
t.v = null!!
|
||||
t.v = ""
|
||||
t.v = null
|
||||
t.v checkType { <!UNRESOLVED_REFERENCE!>_<!><Any?>() }
|
||||
t.v checkType { _<Any?>() }
|
||||
}
|
||||
Reference in New Issue
Block a user