I’d say the only types the argument could be are Expr and LineNumberNode, so there’s not a whole lot to optimize by avoiding type specialization.
(Maybe ex could also be some ‘atom’/literal type I guess)
the type of ex isn’t known when @typed ex is called
it’s not very important to specialize rewrite_assignment on ex
And so for this kind of case @nospecialize can avoid runtime dispatch on rewrite_assignment and will slightly improve the macro expansion of @typed (although it may not be very important given that the computation happens at lowering time).
Well, rewrite_assignment is defined in a way that it can take arbitrary AST elements other than Expr and LineNumberNode e.g. Int, Symbol. I agree with that it may not be very important to optimize the computation that only happens at lowering time, but it’s certainly better to have @nospecialze there.