@inbounds equivalent for type assertions

Is there an @inbounds equivalent for type assertions? That is allow the compiler to aggressively compile a specialization based on a type assertion that is unsafe if the type is not correct?

This occurred to me as related to your question:

See also: Be aware of when Julia avoids specializing

You can assert a type of a value or expression. The compiler knows that this means the expression is either of that type or raises an error. There’s no way to do this unsafely.

1 Like