Class TypeCheckingContext


  • public class TypeCheckingContext
    extends java.lang.Object
    • Field Detail

      • methodsToBeVisited

        protected java.util.Set<MethodNode> methodsToBeVisited
      • isInStaticContext

        protected boolean isInStaticContext
      • errorCollectors

        protected final java.util.LinkedList<ErrorCollector> errorCollectors
      • enclosingClassNodes

        protected final java.util.LinkedList<ClassNode> enclosingClassNodes
      • enclosingMethods

        protected final java.util.LinkedList<MethodNode> enclosingMethods
      • enclosingMethodCalls

        protected final java.util.LinkedList<Expression> enclosingMethodCalls
      • delegationMetadata

        protected org.codehaus.groovy.transform.stc.DelegationMetadata delegationMetadata
      • lastImplicitItType

        protected ClassNode lastImplicitItType
        The type of the last encountered "it" implicit parameter
      • ifElseForWhileAssignmentTracker

        protected java.util.Map<VariableExpression,​java.util.List<ClassNode>> ifElseForWhileAssignmentTracker
        This field is used to track assignments in if/else branches, for loops and while loops. For example, in the following code: if (cond) { x = 1 } else { x = '123' } the inferred type of x after the if/else statement should be the LUB of (int, String)
      • temporaryIfBranchTypeInformation

        protected java.util.Stack<java.util.Map<java.lang.Object,​java.util.List<ClassNode>>> temporaryIfBranchTypeInformation
        Stores information which is only valid in the "if" branch of an if-then-else statement. This is used when the if condition expression makes use of an instanceof check
      • alreadyVisitedMethods

        protected java.util.Set<MethodNode> alreadyVisitedMethods
      • secondPassExpressions

        protected final java.util.LinkedHashSet<org.codehaus.groovy.transform.stc.SecondPassExpression> secondPassExpressions
        Some expressions need to be visited twice, because type information may be insufficient at some point. For example, for closure shared variables, we need a first pass to collect every type which is assigned to a closure shared variable, then a second pass to ensure that every method call on such a variable is made on a LUB.
      • closureSharedVariablesAssignmentTypes

        protected final java.util.Map<VariableExpression,​java.util.List<ClassNode>> closureSharedVariablesAssignmentTypes
        A map used to store every type used in closure shared variable assignments. In a second pass, we will compute the LUB of each type and check that method calls on those variables are valid.
      • controlStructureVariables

        protected java.util.Map<Parameter,​ClassNode> controlStructureVariables
      • reportedErrors

        protected final java.util.Set<java.lang.Long> reportedErrors
      • enclosingBinaryExpressions

        protected final java.util.LinkedList<BinaryExpression> enclosingBinaryExpressions
    • Method Detail

      • pushEnclosingBinaryExpression

        public void pushEnclosingBinaryExpression​(BinaryExpression binaryExpression)
        Pushes a binary expression into the binary expression stack.
        Parameters:
        binaryExpression - the binary expression to be pushed
      • popEnclosingBinaryExpression

        public BinaryExpression popEnclosingBinaryExpression()
        Pops a binary expression from the binary expression stack.
        Returns:
        the popped binary expression
      • getEnclosingBinaryExpression

        public BinaryExpression getEnclosingBinaryExpression()
        Returns the binary expression which is on the top of the stack, or null if there's no such element.
        Returns:
        the binary expression on top of the stack, or null if no such element.
      • getEnclosingBinaryExpressionStack

        public java.util.List<BinaryExpression> getEnclosingBinaryExpressionStack()
        Returns the current stack of enclosing binary expressions. The first element is the top of the stack.
        Returns:
        an immutable list of binary expressions.
      • pushEnclosingClosureExpression

        public void pushEnclosingClosureExpression​(ClosureExpression closureExpression)
        Pushes a closure expression into the closure expression stack.
        Parameters:
        closureExpression - the closure expression to be pushed
      • popEnclosingClosure

        public TypeCheckingContext.EnclosingClosure popEnclosingClosure()
        Pops a closure expression from the closure expression stack.
        Returns:
        the popped closure expression
      • getEnclosingClosure

        public TypeCheckingContext.EnclosingClosure getEnclosingClosure()
        Returns the closure expression which is on the top of the stack, or null if there's no such element.
        Returns:
        the closure expression on top of the stack, or null if no such element.
      • getEnclosingClosureStack

        public java.util.List<TypeCheckingContext.EnclosingClosure> getEnclosingClosureStack()
        Returns the current stack of enclosing closure expressions. The first element is the top of the stack.
        Returns:
        an immutable list of closure expressions.
      • pushEnclosingMethod

        public void pushEnclosingMethod​(MethodNode methodNode)
        Pushes a method into the method stack.
        Parameters:
        methodNode - the method to be pushed
      • popEnclosingMethod

        public MethodNode popEnclosingMethod()
        Pops a method from the enclosing methods stack.
        Returns:
        the popped method
      • getEnclosingMethod

        public MethodNode getEnclosingMethod()
        Returns the method node which is on the top of the stack, or null if there's no such element.
        Returns:
        the enclosing method on top of the stack, or null if no such element.
      • getEnclosingMethods

        public java.util.List<MethodNode> getEnclosingMethods()
        Returns the current stack of enclosing methods. The first element is the top of the stack, that is to say the last visited method.
        Returns:
        an immutable list of method nodes.
      • pushEnclosingClassNode

        public void pushEnclosingClassNode​(ClassNode classNode)
        Pushes a class into the classes stack.
        Parameters:
        classNode - the class to be pushed
      • popEnclosingClassNode

        public ClassNode popEnclosingClassNode()
        Pops a class from the enclosing classes stack.
        Returns:
        the popped class
      • getEnclosingClassNode

        public ClassNode getEnclosingClassNode()
        Returns the class node which is on the top of the stack, or null if there's no such element.
        Returns:
        the enclosing class on top of the stack, or null if no such element.
      • getEnclosingClassNodes

        public java.util.List<ClassNode> getEnclosingClassNodes()
        Returns the current stack of enclosing classes. The first element is the top of the stack, that is to say the currently visited class.
        Returns:
        an immutable list of class nodes.
      • pushTemporaryTypeInfo

        public void pushTemporaryTypeInfo()
      • popTemporaryTypeInfo

        public void popTemporaryTypeInfo()
      • popEnclosingMethodCall

        public Expression popEnclosingMethodCall()
        Pops a method call from the enclosing method call stack.
        Returns:
        the popped call
      • getEnclosingMethodCall

        public Expression getEnclosingMethodCall()
        Returns the method call which is on the top of the stack, or null if there's no such element.
        Returns:
        the enclosing method call on top of the stack, or null if no such element.
      • getEnclosingMethodCalls

        public java.util.List<Expression> getEnclosingMethodCalls()
        Returns the current stack of enclosing classes. The first element is the top of the stack, that is to say the currently visited class.
        Returns:
        an immutable list of class nodes.
      • getErrorCollectors

        public java.util.List<ErrorCollector> getErrorCollectors()
      • pushErrorCollector

        public void pushErrorCollector​(ErrorCollector collector)
      • setCompilationUnit

        public void setCompilationUnit​(CompilationUnit compilationUnit)