Package org.codehaus.groovy.transform.tailrec

# Class ReturnAdderForClosures

java.lang.Object
org.codehaus.groovy.ast.CodeVisitorSupport
org.codehaus.groovy.transform.tailrec.ReturnAdderForClosures

All Implemented Interfaces:
  `GroovyCodeVisitor`

public class ReturnAdderForClosures extends CodeVisitorSupport
Adds explicit return statements to implicit return points in a closure. This is necessary since tail-recursion is detected by having the recursive call within the return statement.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ReturnAdderForClosures()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `visitClosureExpression(ClosureExpression expression)`
  Visits a `ClosureExpression`, traversing parameter initializers and the closure code block.
  `void`
  `visitMethod(MethodNode method)`
  Adds explicit return statements to closures contained in the supplied method.

  ### Methods inherited from class org.codehaus.groovy.ast.CodeVisitorSupport

  `afterSwitchCaseStatementsVisited, afterSwitchCaseStatementsVisited, afterSwitchConditionExpressionVisited, afterSwitchConditionExpressionVisited, visitArgumentlistExpression, visitArrayExpression, visitAssertStatement, visitAttributeExpression, visitBinaryExpression, visitBitwiseNegationExpression, visitBlockStatement, visitBooleanExpression, visitBreakStatement, visitBytecodeExpression, visitCaseStatement, visitCastExpression, visitCatchStatement, visitClassExpression, 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`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface org.codehaus.groovy.ast.GroovyCodeVisitor

  `visit, visit, visitEmptyExpression, visitListOfExpressions`

- ## Constructor Details

  - ### ReturnAdderForClosures

    public ReturnAdderForClosures()

- ## Method Details

  - ### visitMethod

    public void visitMethod(MethodNode method)
    Adds explicit return statements to closures contained in the supplied method.
    Parameters:
      `method` - the method whose closures should be normalized

  - ### visitClosureExpression

    public void visitClosureExpression(ClosureExpression expression)
    Visits a `ClosureExpression`, traversing parameter initializers and the closure code block.
    Specified by:
      `visitClosureExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitClosureExpression` in class `CodeVisitorSupport`
    Parameters:
      `expression` - the closure expression