ZeroC Ice for Java translates every Slice interface Simple
into (among other things) a proxy interface SimplePrx
and a proxy SimplePrxHelper
. If I have an ObjectPrx
(the base interface for all proxies), I can check whether it actually has interface Simple
by using a static method on SimplePrxHelper
:
val obj : Ice.ObjectPrx = ...; // Get a proxy from somewhere...
val simple : SimplePrx = SimplePrxHelper.checkedCast(obj);
if (simple != null)
// Object supports the Simple interface...
else
// Object is not of type Simple...
I wanted to write a method castTo
so that I could replace the second line with
val simple = castTo[SimplePrx](obj)
or
val simple = castTo[SimplePrxHelper](obj)
So far as I can see, Scala's type system is not expressive enough to allow me to define castTo
. Is this correct?