I have a base class with explicit generic arguments in F #. I am trying to check if a given type is using, I am using a specific interface. I thought that “if ob :? ISysAware then” would do, but the complaint is always the same:
let (|SysAware|_|) t =
match t with
| :? ISysAware as p -> Some(p)
| _ -> None
error FS0008: This is a compulsion or runtime type test from type 'a to ISysAware includes an undefined type based on the information up to this point in the program. Runtime type testing is not allowed for some types. Additional type annotations are required.
I would rather not use reflection here, obviously. IsAssignableFrom will do the trick, at a high price.
Thoughts?
source
share