Prohibit check for instance of a non-reified, non-subtype type parameter
#KT-12683 Fixed #KT-9986 Fixed
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
fun <T, S : T> test(x: T?, y: S, z: T) {
|
||||
x is <!CANNOT_CHECK_FOR_ERASED!>T<!>
|
||||
x is T?
|
||||
|
||||
y is T
|
||||
y is S
|
||||
y is T<!USELESS_NULLABLE_CHECK!>?<!>
|
||||
y is S<!USELESS_NULLABLE_CHECK!>?<!>
|
||||
|
||||
z is T
|
||||
z is T<!USELESS_NULLABLE_CHECK!>?<!>
|
||||
|
||||
<!UNCHECKED_CAST!>null as T<!>
|
||||
null <!USELESS_CAST!>as T?<!>
|
||||
<!UNCHECKED_CAST!>null as S<!>
|
||||
}
|
||||
|
||||
inline fun <reified T> test(x: T?) {
|
||||
x is T
|
||||
null as T
|
||||
null <!USELESS_CAST!>as T?<!>
|
||||
}
|
||||
|
||||
fun <T> foo(x: List<T>, y: List<T>?) {
|
||||
x is List<T>
|
||||
y is List<T>
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ T> foo(/*0*/ x: kotlin.collections.List<T>, /*1*/ y: kotlin.collections.List<T>?): kotlin.Unit
|
||||
public inline fun </*0*/ reified T> test(/*0*/ x: T?): kotlin.Unit
|
||||
public fun </*0*/ T, /*1*/ S : T> test(/*0*/ x: T?, /*1*/ y: S, /*2*/ z: T): kotlin.Unit
|
||||
Vendored
+1
-1
@@ -25,7 +25,7 @@ class MyProperty<R, T> {
|
||||
|
||||
operator fun getValue(thisRef: R, desc: KProperty<*>): T {
|
||||
println("get $thisRef ${desc.name}")
|
||||
return null as T
|
||||
return <!UNCHECKED_CAST!>null as T<!>
|
||||
}
|
||||
|
||||
operator fun setValue(thisRef: R, desc: KProperty<*>, value: T) {
|
||||
|
||||
@@ -5,7 +5,7 @@ import java.util.HashMap
|
||||
|
||||
public inline fun <K,V1, V: V1> Map<K,V>.getOrElse1(key: K, defaultValue: ()-> V1) : V1 {
|
||||
if (this.containsKey(key)) {
|
||||
return this.get(key) as V
|
||||
return <!UNCHECKED_CAST!>this.get(key) as V<!>
|
||||
} else {
|
||||
return defaultValue()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user