================================================================================
lambdas/amendLambdaThatReturnsAnotherLambda
================================================================================

example1 {
  local f1 = () -> () -> () -> new Dynamic {}
  local f2 = (f1) { name = "Pigeon" }
  result = f2.apply().apply().apply()
}

example2 {
  local default1 = new Dynamic { name = "Pigeon" }
  local default2 = (name) -> (default1) { name2 = name }
  local default3 = (name) -> (default2) { name3 = name }
  local default4 = (name) -> (default3) { name4 = name }
  result = default4.apply("Pigeon4").apply("Pigeon3").apply("Pigeon2")
}

example3 {
  local f1 = () -> new Dynamic { f1Args = List() }
  local f2 = (arg1) -> (f1) { f2Args = List(arg1) }
  local f3 = (arg1, arg2) -> (f2) { f3Args = List(arg1, arg2) }
  result1 = f3.apply("f3Arg1", "f3Arg2").apply("f2Arg1").apply()
  result2 = f3.apply(42, 5.gb).apply(3.min).apply()
  result3 = f3.apply(new Dynamic { x = 42 }, new Dynamic { y = 5.gb }).apply(new Dynamic { z = 3.min }).apply()
}

example4 {
  local f1 = (arg1, arg2) -> new Dynamic { f1Args = List(arg1, arg2) }
  local f2 = (arg1) -> (f1) { f2Args = List(arg1) }
  local f3 = () -> (f2) { f3Args = List() }
  result = f3.apply().apply("f2Arg1").apply("f1Arg1", "f1Arg2")
}

--------------------------------------------------------------------------------

(module
  (classProperty
    (identifier)
    (objectBody
      (objectProperty
        (modifier)
        (identifier)
        (functionLiteral
          (parameterList)
          (functionLiteral
            (parameterList)
            (functionLiteral
              (parameterList)
              (newExpr
                (type
                  (qualifiedIdentifier
                    (identifier)))
                (objectBody))))))
      (objectProperty
        (modifier)
        (identifier)
        (objectLiteral
          (parenthesizedExpr
            (variableExpr
              (identifier)))
          (objectBody
            (objectProperty
              (identifier)
              (slStringLiteral)))))
      (objectProperty
        (identifier)
        (methodCallExpr
          (methodCallExpr
            (methodCallExpr
              (variableExpr
                (identifier))
              (identifier)
              (argumentList))
            (identifier)
            (argumentList))
          (identifier)
          (argumentList)))))
  (classProperty
    (identifier)
    (objectBody
      (objectProperty
        (modifier)
        (identifier)
        (newExpr
          (type
            (qualifiedIdentifier
              (identifier)))
          (objectBody
            (objectProperty
              (identifier)
              (slStringLiteral)))))
      (objectProperty
        (modifier)
        (identifier)
        (functionLiteral
          (parameterList
            (typedIdentifier
              (identifier)))
          (objectLiteral
            (parenthesizedExpr
              (variableExpr
                (identifier)))
            (objectBody
              (objectProperty
                (identifier)
                (variableExpr
                  (identifier)))))))
      (objectProperty
        (modifier)
        (identifier)
        (functionLiteral
          (parameterList
            (typedIdentifier
              (identifier)))
          (objectLiteral
            (parenthesizedExpr
              (variableExpr
                (identifier)))
            (objectBody
              (objectProperty
                (identifier)
                (variableExpr
                  (identifier)))))))
      (objectProperty
        (modifier)
        (identifier)
        (functionLiteral
          (parameterList
            (typedIdentifier
              (identifier)))
          (objectLiteral
            (parenthesizedExpr
              (variableExpr
                (identifier)))
            (objectBody
              (objectProperty
                (identifier)
                (variableExpr
                  (identifier)))))))
      (objectProperty
        (identifier)
        (methodCallExpr
          (methodCallExpr
            (methodCallExpr
              (variableExpr
                (identifier))
              (identifier)
              (argumentList
                (slStringLiteral)))
            (identifier)
            (argumentList
              (slStringLiteral)))
          (identifier)
          (argumentList
            (slStringLiteral))))))
  (classProperty
    (identifier)
    (objectBody
      (objectProperty
        (modifier)
        (identifier)
        (functionLiteral
          (parameterList)
          (newExpr
            (type
              (qualifiedIdentifier
                (identifier)))
            (objectBody
              (objectProperty
                (identifier)
                (methodCallExpr
                  (identifier)
                  (argumentList)))))))
      (objectProperty
        (modifier)
        (identifier)
        (functionLiteral
          (parameterList
            (typedIdentifier
              (identifier)))
          (objectLiteral
            (parenthesizedExpr
              (variableExpr
                (identifier)))
            (objectBody
              (objectProperty
                (identifier)
                (methodCallExpr
                  (identifier)
                  (argumentList
                    (variableExpr
                      (identifier)))))))))
      (objectProperty
        (modifier)
        (identifier)
        (functionLiteral
          (parameterList
            (typedIdentifier
              (identifier))
            (typedIdentifier
              (identifier)))
          (objectLiteral
            (parenthesizedExpr
              (variableExpr
                (identifier)))
            (objectBody
              (objectProperty
                (identifier)
                (methodCallExpr
                  (identifier)
                  (argumentList
                    (variableExpr
                      (identifier))
                    (variableExpr
                      (identifier)))))))))
      (objectProperty
        (identifier)
        (methodCallExpr
          (methodCallExpr
            (methodCallExpr
              (variableExpr
                (identifier))
              (identifier)
              (argumentList
                (slStringLiteral)
                (slStringLiteral)))
            (identifier)
            (argumentList
              (slStringLiteral)))
          (identifier)
          (argumentList)))
      (objectProperty
        (identifier)
        (methodCallExpr
          (methodCallExpr
            (methodCallExpr
              (variableExpr
                (identifier))
              (identifier)
              (argumentList
                (intLiteral)
                (propertyCallExpr
                  (intLiteral)
                  (identifier))))
            (identifier)
            (argumentList
              (propertyCallExpr
                (intLiteral)
                (identifier))))
          (identifier)
          (argumentList)))
      (objectProperty
        (identifier)
        (methodCallExpr
          (methodCallExpr
            (methodCallExpr
              (variableExpr
                (identifier))
              (identifier)
              (argumentList
                (newExpr
                  (type
                    (qualifiedIdentifier
                      (identifier)))
                  (objectBody
                    (objectProperty
                      (identifier)
                      (intLiteral))))
                (newExpr
                  (type
                    (qualifiedIdentifier
                      (identifier)))
                  (objectBody
                    (objectProperty
                      (identifier)
                      (propertyCallExpr
                        (intLiteral)
                        (identifier)))))))
            (identifier)
            (argumentList
              (newExpr
                (type
                  (qualifiedIdentifier
                    (identifier)))
                (objectBody
                  (objectProperty
                    (identifier)
                    (propertyCallExpr
                      (intLiteral)
                      (identifier)))))))
          (identifier)
          (argumentList)))))
  (classProperty
    (identifier)
    (objectBody
      (objectProperty
        (modifier)
        (identifier)
        (functionLiteral
          (parameterList
            (typedIdentifier
              (identifier))
            (typedIdentifier
              (identifier)))
          (newExpr
            (type
              (qualifiedIdentifier
                (identifier)))
            (objectBody
              (objectProperty
                (identifier)
                (methodCallExpr
                  (identifier)
                  (argumentList
                    (variableExpr
                      (identifier))
                    (variableExpr
                      (identifier)))))))))
      (objectProperty
        (modifier)
        (identifier)
        (functionLiteral
          (parameterList
            (typedIdentifier
              (identifier)))
          (objectLiteral
            (parenthesizedExpr
              (variableExpr
                (identifier)))
            (objectBody
              (objectProperty
                (identifier)
                (methodCallExpr
                  (identifier)
                  (argumentList
                    (variableExpr
                      (identifier)))))))))
      (objectProperty
        (modifier)
        (identifier)
        (functionLiteral
          (parameterList)
          (objectLiteral
            (parenthesizedExpr
              (variableExpr
                (identifier)))
            (objectBody
              (objectProperty
                (identifier)
                (methodCallExpr
                  (identifier)
                  (argumentList)))))))
      (objectProperty
        (identifier)
        (methodCallExpr
          (methodCallExpr
            (methodCallExpr
              (variableExpr
                (identifier))
              (identifier)
              (argumentList))
            (identifier)
            (argumentList
              (slStringLiteral)))
          (identifier)
          (argumentList
            (slStringLiteral)
            (slStringLiteral)))))))
