Files
kotlin-fork/compiler/testData/diagnostics/tests/generics/starProjections/invalid.kt
T
Denis Zharkov 8caee7940e 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
2016-06-24 10:23:16 +03:00

27 lines
686 B
Kotlin
Vendored

// !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() {}
}