Groovy Documentation

org.codehaus.groovy.transform.stc
[Java] Class StaticTypeCheckingVisitor

java.lang.Object
  org.codehaus.groovy.ast.CodeVisitorSupport
      org.codehaus.groovy.ast.ClassCodeVisitorSupport
          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.

Authors:
Cedric Champeau
Jochen Theodorou


Nested Class Summary
static class StaticTypeCheckingVisitor.SignatureCodecFactory

protected class StaticTypeCheckingVisitor.VariableExpressionTypeMemoizer

 
Field Summary
static MethodNode CLOSURE_CALL_NO_ARG

static MethodNode CLOSURE_CALL_ONE_ARG

static MethodNode CLOSURE_CALL_VARGS

protected static Expression CURRENT_SIGNATURE_PROTOCOL

protected static int CURRENT_SIGNATURE_PROTOCOL_VERSION

protected static ClassNode DELEGATES_TO

protected static ClassNode DELEGATES_TO_TARGET

protected static ClassNode DGM_CLASSNODE

protected static java.util.List EMPTY_METHODNODE_LIST

protected static java.lang.Object ERROR_COLLECTOR

protected static MethodNode GET_DELEGATE

protected static MethodNode GET_OWNER

protected static MethodNode GET_THISOBJECT

protected static ClassNode ITERABLE_TYPE

protected static ClassNode TYPECHECKED_CLASSNODE

protected static ClassNode[] TYPECHECKING_ANNOTATIONS

protected static ClassNode TYPECHECKING_INFO_NODE

protected DefaultTypeCheckingExtension extension

protected ReturnAdder returnAdder

protected ReturnStatementListener returnListener

protected TypeCheckingContext typeCheckingContext

 
Constructor Summary
StaticTypeCheckingVisitor(SourceUnit source, ClassNode cn)

 
Method Summary
protected void addAmbiguousErrorMessage(java.util.List foundMethods, java.lang.String name, ClassNode[] args, Expression expr)

protected void addAssignmentError(ClassNode leftType, ClassNode rightType, Expression assignmentExpression)

protected void addCategoryMethodCallError(Expression call)

protected void addClosureReturnType(ClassNode returnType)

protected void addError(java.lang.String msg, ASTNode expr)

protected void addNoMatchingMethodError(ClassNode receiver, java.lang.String name, ClassNode[] args, Expression call)

protected void addReceivers(java.util.List receivers, java.util.Collection owners, boolean implicitThis)

protected void addStaticTypeError(java.lang.String msg, ASTNode expr)

void addTypeCheckingExtension(TypeCheckingExtension extension)

protected void addTypeCheckingInfoAnnotation(MethodNode node)

protected void addUnsupportedPreOrPostfixExpressionError(Expression expression)

protected boolean areCategoryMethodCalls(java.util.List foundMethods, java.lang.String name, ClassNode[] args)

protected boolean checkCast(ClassNode targetType, Expression source)

protected void checkClosureParameters(Expression callArguments, ClassNode receiver)

visit a method call target, to infer the type.

protected void checkForbiddenSpreadArgument(ArgumentListExpression argumentList)

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

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

protected void checkGroovyStyleConstructor(ClassNode node, ClassNode[] arguments)

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

protected ClassNode checkReturnType(ReturnStatement statement)

protected void collectAllInterfaceMethodsByName(ClassNode receiver, java.lang.String name, java.util.List methods)

If a method call returns a parameterized type, then we can perform additional inference on the return type, so that the type gets actual type parameters.

protected boolean existsProperty(PropertyExpression pexp, boolean checkForReadOnly)

protected boolean existsProperty(PropertyExpression pexp, boolean checkForReadOnly, ClassCodeVisitorSupport visitor)

protected java.lang.Object extractTemporaryTypeInfoKey(Expression expression)

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

protected ClassNode findCurrentInstanceOfClass(Expression expr, ClassNode type)

protected java.util.List findMethod(ClassNode receiver, java.lang.String name, ClassNode... args)

protected MethodNode findMethodOrFail(Expression expr, ClassNode receiver, java.lang.String name, ClassNode... args)

protected java.util.List findMethodsWithGenerated(ClassNode receiver, java.lang.String name)

protected static java.lang.String formatArgumentList(ClassNode[] nodes)

Returns a wrapped type if, and only if, the provided class node is a primitive type.

protected static GenericsType fullyResolve(GenericsType gt, java.util.Map placeholders)

protected static ClassNode fullyResolveType(ClassNode type, java.util.Map placeholders)

protected ClassNode[] getArgumentTypes(ArgumentListExpression args)

protected DelegationMetadata getDelegationMetadata(ClosureExpression expression)

protected static ClassNode getGroupOperationResultType(ClassNode a, ClassNode b)

This method returns the list of methods named against the supplied parameter that are defined on the specified receiver, but it will also add "non existing" methods that will be generated afterwards by the compiler, for example if a method is using default values and that the specified class node isn't compiled yet.

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)

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

protected SourceUnit getSourceUnit()

protected java.util.List getTemporaryTypesForExpression(Expression objectExpression)

protected ClassNode getType(ASTNode exp)

protected ClassNode[] getTypeCheckingAnnotations()

TypeCheckingContext getTypeCheckingContext()

Returns the current type checking context.

protected static boolean hasRHSIncompleteGenericTypeInfo(ClassNode inferredRightExpressionType)

A helper method which determines which receiver class should be used in error messages when a field or attribute is not found.

protected StaticTypeCheckingVisitor.SetterInfo hasSetter(PropertyExpression pexp)

protected ClassNode inferComponentType(ClassNode containerType, ClassNode indexType)

protected void inferDiamondType(ConstructorCallExpression cce, ClassNode lType)

protected ClassNode inferListExpressionType(ListExpression list)

static ClassNode inferLoopElementType(ClassNode collectionType)

protected ClassNode inferMapExpressionType(MapExpression map)

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

Checks that the parameterized generics of an argument are compatible with the generics of the parameter.

void initialize()

protected static boolean isClassInnerClassOrEqualTo(ClassNode toBeChecked, ClassNode start)

protected boolean isClosureCall(java.lang.String name, Expression objectExpression, Expression arguments)

protected static boolean isNullConstant(Expression expression)

Given a generics type representing SomeClass<T,V> and a resolved placeholder map, returns a new generics type for which placeholders are resolved recursively.

protected boolean isSecondPassNeededForControlStructure(java.util.Map varOrigType, java.util.Map oldTracker)

boolean isSkipMode(AnnotatedNode node)

protected java.util.List makeOwnerList(Expression objectExpression)

void performSecondPass()

protected void pickInferredTypeFromMethodAnnotation(MethodNode node)

protected java.util.Map popAssignmentTracking(java.util.Map oldTracker)

protected static java.lang.String prettyPrintMethodList(java.util.List nodes)

protected java.util.Map pushAssignmentTracking()

protected void pushInstanceOfTypeInfo(Expression objectOfInstanceOf, Expression typeExpression)

Stores information about types when [objectOfInstanceof instanceof typeExpression] is visited

protected void restoreVariableExpressionMetadata(java.util.Map typesBeforeVisit)

protected void saveVariableExpressionMetadata(java.util.Set closureSharedExpressions, java.util.Map typesBeforeVisit)

void setMethodsToBeVisited(java.util.Set methodsToBeVisited)

protected boolean shouldSkipClassNode(ClassNode node)

protected boolean shouldSkipMethodNode(MethodNode node)

protected void silentlyVisitMethodNode(MethodNode directMethodCallCandidate)

protected void startMethodInference(MethodNode node, ErrorCollector collector)

protected void storeInferredTypeForPropertyExpression(PropertyExpression pexp, ClassNode flatInferredType)

protected void storeTargetMethod(Expression call, MethodNode directMethodCallCandidate)

protected void storeType(Expression exp, ClassNode cn)

protected void typeCheckAssignment(BinaryExpression assignmentExpression, Expression leftExpression, ClassNode leftExpressionType, Expression rightExpression, ClassNode inferredRightExpressionType)

protected void typeCheckClosureCall(Expression callArguments, ClassNode[] args, Parameter[] parameters)

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

protected boolean typeCheckMethodArgumentWithGenerics(ClassNode parameterType, ClassNode argumentType, boolean lastArg)

protected void typeCheckMethodsWithGenerics(ClassNode receiver, ClassNode[] arguments, MethodNode candidateMethod, Expression location)

void visitAttributeExpression(AttributeExpression expression)

void visitBinaryExpression(BinaryExpression expression)

void visitBitwiseNegationExpression(BitwiseNegationExpression expression)

void visitCastExpression(CastExpression expression)

void visitClass(ClassNode node)

void visitClassExpression(ClassExpression expression)

void visitClosureExpression(ClosureExpression expression)

void visitConstructorCallExpression(ConstructorCallExpression call)

protected void visitConstructorOrMethod(MethodNode node, boolean isConstructor)

void visitField(FieldNode node)

Given a loop collection type, returns the inferred type of the loop element.

void visitForLoop(ForStatement forLoop)

void visitIfElse(IfStatement ifElse)

void visitMethod(MethodNode node)

protected void visitMethodCallArguments(ArgumentListExpression arguments, boolean visitClosures, MethodNode selectedMethod)

void visitMethodCallExpression(MethodCallExpression call)

void visitPostfixExpression(PostfixExpression expression)

void visitPrefixExpression(PrefixExpression expression)

void visitPropertyExpression(PropertyExpression pexp)

void visitRangeExpression(RangeExpression expression)

void visitReturnStatement(ReturnStatement statement)

void visitStaticMethodCallExpression(StaticMethodCallExpression call)

void visitTernaryExpression(TernaryExpression expression)

void visitTryCatchFinally(TryCatchStatement statement)

void visitUnaryMinusExpression(UnaryMinusExpression expression)

void visitUnaryPlusExpression(UnaryPlusExpression expression)

void visitVariableExpression(VariableExpression vexp)

void visitWhileLoop(WhileStatement loop)

protected static ClassNode wrapTypeIfNecessary(ClassNode type)

 
Methods inherited from class ClassCodeVisitorSupport
visitMethod, visitField, visitProperty, visitConstructor, visitReturnStatement, visitBlockStatement, visitAnnotations, visitClass, visitPackage, visitDeclarationExpression, visitImports, visitBreakStatement, visitContinueStatement, visitTryCatchFinally, visitCatchStatement, visitIfElse, visitAssertStatement, visitCaseStatement, visitSynchronizedStatement, visitThrowStatement, visitSwitch, visitWhileLoop, visitForLoop, visitDoWhileLoop, visitExpressionStatement, visitPropertyExpression, visitClassExpression, visitListExpression, visitConstantExpression, visitMethodCallExpression, visitStaticMethodCallExpression, visitArrayExpression, visitMapExpression, visitMapEntryExpression, visitRangeExpression, visitSpreadExpression, visitSpreadMapExpression, visitMethodPointerExpression, visitUnaryMinusExpression, visitUnaryPlusExpression, visitBitwiseNegationExpression, visitCastExpression, visitVariableExpression, visitAttributeExpression, visitFieldExpression, visitGStringExpression, visitConstructorCallExpression, visitBinaryExpression, visitTernaryExpression, visitShortTernaryExpression, visitPostfixExpression, visitPrefixExpression, visitBooleanExpression, visitNotExpression, visitClosureExpression, visitTupleExpression, visitArgumentlistExpression, visitClosureListExpression, visitBytecodeExpression, wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 
Methods inherited from class CodeVisitorSupport
visitPropertyExpression, visitClassExpression, visitListExpression, visitReturnStatement, visitConstantExpression, visitBlockStatement, visitDeclarationExpression, visitBreakStatement, visitContinueStatement, visitTryCatchFinally, visitMethodCallExpression, visitStaticMethodCallExpression, visitArrayExpression, visitMapExpression, visitMapEntryExpression, visitRangeExpression, visitSpreadExpression, visitSpreadMapExpression, visitMethodPointerExpression, visitUnaryMinusExpression, visitUnaryPlusExpression, visitBitwiseNegationExpression, visitCastExpression, visitVariableExpression, visitAttributeExpression, visitFieldExpression, visitGStringExpression, visitConstructorCallExpression, visitBinaryExpression, visitTernaryExpression, visitShortTernaryExpression, visitPostfixExpression, visitPrefixExpression, visitBooleanExpression, visitNotExpression, visitClosureExpression, visitTupleExpression, visitCatchStatement, visitIfElse, visitAssertStatement, visitCaseStatement, visitSynchronizedStatement, visitThrowStatement, visitSwitch, visitWhileLoop, visitForLoop, visitDoWhileLoop, visitExpressionStatement, visitArgumentlistExpression, visitClosureListExpression, visitBytecodeExpression, wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

Field Detail

CLOSURE_CALL_NO_ARG

public static final MethodNode CLOSURE_CALL_NO_ARG


CLOSURE_CALL_ONE_ARG

public static final MethodNode CLOSURE_CALL_ONE_ARG


CLOSURE_CALL_VARGS

public static final MethodNode CLOSURE_CALL_VARGS


CURRENT_SIGNATURE_PROTOCOL

protected static final Expression CURRENT_SIGNATURE_PROTOCOL


CURRENT_SIGNATURE_PROTOCOL_VERSION

protected static final int CURRENT_SIGNATURE_PROTOCOL_VERSION


DELEGATES_TO

protected static final ClassNode DELEGATES_TO


DELEGATES_TO_TARGET

protected static final ClassNode DELEGATES_TO_TARGET


DGM_CLASSNODE

protected static final ClassNode DGM_CLASSNODE


EMPTY_METHODNODE_LIST

protected static final java.util.List EMPTY_METHODNODE_LIST


ERROR_COLLECTOR

protected static final java.lang.Object ERROR_COLLECTOR


GET_DELEGATE

protected static final MethodNode GET_DELEGATE


GET_OWNER

protected static final MethodNode GET_OWNER


GET_THISOBJECT

protected static final MethodNode GET_THISOBJECT


ITERABLE_TYPE

protected static final ClassNode ITERABLE_TYPE


TYPECHECKED_CLASSNODE

protected static final ClassNode TYPECHECKED_CLASSNODE


TYPECHECKING_ANNOTATIONS

protected static final ClassNode[] TYPECHECKING_ANNOTATIONS


TYPECHECKING_INFO_NODE

protected static final ClassNode TYPECHECKING_INFO_NODE


extension

protected DefaultTypeCheckingExtension extension


returnAdder

protected final ReturnAdder returnAdder


returnListener

protected final ReturnStatementListener returnListener


typeCheckingContext

protected TypeCheckingContext typeCheckingContext


 
Constructor Detail

StaticTypeCheckingVisitor

public StaticTypeCheckingVisitor(SourceUnit source, ClassNode cn)


 
Method Detail

addAmbiguousErrorMessage

protected void addAmbiguousErrorMessage(java.util.List foundMethods, java.lang.String name, ClassNode[] args, Expression expr)


addAssignmentError

protected void addAssignmentError(ClassNode leftType, ClassNode rightType, Expression assignmentExpression)


addCategoryMethodCallError

protected void addCategoryMethodCallError(Expression call)


addClosureReturnType

protected void addClosureReturnType(ClassNode returnType)


addError

protected void addError(java.lang.String msg, ASTNode expr)


addNoMatchingMethodError

protected void addNoMatchingMethodError(ClassNode receiver, java.lang.String name, ClassNode[] args, Expression call)


addReceivers

protected void addReceivers(java.util.List receivers, java.util.Collection owners, boolean implicitThis)


addStaticTypeError

protected void addStaticTypeError(java.lang.String msg, ASTNode expr)


addTypeCheckingExtension

public void addTypeCheckingExtension(TypeCheckingExtension extension)


addTypeCheckingInfoAnnotation

protected void addTypeCheckingInfoAnnotation(MethodNode node)


addUnsupportedPreOrPostfixExpressionError

protected void addUnsupportedPreOrPostfixExpressionError(Expression expression)


areCategoryMethodCalls

protected boolean areCategoryMethodCalls(java.util.List foundMethods, java.lang.String name, ClassNode[] args)


checkCast

protected boolean checkCast(ClassNode targetType, Expression source)


checkClosureParameters

protected void checkClosureParameters(Expression callArguments, ClassNode receiver)
visit a method call target, to infer the type. Don't report errors right away, that will be done by a later visitMethod call


checkForbiddenSpreadArgument

protected void checkForbiddenSpreadArgument(ArgumentListExpression argumentList)


checkGroovyConstructorMap

protected void checkGroovyConstructorMap(Expression receiver, ClassNode receiverType, MapExpression mapExpression)
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


checkGroovyStyleConstructor

protected void checkGroovyStyleConstructor(ClassNode node, ClassNode[] arguments)
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
checkForReadOnly - also lookup for read only properties
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


checkReturnType

protected ClassNode checkReturnType(ReturnStatement statement)


collectAllInterfaceMethodsByName

protected void collectAllInterfaceMethodsByName(ClassNode receiver, java.lang.String name, java.util.List methods)
If a method call returns a parameterized type, then we can perform additional inference on the return type, so that the type gets actual type parameters. For example, the method Arrays.asList(T...) is generified with type T which can be deduced from actual type arguments.
Parameters:
method - the method node
arguments - the method call arguments
Returns:
parameterized, infered, class node


existsProperty

protected boolean existsProperty(PropertyExpression pexp, boolean checkForReadOnly)


existsProperty

protected boolean existsProperty(PropertyExpression pexp, boolean checkForReadOnly, ClassCodeVisitorSupport visitor)


extractTemporaryTypeInfoKey

protected java.lang.Object extractTemporaryTypeInfoKey(Expression expression)


extractTypesFromParameters

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


findCurrentInstanceOfClass

protected ClassNode findCurrentInstanceOfClass(Expression expr, ClassNode type)


findMethod

protected java.util.List findMethod(ClassNode receiver, java.lang.String name, ClassNode... args)


findMethodOrFail

protected MethodNode findMethodOrFail(Expression expr, ClassNode receiver, java.lang.String name, ClassNode... args)


findMethodsWithGenerated

protected java.util.List findMethodsWithGenerated(ClassNode receiver, java.lang.String name)


formatArgumentList

protected static java.lang.String formatArgumentList(ClassNode[] nodes)
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.
Parameters:
type
Returns:
the wrapped type


fullyResolve

protected static GenericsType fullyResolve(GenericsType gt, java.util.Map placeholders)


fullyResolveType

protected static ClassNode fullyResolveType(ClassNode type, java.util.Map placeholders)


getArgumentTypes

protected ClassNode[] getArgumentTypes(ArgumentListExpression args)


getDelegationMetadata

protected DelegationMetadata getDelegationMetadata(ClosureExpression expression)


getGroupOperationResultType

protected static ClassNode getGroupOperationResultType(ClassNode a, ClassNode b)
This method returns the list of methods named against the supplied parameter that are defined on the specified receiver, but it will also add "non existing" methods that will be generated afterwards by the compiler, for example if a method is using default values and that the specified class node isn't compiled yet.
Parameters:
receiver - the receiver where to find methods
name - the name of the methods to return
Returns:
the methods that are defined on the receiver completed with stubs for future methods


getInferredReturnTypeFromWithClosureArgument

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, ie. a single closure expression
Returns:
the inferred closure return type or null


getOriginalDeclarationType

protected ClassNode getOriginalDeclarationType(Expression lhs)


getResultType

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


getSourceUnit

protected SourceUnit getSourceUnit()


getTemporaryTypesForExpression

protected java.util.List getTemporaryTypesForExpression(Expression objectExpression)


getType

protected ClassNode getType(ASTNode exp)


getTypeCheckingAnnotations

protected ClassNode[] getTypeCheckingAnnotations()


getTypeCheckingContext

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


hasRHSIncompleteGenericTypeInfo

protected static boolean hasRHSIncompleteGenericTypeInfo(ClassNode inferredRightExpressionType)
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 availble (due to instanceof checks) and whether there is a single candidate in that case.
Parameters:
expr - 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.


hasSetter

protected StaticTypeCheckingVisitor.SetterInfo hasSetter(PropertyExpression pexp)


inferComponentType

protected ClassNode inferComponentType(ClassNode containerType, ClassNode indexType)


inferDiamondType

protected void inferDiamondType(ConstructorCallExpression cce, ClassNode lType)


inferListExpressionType

protected ClassNode inferListExpressionType(ListExpression list)


inferLoopElementType

public static ClassNode inferLoopElementType(ClassNode collectionType)


inferMapExpressionType

protected ClassNode inferMapExpressionType(MapExpression map)


inferReturnTypeGenerics

protected ClassNode inferReturnTypeGenerics(ClassNode receiver, MethodNode method, Expression arguments)
Checks that the parameterized generics of an argument are compatible with the generics of the parameter.
Parameters:
parameterType - the parameter type of a method
argumentType - the type of the argument passed to the method


initialize

public void initialize()


isClassInnerClassOrEqualTo

protected static boolean isClassInnerClassOrEqualTo(ClassNode toBeChecked, ClassNode start)


isClosureCall

protected boolean isClosureCall(java.lang.String name, Expression objectExpression, Expression arguments)


isNullConstant

protected static boolean isNullConstant(Expression expression)
Given a generics type representing SomeClass<T,V> and a resolved placeholder map, returns a new generics type for which placeholders are resolved recursively.


isSecondPassNeededForControlStructure

protected boolean isSecondPassNeededForControlStructure(java.util.Map varOrigType, java.util.Map oldTracker)


isSkipMode

public boolean isSkipMode(AnnotatedNode node)


makeOwnerList

protected java.util.List makeOwnerList(Expression objectExpression)


performSecondPass

public void performSecondPass()


pickInferredTypeFromMethodAnnotation

protected void pickInferredTypeFromMethodAnnotation(MethodNode node)


popAssignmentTracking

protected java.util.Map popAssignmentTracking(java.util.Map oldTracker)


prettyPrintMethodList

protected static java.lang.String prettyPrintMethodList(java.util.List nodes)


pushAssignmentTracking

protected java.util.Map pushAssignmentTracking()


pushInstanceOfTypeInfo

protected void pushInstanceOfTypeInfo(Expression objectOfInstanceOf, Expression typeExpression)
Stores information about types when [objectOfInstanceof instanceof typeExpression] is visited
Parameters:
objectOfInstanceOf - the expression which must be checked against instanceof
typeExpression - the expression which represents the target type


restoreVariableExpressionMetadata

protected void restoreVariableExpressionMetadata(java.util.Map typesBeforeVisit)


saveVariableExpressionMetadata

protected void saveVariableExpressionMetadata(java.util.Set closureSharedExpressions, java.util.Map typesBeforeVisit)


setMethodsToBeVisited

public void setMethodsToBeVisited(java.util.Set methodsToBeVisited)


shouldSkipClassNode

protected boolean shouldSkipClassNode(ClassNode node)


shouldSkipMethodNode

protected boolean shouldSkipMethodNode(MethodNode node)


silentlyVisitMethodNode

protected void silentlyVisitMethodNode(MethodNode directMethodCallCandidate)


startMethodInference

protected void startMethodInference(MethodNode node, ErrorCollector collector)


storeInferredTypeForPropertyExpression

protected void storeInferredTypeForPropertyExpression(PropertyExpression pexp, ClassNode flatInferredType)


storeTargetMethod

protected void storeTargetMethod(Expression call, MethodNode directMethodCallCandidate)


storeType

protected void storeType(Expression exp, ClassNode cn)


typeCheckAssignment

protected void typeCheckAssignment(BinaryExpression assignmentExpression, Expression leftExpression, ClassNode leftExpressionType, Expression rightExpression, ClassNode inferredRightExpressionType)


typeCheckClosureCall

protected void typeCheckClosureCall(Expression callArguments, ClassNode[] args, Parameter[] parameters)


typeCheckMapConstructor

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


typeCheckMethodArgumentWithGenerics

protected boolean typeCheckMethodArgumentWithGenerics(ClassNode parameterType, ClassNode argumentType, boolean lastArg)


typeCheckMethodsWithGenerics

protected void typeCheckMethodsWithGenerics(ClassNode receiver, ClassNode[] arguments, MethodNode candidateMethod, Expression location)


visitAttributeExpression

if (Integer_TYPE.equals(fromType) && Integer_TYPE.equals(toType)) {
public void visitAttributeExpression(AttributeExpression expression)


visitBinaryExpression

VariableExpression ve = new VariableExpression("%", setterInfo.receiverType);
public void visitBinaryExpression(BinaryExpression expression)


visitBitwiseNegationExpression

if (node != null) {
public void visitBitwiseNegationExpression(BitwiseNegationExpression expression)


visitCastExpression

if (leftRedirect.implementsInterface(Collection_TYPE) && rightRedirect.implementsInterface(Collection_TYPE)) {
public void visitCastExpression(CastExpression expression)


visitClass

extension.afterVisitClass(node);
public void visitClass(ClassNode node)


visitClassExpression

public void visitClassExpression(ClassExpression expression)


visitClosureExpression

}
public void visitClosureExpression(ClosureExpression expression)


visitConstructorCallExpression

Statement code = expression.getCode();
public void visitConstructorCallExpression(ConstructorCallExpression call)


visitConstructorOrMethod

return;
protected void visitConstructorOrMethod(MethodNode node, boolean isConstructor)


visitField

ClassNode intf = GenericsUtils.parameterizeType(collectionType, ITERABLE_TYPE);
public void visitField(FieldNode node)
Given a loop collection type, returns the inferred type of the loop element. 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


visitForLoop

}
public void visitForLoop(ForStatement forLoop)


visitIfElse

// In that case, instead of storing the virtual type, we must "reset" type information
public void visitIfElse(IfStatement ifElse)


visitMethod

return;
public void visitMethod(MethodNode node)


visitMethodCallArguments

protected void visitMethodCallArguments(ArgumentListExpression arguments, boolean visitClosures, MethodNode selectedMethod)


visitMethodCallExpression

// we can get actual parameters directly
public void visitMethodCallExpression(MethodCallExpression call)


visitPostfixExpression

@Override
public void visitPostfixExpression(PostfixExpression expression)


visitPrefixExpression

} else if (!enclosingMethod.isVoidMethod()) {
public void visitPrefixExpression(PrefixExpression expression)


visitPropertyExpression

}
public void visitPropertyExpression(PropertyExpression pexp)


visitRangeExpression

typeCheckingContext.pushEnclosingBinaryExpression(expression);
public void visitRangeExpression(RangeExpression expression)


visitReturnStatement

public void visitReturnStatement(ReturnStatement statement)


visitStaticMethodCallExpression

if (callArguments instanceof ArgumentListExpression) {
public void visitStaticMethodCallExpression(StaticMethodCallExpression call)


visitTernaryExpression

return Matcher_TYPE;
public void visitTernaryExpression(TernaryExpression expression)


visitTryCatchFinally

return BigDecimal_TYPE;
public void visitTryCatchFinally(TryCatchStatement statement)


visitUnaryMinusExpression

resultType = type;
public void visitUnaryMinusExpression(UnaryMinusExpression expression)


visitUnaryPlusExpression

resultType = ArrayList_TYPE;
public void visitUnaryPlusExpression(UnaryPlusExpression expression)


visitVariableExpression

if (vexp.getName().equals("owner")
public void visitVariableExpression(VariableExpression vexp)


visitWhileLoop

ClassNode exprType = getType(inner);
public void visitWhileLoop(WhileStatement loop)


wrapTypeIfNecessary

protected static ClassNode wrapTypeIfNecessary(ClassNode type)


 

Groovy Documentation