Simon Craigie
11/29/2019, 4:55 PMfun <PARENT, CHILD: PARENT> returnFuncWithParentTypeAsParameter(resolver: (CHILD) -> Unit): (PARENT) -> Unit {
return resolver as (PARENT) -> Unit
}
Thanks in advance!Adam Powell
11/29/2019, 5:07 PMCHILD when you call the resulting function.Simon Craigie
11/29/2019, 5:22 PMPARENT object. If all CHILD 's are of type PARENT 's then is it still unsafe?Robert Jaros
11/29/2019, 5:23 PMinline fun <PARENT, reified CHILD: PARENT> returnFuncWithParentTypeAsParameter(crossinline resolver: (CHILD) -> Unit): (PARENT) -> Unit {
return {
if (it is CHILD) {
resolver(it)
}
}
}Robert Jaros
11/29/2019, 5:23 PMRobert Jaros
11/29/2019, 5:25 PMAdam Powell
11/29/2019, 5:26 PMPARENT, all `PARENT`s are not of type CHILD. If you pass any PARENT to a resolver that is expecting parameters of type CHILD, you are trying to make the latter assertion, which cannot hold.Simon Craigie
11/29/2019, 5:36 PM