NI: take into account flexible types during capturing arguments from expression

^KT-40544 Fixed
This commit is contained in:
Victor Petukhov
2020-08-03 19:27:15 +03:00
parent 65ebd02a39
commit af48f08f9c
8 changed files with 97 additions and 11 deletions
@@ -10,10 +10,10 @@ public class Clazz<T> {
// FILE: main.kt
fun test(clazz: Clazz<*>) {
clazz.t checkType { _<Any?>() }
clazz.getSuperClass() checkType { <!NI;UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><Clazz<*>?>() }
clazz.getSuperClass() checkType { _<Clazz<*>?>() }
clazz.getSuperClass().t checkType { _<Any?>() }
clazz.superClass checkType { <!NI;UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><Clazz<*>?>() }
clazz.superClass checkType { _<Clazz<*>?>() }
clazz.superClass.t checkType { _<Any?>() }
// See KT-9294
@@ -0,0 +1,18 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNCHECKED_CAST
// FILE: Test.java
class Test {
static Foo<? extends Number> getFoo() {
return null;
}
}
// FILE: main.kt
class Foo<T>
fun <T> id(x: T) = null as T
fun test() {
Test.getFoo()
<!DEBUG_INFO_EXPRESSION_TYPE("Foo<out kotlin.Number..kotlin.Number?!>")!>id(Test.getFoo())<!>
}
@@ -0,0 +1,18 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNCHECKED_CAST
// FILE: Test.java
class Test {
static Foo<? extends Number> getFoo() {
return null;
}
}
// FILE: main.kt
class Foo<T>
fun <T> id(x: T) = null as T
fun test() {
<!DEBUG_INFO_EXPRESSION_TYPE("(Foo<out (kotlin.Number..kotlin.Number?)>..Foo<out (kotlin.Number..kotlin.Number?)>?)")!>Test.getFoo()<!>
<!DEBUG_INFO_EXPRESSION_TYPE("(Foo<out (kotlin.Number..kotlin.Number?)>..Foo<out (kotlin.Number..kotlin.Number?)>?)")!>id(Test.getFoo())<!>
}
@@ -0,0 +1,21 @@
package
public fun </*0*/ T> id(/*0*/ x: T): T
public fun test(): kotlin.Unit
public final class Foo</*0*/ T> {
public constructor Foo</*0*/ T>()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public/*package*/ open class Test {
public/*package*/ constructor Test()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
// Static members
public/*package*/ open fun getFoo(): Foo<out kotlin.Number!>!
}