Each 'when' case needs to be a constant value. The dynamic type of an object is not a constant value, so inspect is not the right mechanism to use.
Each object makes available its 'generating_type', and that is of type TYPE. Within the TYPE class is an integer 'type_id'. While that could be used in an inspect clause, I recommend against that.
It is often useful, once an object is found to be attached as a dynamic type, to use that knowledge AND that attachment to do something.
If all you need to do is to find the dynamic attached type, then a set of if-then-elses is what you need to do. If you expect to perform that check often, then put that logic in a function.
If the set of possible attachments in your application is small and stable, then defining your own app-specific constants could streamline your code, and you could use those values in the inspect clauses you might need for that.
There are mechanisms available. Choosing the right one sometimes is not that obvious. While each of us might have used a screwdriver at some point when we really needed a chisel, that doesn't make the screwdriver the right tool for the job.
R