"as" in binary / unary expressions now checked only for original type conversion #KT-10384 Fixed

Also #KT-10386 Fixed
This commit is contained in:
Mikhail Glukhikh
2015-12-14 17:12:10 +03:00
parent 233e8e58e8
commit 49e7417741
7 changed files with 119 additions and 0 deletions
@@ -0,0 +1,20 @@
// See also KT-10386
interface A
class B : A
fun foo1(list: List<A>, arg: B?): Boolean {
// contains(T): Boolean is deprecated
return arg <!DEPRECATION!>in<!> list
}
fun foo2(list: List<A>, arg: B?): Boolean {
// FAKE: no cast needed
return arg as A? in list
}
fun foo3(list: List<A>, arg: B?): Boolean {
// No warning but KNPE risk
return arg!! in list
}
// But
fun foo4(list: List<A>, arg: B): Boolean {
// Ok
return arg in list
}