Package: org.codehaus.groovy.transform.stc

## [Java] Class StaticTypeCheckingVisitor

- org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor

-     public class StaticTypeCheckingVisitor
      extends ClassCodeVisitorSupport

  The main class code visitor responsible for static type checking. It will perform various inspections like checking assignment types, type inference, ... Eventually, class nodes may be annotated with inferred type information.

- - ### Nested Class Summary

    Nested classes
    Modifiers | Name | Description
    --- | --- | ---
    `static class` | `StaticTypeCheckingVisitor.SignatureCodecFactory` | Creates signature codecs for serialized type checking metadata.
    `protected class` | `StaticTypeCheckingVisitor.VariableExpressionTypeMemoizer` | Memoizes inferred variable types so they can be restored after temporary rewrites.

  - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `protected static ClassNode` | `CHAR_SEQUENCE_TYPE` | Cached CharSequence type (GROOVY-9848: membership operator dispatch).
    `protected static ClassNode` | `CLOSUREPARAMS_CLASSNODE` | Cached ClosureParams annotation type.
    `static MethodNode` | `CLOSURE_CALL_NO_ARG` | Cached zero-argument `Closure#call()` method.
    `static MethodNode` | `CLOSURE_CALL_ONE_ARG` | Cached single-argument `Closure#call(Object)` method.
    `static MethodNode` | `CLOSURE_CALL_VARGS` | Cached varargs `Closure#call(Object[])` method.
    `protected static Expression` | `CURRENT_SIGNATURE_PROTOCOL` | Constant expression for the current signature protocol version.
    `protected static int` | `CURRENT_SIGNATURE_PROTOCOL_VERSION` | Current encoding protocol for stored type-checking signatures.
    `protected static ClassNode` | `DELEGATES_TO` | Cached DelegatesTo annotation type.
    `protected static ClassNode` | `DELEGATES_TO_TARGET` | Cached DelegatesTo.Target annotation type.
    `protected static ClassNode` | `DGM_CLASSNODE` | Cached DefaultGroovyMethods type.
    `protected static List<MethodNode>` | `EMPTY_METHODNODE_LIST` | Shared empty method list.
    `protected static ClassNode` | `ENUMERATION_TYPE` | Cached Enumeration type.
    `protected static Object` | `ERROR_COLLECTOR` | Metadata key used to store per-method error collectors.
    `static Statement` | `GENERATED_EMPTY_STATEMENT` | Empty statement reused for synthetic AST nodes.
    `protected static MethodNode` | `GET_DELEGATE` | Cached `Closure#getDelegate()` method.
    `protected static MethodNode` | `GET_OWNER` | Cached `Closure#getOwner()` method.
    `protected static MethodNode` | `GET_THISOBJECT` | Cached `Closure#getThisObject()` method.
    `protected static ClassNode` | `ITERABLE_TYPE` | Cached Iterable type.
    `protected static ClassNode` | `LINKEDHASHMAP_CLASSNODE` |
    `protected static ClassNode` | `MAP_ENTRY_TYPE` | Cached Entry type.
    `protected static ClassNode` | `NAMED_PARAMS_CLASSNODE` | Cached NamedParams annotation type.
    `protected static ClassNode` | `NAMED_PARAM_CLASSNODE` | Cached NamedParam annotation type.
    `protected static ClassNode` | `TYPECHECKED_CLASSNODE` | Cached TypeChecked annotation type.
    `protected static ClassNode[]` | `TYPECHECKING_ANNOTATIONS` | Type-checking annotations recognized by this visitor.
    `protected static ClassNode` | `TYPECHECKING_INFO_NODE` | Cached TypeChecked.TypeCheckingInfo annotation type.
    `protected FieldNode` | `currentField` | Field currently being visited.
    `protected PropertyNode` | `currentProperty` | Property currently being visited.
    `protected DefaultTypeCheckingExtension` | `extension` | Composite extension chain consulted during type checking.
    `protected ReturnAdder` | `returnAdder` | Return adder used to normalize implicit and explicit returns.
    `protected ReturnStatementListener` | `returnListener` |
    `protected TypeCheckingContext` | `typeCheckingContext` | Mutable state for the current type-checking run.

  - ### Constructor Summary

    Constructors
    Constructor and description
    `StaticTypeCheckingVisitor(SourceUnit source, ClassNode classNode)` Creates a static type-checking visitor for the supplied source and class.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `protected void` | `addAmbiguousErrorMessage(List<MethodNode> foundMethods, String name, ClassNode[] args, Expression expr)` Reports that method resolution remained ambiguous after filtering.
    `` | `protected void` | `addAssignmentError(ClassNode leftType, ClassNode rightType, Expression expression)` Reports an incompatible assignment between the supplied types.
    `` | `protected void` | `addCategoryMethodCallError(Expression call)` Reports that categories cannot be used under static type checking.
    `` | `protected void` | `addClosureReturnType(ClassNode returnType)` Records a non-void return type for the current enclosing closure.
    `` | `public void` | `addError(String msg, ASTNode node)` * Adds an error message associated with an AST node to the source unit. * Errors are accumulated and reported after visitation completes. * * Parameters: `error` - the error message to report * `node` - the AST node associated with the error location * See Also: ErrorCollecting
    `` | `protected void` | `addNoMatchingMethodError(ClassNode receiver, String name, ClassNode[] args, Expression exp)` Reports that no matching method or constructor could be found for the call.
    `` | `protected void` | `addNoMatchingMethodError(ClassNode receiver, String name, ClassNode[] args, ASTNode origin)` Reports that no matching method or constructor could be found for the call.
    `` | `protected void` | `addReceivers(List<Receiver<String>> receivers, Collection<Receiver<String>> owners, boolean implicitThis)` Adds candidate receivers derived from owner chains.
    `` | `protected void` | `addStaticTypeError(String msg, ASTNode node)` Reports a static type checking error for the supplied node.
    `` | `public void` | `addTypeCheckingExtension(TypeCheckingExtension extension)` Adds a type-checking extension to the active extension chain.
    `` | `protected void` | `addTypeCheckingInfoAnnotation(MethodNode node)` Adds TypeChecked.TypeCheckingInfo metadata for an inferred method return type.
    `` | `protected void` | `addUnsupportedPreOrPostfixExpressionError(Expression expression)` Reports an unsupported prefix or postfix operation.
    `` | `protected void` | `afterSwitchCaseStatementsVisited(SwitchExpression expression)` * Hook method called after all case arms are visited, but before the default * arm (GROOVY-12255). * * Parameters: `expression` - the switch expression being visited * Since: 6.0.0
    `` | `protected void` | `afterSwitchCaseStatementsVisited(SwitchStatement statement)` * Hook method called after all case statements are visited, but before the default statement. * Subclasses may override to perform processing between cases and default. * * Parameters: `statement` - the switch statement being visited * Since: 5.0.0
    `` | `protected void` | `afterSwitchConditionExpressionVisited(SwitchExpression expression)` * Hook method called after the switch-expression selector is visited, but * before case arms (GROOVY-12255). * * Parameters: `expression` - the switch expression being visited * Since: 6.0.0
    `` | `protected void` | `afterSwitchConditionExpressionVisited(SwitchStatement statement)` * Hook method called after the switch condition expression is visited, but before case statements. * Subclasses may override to perform processing between condition and cases. * * Parameters: `statement` - the switch statement being visited * Since: 3.0.0
    `` | `protected boolean` | `areCategoryMethodCalls(List<MethodNode> foundMethods, String name, ClassNode[] args)` Indicates whether all candidates are category-style extension methods.
    `` | `protected boolean` | `checkCast(ClassNode targetType, Expression source)` Checks whether the source expression can be cast to the supplied target type.
    `` | `protected void` | `checkClosureParameters(Expression callArguments, ClassNode receiver)` deprecated: this method is unused, replaced with DelegatesTo inference.
    `` | `protected void` | `checkForbiddenSpreadArgument(ArgumentListExpression arguments)` Rejects spread arguments where no target signature is available.
    `` | `protected void` | `checkGroovyConstructorMap(Expression receiver, ClassNode receiverType, MapExpression mapExpression)` Validates map-style constructor arguments against writable properties.
    `` | `protected MethodNode` | `checkGroovyStyleConstructor(ClassNode node, ClassNode[] arguments, ASTNode origin)` Checks that a constructor style expression is valid regarding the number of arguments and the argument types.
    `` | `protected ClassNode` | `checkReturnType(ReturnStatement statement)` Validates the current return statement against the enclosing closure or method.
    `` | `protected boolean` | `existsProperty(PropertyExpression pexp, boolean checkForReadOnly)` Checks whether the property exists for the current access mode.
    `` | `protected boolean` | `existsProperty(PropertyExpression pexp, boolean readMode, ClassCodeVisitorSupport visitor)` Checks whether a property exists on the receiver, or on any of the possible receiver classes (found in the temporary type information table)
    `` | `public static String` | `extractPropertyNameFromMethodName(String prefix, String methodName)` Given a method name and a prefix, returns the name of the property that should be looked up, following the java beans rules.
    `` | `protected Object` | `extractTemporaryTypeInfoKey(Expression expression)` Computes the key to use for TypeCheckingContext.temporaryIfBranchTypeInformation.
    `` | `protected static ClassNode[]` | `extractTypesFromParameters(Parameter[] parameters)` Extracts the declared types of the supplied parameters.
    `` | `protected ClassNode` | `findCurrentInstanceOfClass(Expression expression, ClassNode type)` A helper method which determines which receiver class should be used in error messages when a field or attribute is not found.
    `` | `protected List<MethodNode>` | `findMethod(ClassNode receiver, String name, ClassNode args)` Finds candidate methods matching the supplied receiver, name, and argument types.
    `` | `protected MethodNode` | `findMethodOrFail(Expression expr, ClassNode receiver, String name, ClassNode args)` Finds a matching method or reports a static type error when none is available.
    `` | `protected List<MethodNode>` | `findMethodsWithGenerated(ClassNode receiver, String name)` Returns methods defined for the specified receiver and adds "non-existing" methods that will be generated afterwards by the compiler; for example if a method is using default values and the class node is not compiled yet.
    `` | `protected static String` | `formatArgumentList(ClassNode[] nodes)` Formats an argument-type list for diagnostics.
    `` | `protected ClassNode[]` | `getArgumentTypes(ArgumentListExpression argumentList)` Returns the inferred argument types for the supplied argument list.
    `` | `protected DelegationMetadata` | `getDelegationMetadata(ClosureExpression expression)` Returns delegation metadata attached to the supplied closure expression.
    `` | `protected static ClassNode` | `getGroupOperationResultType(ClassNode a, ClassNode b)` Returns the result type for grouped numeric operations such as addition.
    `` | `protected ClassNode` | `getInferredReturnType(ASTNode node)` Returns the inferred return type of a closure or method, if stored on the AST node.
    `` | `protected ClassNode` | `getInferredReturnTypeFromWithClosureArgument(Expression callArguments)` In the case of a Object.with { ... } call, this method is supposed to retrieve the inferred closure return type.
    `` | `protected ClassNode` | `getOriginalDeclarationType(Expression lhs)` Returns the declared type of the left-hand side before any flow-based refinement.
    `` | `protected ClassNode` | `getResultType(ClassNode left, int op, ClassNode right, BinaryExpression expr)` Computes the result type of a binary operation.
    `` | `protected SourceUnit` | `getSourceUnit()` * Provides access to the SourceUnit for error reporting during visitation. * Implementations must override this method. * * Returns: the source unit for this visitor
    `` | `protected List<ClassNode>` | `getTemporaryTypesForExpression(Expression expression)` Returns temporary narrowed types recorded for the supplied expression.
    `` | `protected ClassNode` | `getType(ASTNode node)` Returns the inferred type for the supplied AST node.
    `` | `protected ClassNode[]` | `getTypeCheckingAnnotations()` Returns array of type checking annotations.
    `` | `public TypeCheckingContext` | `getTypeCheckingContext()` Returns the current type checking context.
    `` | `protected static boolean` | `hasRHSIncompleteGenericTypeInfo(ClassNode inferredRightExpressionType)` Indicates whether the inferred type still contains unresolved placeholder generics.
    `` | `protected void` | `inferClosureParameterTypes(ClassNode receiver, Expression arguments, ClosureExpression expression, Parameter target, MethodNode method)` Performs type inference on closure argument types whenever code like this is found: `foo.collect { it.toUpperCase() }`.
    `` | `protected ClassNode` | `inferComponentType(ClassNode receiverType, ClassNode subscriptType)` Infers the component type addressed by subscript or iterator access.
    `` | `protected void` | `inferDiamondType(ConstructorCallExpression cce, ClassNode lType)` Infers generic arguments for constructor calls that use the diamond operator.
    `` | `protected ClassNode` | `inferListExpressionType(ListExpression list)` Infers the static type of a list literal.
    `` | `public static ClassNode` | `inferLoopElementType(ClassNode collectionType)` Returns the inferred loop element type given a loop collection type.
    `` | `protected ClassNode` | `inferMapExpressionType(MapExpression map)` Infers the static type of a map literal.
    `` | `protected ClassNode` | `inferRangeSliceType(ClassNode receiverType)` GEP-20: probe the static return type of `rhs.getAt(IntRange)` on `receiverType`, so the rest binder can be typed against the actual slice type rather than a hard-coded `List<T>`.
    `` | `protected ClassNode` | `inferReturnTypeGenerics(ClassNode receiver, MethodNode method, Expression arguments)` If a method call returns a parameterized type, then perform additional inference on the return type, so that the type gets actual type arguments.
    `` | `protected ClassNode` | `inferReturnTypeGenerics(ClassNode receiver, MethodNode method, Expression arguments, GenericsType[] explicitTypeHints)` If a method call returns a parameterized type, then perform additional inference on the return type, so that the type gets actual type arguments.
    `` | `public void` | `initialize()` Initializes the registered type-checking extensions.
    `` | `protected static boolean` | `isClassInnerClassOrEqualTo(ClassNode toBeChecked, ClassNode start)` Indicates whether `start` is `toBeChecked` or nested within it.
    `` | `protected static boolean` | `isNullConstant(Expression expression)` Indicates whether the expression is the `null` constant.
    `` | `protected boolean` | `isSecondPassNeededForControlStructure(Map<VariableExpression, ClassNode> startTypes, Map<VariableExpression, List<ClassNode>> oldTracker)` Indicates whether a second pass is needed after visiting a control structure.
    `` | `public boolean` | `isSkipMode(AnnotatedNode node)` Indicates whether the annotated node is configured for TypeCheckingMode.SKIP.
    `` | `protected boolean` | `isSkippedInnerClass(AnnotatedNode node)` Tests if a node is an inner class node, and if it is, then checks if the enclosing method is skipped.
    `` | `protected static boolean` | `isSuperExpression(Expression expression)` Indicates whether the expression represents `super`.
    `` | `protected static boolean` | `isThisExpression(Expression expression)` Indicates whether the expression represents `this`.
    `` | `protected List<Receiver<String>>` | `makeOwnerList(Expression objectExpression)` Given an object expression (a message receiver expression), generate list of possible types.
    `` | `public void` | `performSecondPass()` Replays deferred checks that require information collected during the first pass.
    `` | `protected Map<VariableExpression, ClassNode>` | `popAssignmentTracking(Map<VariableExpression, List<ClassNode>> oldTracker)` Pops the current assignment tracker and applies any merged types.
    `` | `protected static String` | `prettyPrintMethodList(List<MethodNode> nodes)` Formats a method list for diagnostics.
    `` | `protected Map<VariableExpression, List<ClassNode>>` | `pushAssignmentTracking()` Pushes a fresh assignment tracker and returns the previous tracker.
    `` | `protected void` | `pushInstanceOfTypeInfo(Expression objectExpression, Expression typeExpression)` Stores information about types when [objectExpression instanceof typeExpression] is visited.
    `` | `protected void` | `restoreVariableExpressionMetadata(Map<VariableExpression, Map<StaticTypesMarker, Object>> typesBeforeVisit)` Restores variable-expression metadata saved before a closure visit.
    `` | `protected void` | `saveVariableExpressionMetadata(Set<VariableExpression> closureSharedExpressions, Map<VariableExpression, Map<StaticTypesMarker, Object>> typesBeforeVisit)` Saves variable-expression metadata that must survive closure re-visits.
    `` | `public void` | `setCompilationUnit(CompilationUnit compilationUnit)` Associates the visitor with a compilation unit.
    `` | `public void` | `setMethodsToBeVisited(Set<MethodNode> methodsToBeVisited)` Restricts type checking to the supplied method set.
    `` | `protected boolean` | `shouldSkipClassNode(ClassNode node)` Indicates whether the class should be skipped by this visitor.
    `` | `protected boolean` | `shouldSkipMethodNode(MethodNode node)` Indicates whether the method should be skipped by this visitor.
    `` | `protected void` | `silentlyVisitMethodNode(MethodNode directMethodCallCandidate)` Visits a method call target, to infer the type.
    `` | `protected void` | `startMethodInference(MethodNode node, ErrorCollector collector)` Starts type inference for the supplied method using the supplied error collector.
    `` | `protected ClassNode` | `storeInferredReturnType(ASTNode node, ClassNode type)` Stores the inferred return type of a closure or method.
    `` | `protected void` | `storeTargetMethod(Expression call, MethodNode target)` Stores the selected target method on the call expression.
    `` | `protected void` | `storeType(Expression exp, ClassNode cn)` Stores the inferred type for the supplied expression.
    `` | `protected void` | `typeCheckAssignment(BinaryExpression assignmentExpression, Expression leftExpression, ClassNode leftExpressionType, Expression rightExpression, ClassNode rightExpressionType)` Checks assignment compatibility and reports any associated type errors.
    `` | `protected void` | `typeCheckClosureCall(Expression arguments, ClassNode[] argumentTypes, Parameter[] parameters)` Validates closure calls against the signatures implied by the closure parameters.
    `` | `protected MethodNode` | `typeCheckMapConstructor(ConstructorCallExpression call, ClassNode receiver, Expression arguments)` Selects and validates a synthetic map-style constructor target.
    `` | `protected boolean` | `typeCheckMethodsWithGenericsOrFail(ClassNode receiver, ClassNode[] arguments, MethodNode candidateMethod, Expression location)` Validates a chosen method against its generic constraints and reports failures.
    `` | `public void` | `visitArrayExpression(ArrayExpression expression)` * Visits an ArrayExpression, traversing element expressions and size expressions. * * Parameters: `expression` - the array expression
    `` | `public void` | `visitAttributeExpression(AttributeExpression expression)` * Visits an AttributeExpression, traversing the object and attribute name expressions. * * Parameters: `expression` - the attribute expression
    `` | `public void` | `visitBinaryExpression(BinaryExpression expression)` * Visits a BinaryExpression, traversing left and right operand expressions. * * Parameters: `expression` - the binary expression
    `` | `public void` | `visitBitwiseNegationExpression(BitwiseNegationExpression expression)` * Visits a BitwiseNegationExpression, traversing the operand expression. * * Parameters: `expression` - the bitwise negation expression
    `` | `public void` | `visitCaseStatement(CaseStatement statement)` * Visits a CaseStatement, invoking the statement hook before parent traversal. * * Parameters: `statement` - the case statement to visit
    `` | `public void` | `visitCastExpression(CastExpression expression)` * Visits a CastExpression, traversing the operand expression. * * Parameters: `expression` - the cast expression
    `` | `public void` | `visitClass(ClassNode node)` * Visits a ClassNode, processing its annotations, package, imports, contents, and object initializers. * * Parameters: `node` - the class node to visit
    `` | `public void` | `visitClassExpression(ClassExpression expression)` * Visits a ClassExpression. No traversal is performed as class expressions contain no child expressions. * * Parameters: `expression` - the class expression
    `` | `public void` | `visitClosureExpression(ClosureExpression expression)` * Visits a ClosureExpression with annotation processing, traversing parameter annotations * before delegating to parent traversal. * * Parameters: `expression` - the closure expression to visit
    `` | `public void` | `visitConstructor(ConstructorNode node)` * Visits a ConstructorNode, processing its annotations, parameter annotations, and code block. * * Parameters: `node` - the constructor node to visit
    `` | `public void` | `visitConstructorCallExpression(ConstructorCallExpression call)` * Visits a ConstructorCallExpression, traversing its argument list. * * Parameters: `call` - the constructor call expression
    `` | `protected void` | `visitConstructorOrMethod(MethodNode node, boolean isConstructor)` * Visits a constructor or method node (implementation detail for both visit methods). * Processes the node's annotations, all parameter annotations, and code block. * * Parameters: `node` - the method or constructor node * `isConstructor` - true if node is a constructor, false if it is a method
    `` | `public void` | `visitExpressionStatement(ExpressionStatement statement)` * Visits an ExpressionStatement, invoking the statement hook before parent traversal. * * Parameters: `statement` - the expression statement to visit
    `` | `public void` | `visitField(FieldNode node)` * Visits a FieldNode, processing its annotations and initial value expression if present. * * Parameters: `node` - the field node to visit
    `` | `public void` | `visitForLoop(ForStatement forLoop)` * Visits a ForStatement, invoking statement hooks and processing loop variable annotations. * * Parameters: `statement` - the for statement to visit
    `` | `public void` | `visitIfElse(IfStatement ifElse)` * Visits an IfStatement, invoking the statement hook before parent traversal. * * Parameters: `statement` - the if statement to visit
    `` | `public void` | `visitMethod(MethodNode node)` * Visits a MethodNode, processing its annotations, parameter annotations, and code block. * * Parameters: `node` - the method node to visit
    `` | `protected void` | `visitMethodCallArguments(ClassNode receiver, ArgumentListExpression arguments, boolean visitFunctors, MethodNode selectedMethod)` Visits method-call arguments and defers functional arguments until a target is known.
    `` | `public void` | `visitMethodCallExpression(MethodCallExpression call)` * Visits a MethodCallExpression, traversing the object expression, * method expression, and argument list. * * Parameters: `call` - the method call expression
    `` | `public void` | `visitMethodPointerExpression(MethodPointerExpression expression)` * Visits a MethodPointerExpression, traversing the object and method name expressions. * * Parameters: `expression` - the method pointer expression
    `` | `public void` | `visitNotExpression(NotExpression expression)` * Visits a NotExpression, traversing the operand expression. * * Parameters: `expression` - the not expression
    `` | `protected void` | `visitObjectInitializerStatements(ClassNode node)` * Visits all object initializer statements in a class, typically static or instance initialization blocks. * * Parameters: `node` - the class node containing initializer statements
    `` | `public void` | `visitPostfixExpression(PostfixExpression expression)` * Visits a PostfixExpression, traversing the operand expression. * * Parameters: `expression` - the postfix expression
    `` | `public void` | `visitPrefixExpression(PrefixExpression expression)` * Visits a PrefixExpression, traversing the operand expression. * * Parameters: `expression` - the prefix expression
    `` | `public void` | `visitProperty(PropertyNode node)` * Visits a PropertyNode, processing its annotations, initial value expression, * and getter/setter blocks if present. * * Parameters: `node` - the property node to visit
    `` | `public void` | `visitPropertyExpression(PropertyExpression expression)` * Visits a PropertyExpression, traversing the object and property name expressions. * * Parameters: `expression` - the property expression
    `` | `public void` | `visitRangeExpression(RangeExpression expression)` * Visits a RangeExpression, traversing from and to boundary expressions. * * Parameters: `expression` - the range expression
    `` | `public void` | `visitReturnStatement(ReturnStatement statement)` * Visits a ReturnStatement, invoking the statement hook before parent traversal. * * Parameters: `statement` - the return statement to visit
    `` | `public void` | `visitStaticMethodCallExpression(StaticMethodCallExpression call)` * Visits a StaticMethodCallExpression, traversing its argument list. * * Parameters: `call` - the static method call expression
    `` | `public void` | `visitSwitch(SwitchStatement statement)` * Visits a SwitchStatement, invoking the statement hook before parent traversal. * * Parameters: `statement` - the switch statement to visit
    `` | `public void` | `visitSwitchExpression(SwitchExpression expression)` Type-checks a switch expression: visits the selector and each arm, selects an `isCase` target for non-intrinsic arms, unifies the yielded types (JEP 361 poly expression), and reports a non-exhaustive switch when the selector type is statically known.
    `` | `public void` | `visitTernaryExpression(TernaryExpression expression)` * Visits a TernaryExpression, traversing the condition, true-branch, and false-branch expressions. * * Parameters: `expression` - the ternary expression
    `` | `public void` | `visitTryCatchFinally(TryCatchStatement statement)` * Visits a TryCatchStatement, invoking the statement hook before parent traversal. * * Parameters: `statement` - the try-catch statement to visit
    `` | `public void` | `visitUnaryMinusExpression(UnaryMinusExpression expression)` * Visits a UnaryMinusExpression, traversing the operand expression. * * Parameters: `expression` - the unary minus expression
    `` | `public void` | `visitUnaryPlusExpression(UnaryPlusExpression expression)` * Visits a UnaryPlusExpression, traversing the operand expression. * * Parameters: `expression` - the unary plus expression
    `` | `public void` | `visitVariableExpression(VariableExpression vexp)` * Visits a VariableExpression. No traversal is performed as variable expressions contain no child expressions. * * Parameters: `expression` - the variable expression
    `` | `public void` | `visitWhileLoop(WhileStatement loop)` * Visits a WhileStatement, invoking statement hooks before parent traversal. * * Parameters: `statement` - the while statement to visit
    `` | `public void` | `visitYieldStatement(YieldStatement statement)` * Visits a YieldStatement, invoking the statement hook before parent * traversal (GROOVY-12255). * * Parameters: `statement` - the yield statement to visit * Since: 6.0.0
    `` | `protected static ClassNode` | `wrapTypeIfNecessary(ClassNode type)` Returns a wrapped type if, and only if, the provided class node is a primitive type.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class ClassCodeVisitorSupport` | `addError, getSourceUnit, visitAnnotation, visitAnnotations, visitAnnotations, visitAssertStatement, visitBlockStatement, visitBreakStatement, visitCaseStatement, visitCatchStatement, visitClass, visitClassCodeContainer, visitClosureExpression, visitConstructor, visitConstructorOrMethod, visitContinueStatement, visitDeclarationExpression, visitDoWhileLoop, visitExpressionStatement, visitField, visitForLoop, visitIfElse, visitImports, visitMethod, visitObjectInitializerStatements, visitPackage, visitProperty, visitReturnStatement, visitStatement, visitStatementAnnotations, visitSwitch, visitSynchronizedStatement, visitThrowStatement, visitTryCatchFinally, visitWhileLoop, visitYieldStatement`
    `class CodeVisitorSupport` | `afterSwitchCaseStatementsVisited, afterSwitchCaseStatementsVisited, afterSwitchConditionExpressionVisited, afterSwitchConditionExpressionVisited, visitArgumentlistExpression, visitArrayExpression, visitAssertStatement, visitAttributeExpression, visitBinaryExpression, visitBitwiseNegationExpression, visitBlockStatement, visitBooleanExpression, visitBreakStatement, visitBytecodeExpression, visitCaseStatement, visitCastExpression, visitCatchStatement, visitClassExpression, visitClosureExpression, visitClosureListExpression, visitConstantExpression, visitConstructorCallExpression, visitContinueStatement, visitDeclarationExpression, visitDoWhileLoop, visitEmptyStatement, visitExpressionStatement, visitFieldExpression, visitForLoop, visitGStringExpression, visitIfElse, visitLambdaExpression, visitListExpression, visitMapEntryExpression, visitMapExpression, visitMethodCallExpression, visitMethodPointerExpression, visitMethodReferenceExpression, visitNotExpression, visitPostfixExpression, visitPrefixExpression, visitPropertyExpression, visitRangeExpression, visitReturnStatement, visitShortTernaryExpression, visitSpreadExpression, visitSpreadMapExpression, visitStaticMethodCallExpression, visitSwitch, visitSwitchExpression, visitSynchronizedStatement, visitTernaryExpression, visitThrowStatement, visitTryCatchFinally, visitTupleExpression, visitUnaryMinusExpression, visitUnaryPlusExpression, visitVariableExpression, visitWhileLoop, visitYieldStatement`

- - ### Field Detail

    - #### protected static final ClassNode CHAR_SEQUENCE_TYPE

      Cached CharSequence type (GROOVY-9848: membership operator dispatch).

    - #### protected static final ClassNode CLOSUREPARAMS_CLASSNODE

      Cached ClosureParams annotation type.

    - #### public static final MethodNode CLOSURE_CALL_NO_ARG

      Cached zero-argument `Closure#call()` method.

    - #### public static final MethodNode CLOSURE_CALL_ONE_ARG

      Cached single-argument `Closure#call(Object)` method.

    - #### public static final MethodNode CLOSURE_CALL_VARGS

      Cached varargs `Closure#call(Object[])` method.

    - #### protected static final Expression CURRENT_SIGNATURE_PROTOCOL

      Constant expression for the current signature protocol version.

    - #### protected static final int CURRENT_SIGNATURE_PROTOCOL_VERSION

      Current encoding protocol for stored type-checking signatures.

    - #### protected static final ClassNode DELEGATES_TO

      Cached DelegatesTo annotation type.

    - #### protected static final ClassNode DELEGATES_TO_TARGET

      Cached DelegatesTo.Target annotation type.

    - #### protected static final ClassNode DGM_CLASSNODE

      Cached DefaultGroovyMethods type.

    - #### protected static final List<MethodNode> EMPTY_METHODNODE_LIST

      Shared empty method list.

    - #### protected static final ClassNode ENUMERATION_TYPE

      Cached Enumeration type.

    - #### protected static final Object ERROR_COLLECTOR

      Metadata key used to store per-method error collectors.

    - #### public static final Statement GENERATED_EMPTY_STATEMENT

      Empty statement reused for synthetic AST nodes.

    - #### protected static final MethodNode GET_DELEGATE

      Cached `Closure#getDelegate()` method.

    - #### protected static final MethodNode GET_OWNER

      Cached `Closure#getOwner()` method.

    - #### protected static final MethodNode GET_THISOBJECT

      Cached `Closure#getThisObject()` method.

    - #### protected static final ClassNode ITERABLE_TYPE

      Cached Iterable type.

    - #### @Deprecated(forRemoval = true, since = "4.0.0")
      protected static final ClassNode LINKEDHASHMAP_CLASSNODE

    - #### protected static final ClassNode MAP_ENTRY_TYPE

      Cached Entry type.

    - #### protected static final ClassNode NAMED_PARAMS_CLASSNODE

      Cached NamedParams annotation type.

    - #### protected static final ClassNode NAMED_PARAM_CLASSNODE

      Cached NamedParam annotation type.

    - #### protected static final ClassNode TYPECHECKED_CLASSNODE

      Cached TypeChecked annotation type.

    - #### protected static final ClassNode[] TYPECHECKING_ANNOTATIONS

      Type-checking annotations recognized by this visitor.

    - #### protected static final ClassNode TYPECHECKING_INFO_NODE

      Cached TypeChecked.TypeCheckingInfo annotation type.

    - #### protected FieldNode currentField

      Field currently being visited.

    - #### protected PropertyNode currentProperty

      Property currently being visited.

    - #### protected DefaultTypeCheckingExtension extension

      Composite extension chain consulted during type checking.

    - #### protected final ReturnAdder returnAdder

      Return adder used to normalize implicit and explicit returns.

    - #### protected final ReturnStatementListener returnListener

    - #### protected TypeCheckingContext typeCheckingContext

      Mutable state for the current type-checking run.

  - ### Constructor Detail

    - #### public StaticTypeCheckingVisitor(SourceUnit source, ClassNode classNode)

      Creates a static type-checking visitor for the supplied source and class.

  - ### Method Detail

    - #### protected void addAmbiguousErrorMessage(List<MethodNode> foundMethods, String name, ClassNode[] args, Expression expr)

      Reports that method resolution remained ambiguous after filtering.

    - #### protected void addAssignmentError(ClassNode leftType, ClassNode rightType, Expression expression)

      Reports an incompatible assignment between the supplied types.

    - #### protected void addCategoryMethodCallError(Expression call)

      Reports that categories cannot be used under static type checking.

    - #### protected void addClosureReturnType(ClassNode returnType)

      Records a non-void return type for the current enclosing closure.

    - #### public void addError(String msg, ASTNode node)

      * Adds an error message associated with an AST node to the source unit. * Errors are accumulated and reported after visitation completes. * *

      Parameters:
        `error` - the error message to report *
        `node` - the AST node associated with the error location *
      See Also:
        ErrorCollecting

    - #### protected void addNoMatchingMethodError(ClassNode receiver, String name, ClassNode[] args, Expression exp)

      Reports that no matching method or constructor could be found for the call.

    - #### protected void addNoMatchingMethodError(ClassNode receiver, String name, ClassNode[] args, ASTNode origin)

      Reports that no matching method or constructor could be found for the call.

    - #### protected void addReceivers(List<Receiver<String>> receivers, Collection<Receiver<String>> owners, boolean implicitThis)

      Adds candidate receivers derived from owner chains.

    - #### protected void addStaticTypeError(String msg, ASTNode node)

      Reports a static type checking error for the supplied node.

    - #### public void addTypeCheckingExtension(TypeCheckingExtension extension)

      Adds a type-checking extension to the active extension chain.

    - #### protected void addTypeCheckingInfoAnnotation(MethodNode node)

      Adds TypeChecked.TypeCheckingInfo metadata for an inferred method return type.

    - #### protected void addUnsupportedPreOrPostfixExpressionError(Expression expression)

      Reports an unsupported prefix or postfix operation.

    - #### protected void afterSwitchCaseStatementsVisited(SwitchExpression expression)

      * Hook method called after all case arms are visited, but before the default * arm (GROOVY-12255). * *

      Parameters:
        `expression` - the switch expression being visited *
      Since:
        6.0.0

    - #### protected void afterSwitchCaseStatementsVisited(SwitchStatement statement)

      * Hook method called after all case statements are visited, but before the default statement. * Subclasses may override to perform processing between cases and default. * *

      Parameters:
        `statement` - the switch statement being visited *
      Since:
        5.0.0

    - #### protected void afterSwitchConditionExpressionVisited(SwitchExpression expression)

      * Hook method called after the switch-expression selector is visited, but * before case arms (GROOVY-12255). * *

      Parameters:
        `expression` - the switch expression being visited *
      Since:
        6.0.0

    - #### protected void afterSwitchConditionExpressionVisited(SwitchStatement statement)

      * Hook method called after the switch condition expression is visited, but before case statements. * Subclasses may override to perform processing between condition and cases. * *

      Parameters:
        `statement` - the switch statement being visited *
      Since:
        3.0.0

    - #### protected boolean areCategoryMethodCalls(List<MethodNode> foundMethods, String name, ClassNode[] args)

      Indicates whether all candidates are category-style extension methods.

    - #### protected boolean checkCast(ClassNode targetType, Expression source)

      Checks whether the source expression can be cast to the supplied target type.

    - #### @Deprecated(forRemoval = true, since = "2.5.0")
      protected void checkClosureParameters(Expression callArguments, ClassNode receiver)

      deprecated:
        this method is unused, replaced with DelegatesTo inference.

    - #### protected void checkForbiddenSpreadArgument(ArgumentListExpression arguments)

      Rejects spread arguments where no target signature is available.

    - #### protected void checkGroovyConstructorMap(Expression receiver, ClassNode receiverType, MapExpression mapExpression)

      Validates map-style constructor arguments against writable properties.

    - #### protected MethodNode checkGroovyStyleConstructor(ClassNode node, ClassNode[] arguments, ASTNode origin)

      Checks that a constructor style expression is valid regarding the number of arguments and the argument types.

      Parameters:
        `node` - the class node for which we will try to find a matching constructor
        `arguments` - the constructor arguments

    - #### protected ClassNode checkReturnType(ReturnStatement statement)

      Validates the current return statement against the enclosing closure or method.

    - #### protected boolean existsProperty(PropertyExpression pexp, boolean checkForReadOnly)

      Checks whether the property exists for the current access mode.

    - #### protected boolean existsProperty(PropertyExpression pexp, boolean readMode, ClassCodeVisitorSupport visitor)

      Checks whether a property exists on the receiver, or on any of the possible receiver classes (found in the temporary type information table)

      Parameters:
        `pexp` - a property expression
        `readMode` - if true, look for property read, else for property set
        `visitor` - if not null, when the property node is found, visit it with the provided visitor
      Returns:
        true if the property is defined in any of the possible receiver classes

    - #### public static String extractPropertyNameFromMethodName(String prefix, String methodName)

      Given a method name and a prefix, returns the name of the property that should be looked up, following the java beans rules. For example, "getName" would return "name", while "getFullName" would return "fullName". If the prefix is not found, returns null.

      Parameters:
        `prefix` - the method name prefix ("get", "is", "set", ...)
        `methodName` - the method name
      Returns:
        a property name if the prefix is found and the method matches the java beans rules, null otherwise

    - #### protected Object extractTemporaryTypeInfoKey(Expression expression)

      Computes the key to use for TypeCheckingContext.temporaryIfBranchTypeInformation.

    - #### protected static ClassNode[] extractTypesFromParameters(Parameter[] parameters)

      Extracts the declared types of the supplied parameters.

    - #### protected ClassNode findCurrentInstanceOfClass(Expression expression, ClassNode type)

      A helper method which determines which receiver class should be used in error messages when a field or attribute is not found. The returned type class depends on whether we have temporary type information available (due to instanceof checks) and whether there is a single candidate in that case.

      Parameters:
        `expression` - the expression for which an unknown field has been found
        `type` - the type of the expression (used as fallback type)
      Returns:
        if temporary information is available and there's only one type, returns the temporary type class otherwise falls back to the provided type class.

    - #### protected List<MethodNode> findMethod(ClassNode receiver, String name, ClassNode args)

      Finds candidate methods matching the supplied receiver, name, and argument types.

    - #### protected MethodNode findMethodOrFail(Expression expr, ClassNode receiver, String name, ClassNode args)

      Finds a matching method or reports a static type error when none is available.

    - #### protected List<MethodNode> findMethodsWithGenerated(ClassNode receiver, String name)

      Returns methods defined for the specified receiver and adds "non-existing" methods that will be generated afterwards by the compiler; for example if a method is using default values and the class node is not compiled yet.

      Parameters:
        `receiver` - the type to search for methods
        `name` - the name of the methods to return
      Returns:
        the methods that are defined on the receiver completed with stubs for future methods

    - #### protected static String formatArgumentList(ClassNode[] nodes)

      Formats an argument-type list for diagnostics.

    - #### protected ClassNode[] getArgumentTypes(ArgumentListExpression argumentList)

      Returns the inferred argument types for the supplied argument list.

    - #### protected DelegationMetadata getDelegationMetadata(ClosureExpression expression)

      Returns delegation metadata attached to the supplied closure expression.

    - #### protected static ClassNode getGroupOperationResultType(ClassNode a, ClassNode b)

      Returns the result type for grouped numeric operations such as addition.

    - #### protected ClassNode getInferredReturnType(ASTNode node)

      Returns the inferred return type of a closure or method, if stored on the AST node. This method doesn't perform any type inference by itself.

      Parameters:
        `node` - a ClosureExpression or MethodNode
      Returns:
        The expected return type.

    - #### protected ClassNode getInferredReturnTypeFromWithClosureArgument(Expression callArguments)

      In the case of a Object.with { ... } call, this method is supposed to retrieve the inferred closure return type.

      Parameters:
        `callArguments` - the argument list from the Object#with(Closure) call, i.e. a single closure expression
      Returns:
        the inferred closure return type or null

    - #### protected ClassNode getOriginalDeclarationType(Expression lhs)

      Returns the declared type of the left-hand side before any flow-based refinement.

    - #### protected ClassNode getResultType(ClassNode left, int op, ClassNode right, BinaryExpression expr)

      Computes the result type of a binary operation.

    - #### protected SourceUnit getSourceUnit()

      * Provides access to the SourceUnit for error reporting during visitation. * Implementations must override this method. * *

      Returns:
        the source unit for this visitor

    - #### protected List<ClassNode> getTemporaryTypesForExpression(Expression expression)

      Returns temporary narrowed types recorded for the supplied expression.

    - #### protected ClassNode getType(ASTNode node)

      Returns the inferred type for the supplied AST node.

    - #### protected ClassNode[] getTypeCheckingAnnotations()

      Returns array of type checking annotations. Subclasses may override this method in order to provide additional types which must be looked up when checking if a method or a class node should be skipped.

      The default implementation returns TypeChecked.

    - #### public TypeCheckingContext getTypeCheckingContext()

      Returns the current type checking context. The context is used internally by the type checker during type checking to store various state data.

      Returns:
        the type checking context

    - #### @Deprecated(forRemoval = true, since = "4.0.0")
      protected static boolean hasRHSIncompleteGenericTypeInfo(ClassNode inferredRightExpressionType)

      Indicates whether the inferred type still contains unresolved placeholder generics.

    - #### protected void inferClosureParameterTypes(ClassNode receiver, Expression arguments, ClosureExpression expression, Parameter target, MethodNode method)

      Performs type inference on closure argument types whenever code like this is found: `foo.collect { it.toUpperCase() }`.

      In this case the type checker tries to find if the `collect` method has its Closure argument annotated with ClosureParams. If so, then additional type inference can be performed and the type of `it` may be inferred.

      Parameters:
        receiver
        arguments
        `expression` - closure or lambda expression for which the argument types should be inferred
        `target` - parameter which may provide ClosureParams annotation or SAM type
        `method` - method that declares `target`

    - #### protected ClassNode inferComponentType(ClassNode receiverType, ClassNode subscriptType)

      Infers the component type addressed by subscript or iterator access.

    - #### protected void inferDiamondType(ConstructorCallExpression cce, ClassNode lType)

      Infers generic arguments for constructor calls that use the diamond operator.

    - #### protected ClassNode inferListExpressionType(ListExpression list)

      Infers the static type of a list literal.

    - #### public static ClassNode inferLoopElementType(ClassNode collectionType)

      Returns the inferred loop element type given a loop collection type. Used, for example, to infer the element type of a `for (e in list)` loop.

      Parameters:
        `collectionType` - the type of the collection
      Returns:
        the inferred component type
      See Also:
        inferComponentType

    - #### protected ClassNode inferMapExpressionType(MapExpression map)

      Infers the static type of a map literal.

    - #### protected ClassNode inferRangeSliceType(ClassNode receiverType)

      GEP-20: probe the static return type of `rhs.getAt(IntRange)` on `receiverType`, so the rest binder can be typed against the actual slice type rather than a hard-coded `List<T>`. Returns the resolved slice type (e.g. `String` for a String receiver, `BitSet` for a BitSet receiver, the user-declared return type for custom classes), or `null` if the receiver has no resolvable `getAt(IntRange)`.

      Mirrors inferComponentType but for the IntRange overload. Method resolution runs under a swallowed error collector so a missing overload doesn't surface as a static-type error.

    - #### protected ClassNode inferReturnTypeGenerics(ClassNode receiver, MethodNode method, Expression arguments)

      If a method call returns a parameterized type, then perform additional inference on the return type, so that the type gets actual type arguments. For example, the method `Arrays.asList(T...)` is parameterized with `T`, which can be deduced type arguments or call arguments.

      Parameters:
        `method` - the method node
        `arguments` - the method call arguments
        `receiver` - the object expression type

    - #### protected ClassNode inferReturnTypeGenerics(ClassNode receiver, MethodNode method, Expression arguments, GenericsType[] explicitTypeHints)

      If a method call returns a parameterized type, then perform additional inference on the return type, so that the type gets actual type arguments. For example, the method `Arrays.asList(T...)` is parameterized with `T`, which can be deduced type arguments or call arguments.

      Parameters:
        `method` - the method node
        `arguments` - the method call arguments
        `receiver` - the object expression type
        `explicitTypeHints` - type arguments (optional), for example `Collections.<String>emptyList()`

    - #### public void initialize()

      Initializes the registered type-checking extensions.

    - #### protected static boolean isClassInnerClassOrEqualTo(ClassNode toBeChecked, ClassNode start)

      Indicates whether `start` is `toBeChecked` or nested within it.

    - #### protected static boolean isNullConstant(Expression expression)

      Indicates whether the expression is the `null` constant.

    - #### protected boolean isSecondPassNeededForControlStructure(Map<VariableExpression, ClassNode> startTypes, Map<VariableExpression, List<ClassNode>> oldTracker)

      Indicates whether a second pass is needed after visiting a control structure.

    - #### public boolean isSkipMode(AnnotatedNode node)

      Indicates whether the annotated node is configured for TypeCheckingMode.SKIP.

      The most specific annotation wins: a node whose own type-checking annotation has a non-SKIP mode is never skipped, whatever an enclosing class or method declares. Without an annotation of its own, a node inherits skip mode from its enclosing scope.

    - #### protected boolean isSkippedInnerClass(AnnotatedNode node)

      Tests if a node is an inner class node, and if it is, then checks if the enclosing method is skipped.

      Returns:
        true if the inner class node should be skipped

    - #### protected static boolean isSuperExpression(Expression expression)

      Indicates whether the expression represents `super`.

    - #### protected static boolean isThisExpression(Expression expression)

      Indicates whether the expression represents `this`.

    - #### protected List<Receiver<String>> makeOwnerList(Expression objectExpression)

      Given an object expression (a message receiver expression), generate list of possible types.

      Parameters:
        `objectExpression` - the message receiver
      Returns:
        types and qualifiers of the receiver

    - #### public void performSecondPass()

      Replays deferred checks that require information collected during the first pass.

    - #### protected Map<VariableExpression, ClassNode> popAssignmentTracking(Map<VariableExpression, List<ClassNode>> oldTracker)

      Pops the current assignment tracker and applies any merged types.

    - #### protected static String prettyPrintMethodList(List<MethodNode> nodes)

      Formats a method list for diagnostics.

    - #### protected Map<VariableExpression, List<ClassNode>> pushAssignmentTracking()

      Pushes a fresh assignment tracker and returns the previous tracker.

    - #### protected void pushInstanceOfTypeInfo(Expression objectExpression, Expression typeExpression)

      Stores information about types when [objectExpression instanceof typeExpression] is visited.

      Parameters:
        `objectExpression` - the expression to be checked against instanceof
        `typeExpression` - the expression which represents the target type

    - #### protected void restoreVariableExpressionMetadata(Map<VariableExpression, Map<StaticTypesMarker, Object>> typesBeforeVisit)

      Restores variable-expression metadata saved before a closure visit.

    - #### protected void saveVariableExpressionMetadata(Set<VariableExpression> closureSharedExpressions, Map<VariableExpression, Map<StaticTypesMarker, Object>> typesBeforeVisit)

      Saves variable-expression metadata that must survive closure re-visits.

    - #### public void setCompilationUnit(CompilationUnit compilationUnit)

      Associates the visitor with a compilation unit.

    - #### public void setMethodsToBeVisited(Set<MethodNode> methodsToBeVisited)

      Restricts type checking to the supplied method set.

    - #### protected boolean shouldSkipClassNode(ClassNode node)

      Indicates whether the class should be skipped by this visitor.

    - #### protected boolean shouldSkipMethodNode(MethodNode node)

      Indicates whether the method should be skipped by this visitor.

    - #### protected void silentlyVisitMethodNode(MethodNode directMethodCallCandidate)

      Visits a method call target, to infer the type. Don't report errors right away, that will be done by a later visitMethod call.

    - #### protected void startMethodInference(MethodNode node, ErrorCollector collector)

      Starts type inference for the supplied method using the supplied error collector.

    - #### protected ClassNode storeInferredReturnType(ASTNode node, ClassNode type)

      Stores the inferred return type of a closure or method. We are using a separate key to store inferred return type because the inferred type of a closure is Closure, which is different from the inferred type of the code of the closure.

      Parameters:
        `node` - a ClosureExpression or MethodNode
        `type` - the inferred return type of the code
      Returns:
        The old value of the inferred type.

    - #### protected void storeTargetMethod(Expression call, MethodNode target)

      Stores the selected target method on the call expression.

    - #### protected void storeType(Expression exp, ClassNode cn)

      Stores the inferred type for the supplied expression.

    - #### protected void typeCheckAssignment(BinaryExpression assignmentExpression, Expression leftExpression, ClassNode leftExpressionType, Expression rightExpression, ClassNode rightExpressionType)

      Checks assignment compatibility and reports any associated type errors.

    - #### protected void typeCheckClosureCall(Expression arguments, ClassNode[] argumentTypes, Parameter[] parameters)

      Validates closure calls against the signatures implied by the closure parameters.

    - #### protected MethodNode typeCheckMapConstructor(ConstructorCallExpression call, ClassNode receiver, Expression arguments)

      Selects and validates a synthetic map-style constructor target.

    - #### protected boolean typeCheckMethodsWithGenericsOrFail(ClassNode receiver, ClassNode[] arguments, MethodNode candidateMethod, Expression location)

      Validates a chosen method against its generic constraints and reports failures.

    - #### public void visitArrayExpression(ArrayExpression expression)

      * Visits an ArrayExpression, traversing element expressions and size expressions. * *

      Parameters:
        `expression` - the array expression

    - #### public void visitAttributeExpression(AttributeExpression expression)

      * Visits an AttributeExpression, traversing the object and attribute name expressions. * *

      Parameters:
        `expression` - the attribute expression

    - #### public void visitBinaryExpression(BinaryExpression expression)

      * Visits a BinaryExpression, traversing left and right operand expressions. * *

      Parameters:
        `expression` - the binary expression

    - #### public void visitBitwiseNegationExpression(BitwiseNegationExpression expression)

      * Visits a BitwiseNegationExpression, traversing the operand expression. * *

      Parameters:
        `expression` - the bitwise negation expression

    - #### public void visitCaseStatement(CaseStatement statement)

      * Visits a CaseStatement, invoking the statement hook before parent traversal. * *

      Parameters:
        `statement` - the case statement to visit

    - #### public void visitCastExpression(CastExpression expression)

      * Visits a CastExpression, traversing the operand expression. * *

      Parameters:
        `expression` - the cast expression

    - #### public void visitClass(ClassNode node)

      * Visits a ClassNode, processing its annotations, package, imports, contents, and object initializers. * *

      Parameters:
        `node` - the class node to visit

    - #### public void visitClassExpression(ClassExpression expression)

      * Visits a ClassExpression. No traversal is performed as class expressions contain no child expressions. * *

      Parameters:
        `expression` - the class expression

    - #### public void visitClosureExpression(ClosureExpression expression)

      * Visits a ClosureExpression with annotation processing, traversing parameter annotations * before delegating to parent traversal. * *

      Parameters:
        `expression` - the closure expression to visit

    - #### public void visitConstructor(ConstructorNode node)

      * Visits a ConstructorNode, processing its annotations, parameter annotations, and code block. * *

      Parameters:
        `node` - the constructor node to visit

    - #### public void visitConstructorCallExpression(ConstructorCallExpression call)

      * Visits a ConstructorCallExpression, traversing its argument list. * *

      Parameters:
        `call` - the constructor call expression

    - #### protected void visitConstructorOrMethod(MethodNode node, boolean isConstructor)

      * Visits a constructor or method node (implementation detail for both visit methods). * Processes the node's annotations, all parameter annotations, and code block. * *

      Parameters:
        `node` - the method or constructor node *
        `isConstructor` - true if node is a constructor, false if it is a method

    - #### public void visitExpressionStatement(ExpressionStatement statement)

      * Visits an ExpressionStatement, invoking the statement hook before parent traversal. * *

      Parameters:
        `statement` - the expression statement to visit

    - #### public void visitField(FieldNode node)

      * Visits a FieldNode, processing its annotations and initial value expression if present. * *

      Parameters:
        `node` - the field node to visit

    - #### public void visitForLoop(ForStatement forLoop)

      * Visits a ForStatement, invoking statement hooks and processing loop variable annotations. * *

      Parameters:
        `statement` - the for statement to visit

    - #### public void visitIfElse(IfStatement ifElse)

      * Visits an IfStatement, invoking the statement hook before parent traversal. * *

      Parameters:
        `statement` - the if statement to visit

    - #### public void visitMethod(MethodNode node)

      * Visits a MethodNode, processing its annotations, parameter annotations, and code block. * *

      Parameters:
        `node` - the method node to visit

    - #### protected void visitMethodCallArguments(ClassNode receiver, ArgumentListExpression arguments, boolean visitFunctors, MethodNode selectedMethod)

      Visits method-call arguments and defers functional arguments until a target is known.

    - #### public void visitMethodCallExpression(MethodCallExpression call)

      * Visits a MethodCallExpression, traversing the object expression, * method expression, and argument list. * *

      Parameters:
        `call` - the method call expression

    - #### public void visitMethodPointerExpression(MethodPointerExpression expression)

      * Visits a MethodPointerExpression, traversing the object and method name expressions. * *

      Parameters:
        `expression` - the method pointer expression

    - #### public void visitNotExpression(NotExpression expression)

      * Visits a NotExpression, traversing the operand expression. * *

      Parameters:
        `expression` - the not expression

    - #### protected void visitObjectInitializerStatements(ClassNode node)

      * Visits all object initializer statements in a class, typically static or instance initialization blocks. * *

      Parameters:
        `node` - the class node containing initializer statements

    - #### public void visitPostfixExpression(PostfixExpression expression)

      * Visits a PostfixExpression, traversing the operand expression. * *

      Parameters:
        `expression` - the postfix expression

    - #### public void visitPrefixExpression(PrefixExpression expression)

      * Visits a PrefixExpression, traversing the operand expression. * *

      Parameters:
        `expression` - the prefix expression

    - #### public void visitProperty(PropertyNode node)

      * Visits a PropertyNode, processing its annotations, initial value expression, * and getter/setter blocks if present. * *

      Parameters:
        `node` - the property node to visit

    - #### public void visitPropertyExpression(PropertyExpression expression)

      * Visits a PropertyExpression, traversing the object and property name expressions. * *

      Parameters:
        `expression` - the property expression

    - #### public void visitRangeExpression(RangeExpression expression)

      * Visits a RangeExpression, traversing from and to boundary expressions. * *

      Parameters:
        `expression` - the range expression

    - #### public void visitReturnStatement(ReturnStatement statement)

      * Visits a ReturnStatement, invoking the statement hook before parent traversal. * *

      Parameters:
        `statement` - the return statement to visit

    - #### public void visitStaticMethodCallExpression(StaticMethodCallExpression call)

      * Visits a StaticMethodCallExpression, traversing its argument list. * *

      Parameters:
        `call` - the static method call expression

    - #### public void visitSwitch(SwitchStatement statement)

      * Visits a SwitchStatement, invoking the statement hook before parent traversal. * *

      Parameters:
        `statement` - the switch statement to visit

    - #### public void visitSwitchExpression(SwitchExpression expression)

      Type-checks a switch expression: visits the selector and each arm, selects an `isCase` target for non-intrinsic arms, unifies the yielded types (JEP 361 poly expression), and reports a non-exhaustive switch when the selector type is statically known.

      Since:
        6.0.0

    - #### public void visitTernaryExpression(TernaryExpression expression)

      * Visits a TernaryExpression, traversing the condition, true-branch, and false-branch expressions. * *

      Parameters:
        `expression` - the ternary expression

    - #### public void visitTryCatchFinally(TryCatchStatement statement)

      * Visits a TryCatchStatement, invoking the statement hook before parent traversal. * *

      Parameters:
        `statement` - the try-catch statement to visit

    - #### public void visitUnaryMinusExpression(UnaryMinusExpression expression)

      * Visits a UnaryMinusExpression, traversing the operand expression. * *

      Parameters:
        `expression` - the unary minus expression

    - #### public void visitUnaryPlusExpression(UnaryPlusExpression expression)

      * Visits a UnaryPlusExpression, traversing the operand expression. * *

      Parameters:
        `expression` - the unary plus expression

    - #### public void visitVariableExpression(VariableExpression vexp)

      * Visits a VariableExpression. No traversal is performed as variable expressions contain no child expressions. * *

      Parameters:
        `expression` - the variable expression

    - #### public void visitWhileLoop(WhileStatement loop)

      * Visits a WhileStatement, invoking statement hooks before parent traversal. * *

      Parameters:
        `statement` - the while statement to visit

    - #### public void visitYieldStatement(YieldStatement statement)

      * Visits a YieldStatement, invoking the statement hook before parent * traversal (GROOVY-12255). * *

      Parameters:
        `statement` - the yield statement to visit *
      Since:
        6.0.0

    - #### protected static ClassNode wrapTypeIfNecessary(ClassNode type)

      Returns a wrapped type if, and only if, the provided class node is a primitive type. This method differs from ClassHelper#getWrapper(org.codehaus.groovy.ast.ClassNode) as it will return the same instance if the provided type is not a generic type.

      Returns:
        the wrapped type