Type: add helpers for managing typeof and attributed types
The idea behind this is to prepare for #733 by making typeof and attributed types slightly less annoying to deal with, by moving the recursive call logic to a single place (2 actually), which should make it easier to add a new typedef specifier which will generally just call into its subtype for most of the Type functions.
Wouldn't something more like canonicalize be better? This strategy already requires a duplicate function with a one arg difference.
Maybe a Type.base() which would use a while loop instead of recursion. Most places that use canonicalize seem like they actually want that kind of functionality.
Is the idea that each function that currently recurses on typeof/attributed types, should instead call canonicalize/base on its argument first? I think that would also work and yeah probably simpler.
Something like that yes. It would also work well if in the future Type is reworked to be interned or something similar.
This branch has a fairly heavy performance hit (~5% for large files), and even with just Type.base replacing canonicalize where we only want the specifier, it's still about 1.5% slower. So now I'm kinda leaning toward, we just implement typedef specifiers in the code as-is, and then hopefully clean everything up with Type interning in the future.