Use 'Any?' instead of throwing NPE when calculating star projection type
It's a quite hacky solution, but the choice seems to be conservative, so these types can be refined later #KT-9597 Fixed
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// FILE: main.kt
|
||||
class Inv<T>(val x: T)
|
||||
|
||||
class A<T : Inv<in T>> {
|
||||
fun foo(): T = null!!
|
||||
}
|
||||
|
||||
class Inv2<<!FINITE_BOUNDS_VIOLATION!>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 { _<Any?>() }
|
||||
j.foo() checkType { _<Any?>() }
|
||||
i2.x checkType { _<Any?>() }
|
||||
|
||||
j.<!MEMBER_PROJECTED_OUT!>bar<!>(1, 2, Any())
|
||||
}
|
||||
|
||||
// FILE: JavaClass.java
|
||||
public class JavaClass<T extends JavaClass<? super T>> {
|
||||
public void bar(T... x) {}
|
||||
public T foo() {}
|
||||
}
|
||||
Reference in New Issue
Block a user