Casting generic primitives vs objects

Monkey Forums/Monkey Programming/Casting generic primitives vs objects

Samah(Posted 2013) [#1]
Mark, you might be able to help me with this one.
I want to be able to check if a generic implements an interface, but this means that it won't compile if the parameter is a primitive (which I want to allow).

Class Foo<T>
  Method Test:Void(val:T)
    ' if primitive, do A
    If (val is primitive) Then
      ' do A
    ElseIf (val is object that implements an interface) Then
      ' do B
    End
  End
End

There's no way of checking if T is a primitive, and obviously I can't cast to an interface if it is.

Short of writing horrible native code, can you think of an easy solution?

Thanks,
Samah