dmcg
12/09/2019, 9:10 AMStephan Schroeder
12/09/2019, 10:30 AMdmcg
12/09/2019, 10:51 AMStephan Schroeder
12/09/2019, 10:58 AMfun <T:Any> haveSameClass(first: T, other: Any?): Boolean {
contract {
returns(true) implies (other is T)
}
if (first === other) return true
return other!=null && first.javaClass == other.javaClass
}
will fail with on is T
with: can not check for instance of erased type, while the inline-version
inline fun <reified T:Any> haveSameClass(first: T, other: Any?): Boolean {
contract {
returns(true) implies (other is T)
}
if (first === other) return true
return other!=null && first.javaClass == other.javaClass
}
still fails on is T
but with references to type parameters are forbidden in contractsSergei Dubrov [JB]
12/09/2019, 12:24 PMdmcg
12/09/2019, 12:27 PMSergei Dubrov [JB]
12/09/2019, 12:28 PM