How to depth-search any parameterized type?

For example, I have a parametrized type !dialect.anytype<...> which can contain 0 or more FunctionTypes. I access this type with mlir::Type object and I don’t know exactly what type this is.
Is there a way to find all occurrences of the FunctionTypes? !dialect.anytype can possibly be parametrized with types of dialects other than the dialect.

Basically, I’d be happy enough if I just could get type parameters list from mlir::Type object, but I didn’t find a way to get it. Probably, I wasn’t looking hard enough.

Is there a way to find all occurrences of the FunctionType s?

Can you iterate and filter on when dyn_cast<FunctionType>(type) is successful?

I do not quite understand the question.

If the type is not a FunctionType but some parametrized type with FunctionType inside (possibly several levels deep), dyn_cast is going to find it?

No you need to implement the traversal yourself, this is what I mean by “can you iterate”.

I still do not understand the question :pensive:
So, let me clarify what I want to do.

I need to implement the traversal to find FunctionType occurrence(s).
I need the FunctionType to check its return type for some properties - already implemented.
To find the FunctionType inside a type, I need to get its parameters, but mlir::Type object doesn’t have member functions to get them.

You can cast your “opaque” mlir::Type into your !dialect.anytype<...> with dyn_cast and then use your accessors to iterate on the FunctionTypes.

I’m sorry, I’m probably wasn’t clear enough.
The problem is that I do not know the exact type. It can be any parametrized type from any dialect.

These are contradicting each other.

In any case, there is no generalized storage for “type type parameters”, or for type parameters in general, that one would be able to inspect generically. You can either dyn_cast / TypeSwitch to a subset of types you need to handle, or introduce a type interface and have the relevant types implement it.