'as?' works on types with generics

This commit is contained in:
Dmitry Jemerov
2011-05-13 19:07:51 +02:00
parent ffd0119a46
commit c4954ebcc3
3 changed files with 31 additions and 11 deletions
@@ -0,0 +1,8 @@
class Wrapper<T>() {
fun castToSelf(wrapper: Any) = wrapper as? Wrapper<T>
}
fun foo() {
val wrapper = new Wrapper<Int>()
return wrapper.castToSelf(new Wrapper<String>())
}