-
Notifications
You must be signed in to change notification settings - Fork 1
Description
javac has a chaotic pile of mostly poorly thought-out visitors:
DefaultTypeVisitor: a badly-named skeletal abstract partialType.Visitorimplementation that, by default, routes allvisit*methods tovisitType(Type, Object)SimpleVisitor: an abstractDefaultTypeVisitorthat routes visitation of captured types, generic executables and ill-formed types to their non-generic counterpartsUnaryVisitor: aSimpleVisitorthat passesnullas the argument to the variousvisitmethods. Because it just happens to be aSimpleVisitor, this also means that it treats generic and non-generic artifacts the same, so you have to remember thisMapVisitor: a concreteDefaultTypeVisitorthat, by default, maps a type to itselfTypeRelation: aSimpleVisitorTypeMapping: a (concrete, but documented as if it were abstract for some reason)MapVisitorthat runs a mapping function over all types in a listStructuralTypeMapping: aTypeMappingthat "descends into" related types. For example, itsvisitClassType(ClassType, Object)method works not just on class types, error types and intersection types, but also on array types' component types.
This means you have to pay attention to see, for example, whether captured type variables are actually handled by the visitTypeVar(TypeVar, Object) method instead.
They're all used so infrequently even within javac itself that they're borderline useless.
This visitor hierarchy makes for staggering mental load. When you're looking at an operation that uses a visitor, you have to keep all these rules in your head and also have to understand which methods are overridden by superclasses in order to understand the actual processing logic.
This issue will remain open until I'm satisfied that the various bits of logic here are successfully de-visitorized while retaining the properties of each kind of visitor.