================================================================================
objects/closure
================================================================================

function closeOverFunctionArg(x) = new Dynamic { value = x }

res1 = closeOverFunctionArg(4).value

hidden closeOverLambdaArg = (x) -> new Dynamic { value = x }

res2 = closeOverLambdaArg.apply(4).value

function closeOverFunctionAndLambdaArg(x) = (y) -> new Dynamic { value = y + x }

res3 = closeOverFunctionAndLambdaArg(4).apply(5).value

hidden closeOverTwoLambdaArgs = (x) -> (y) -> new Dynamic { value = y + x }

res4 = closeOverTwoLambdaArgs.apply(4).apply(5).value

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

(module
  (classMethod
    (methodHeader
      (identifier)
      (parameterList
        (typedIdentifier
          (identifier))))
    (newExpr
      (type
        (qualifiedIdentifier
          (identifier)))
      (objectBody
        (objectProperty
          (identifier)
          (variableExpr
            (identifier))))))
  (classProperty
    (identifier)
    (propertyCallExpr
      (methodCallExpr
        (identifier)
        (argumentList
          (intLiteral)))
      (identifier)))
  (classProperty
    (modifier)
    (identifier)
    (functionLiteral
      (parameterList
        (typedIdentifier
          (identifier)))
      (newExpr
        (type
          (qualifiedIdentifier
            (identifier)))
        (objectBody
          (objectProperty
            (identifier)
            (variableExpr
              (identifier)))))))
  (classProperty
    (identifier)
    (propertyCallExpr
      (methodCallExpr
        (variableExpr
          (identifier))
        (identifier)
        (argumentList
          (intLiteral)))
      (identifier)))
  (classMethod
    (methodHeader
      (identifier)
      (parameterList
        (typedIdentifier
          (identifier))))
    (functionLiteral
      (parameterList
        (typedIdentifier
          (identifier)))
      (newExpr
        (type
          (qualifiedIdentifier
            (identifier)))
        (objectBody
          (objectProperty
            (identifier)
            (binaryExpr
              (variableExpr
                (identifier))
              (variableExpr
                (identifier))))))))
  (classProperty
    (identifier)
    (propertyCallExpr
      (methodCallExpr
        (methodCallExpr
          (identifier)
          (argumentList
            (intLiteral)))
        (identifier)
        (argumentList
          (intLiteral)))
      (identifier)))
  (classProperty
    (modifier)
    (identifier)
    (functionLiteral
      (parameterList
        (typedIdentifier
          (identifier)))
      (functionLiteral
        (parameterList
          (typedIdentifier
            (identifier)))
        (newExpr
          (type
            (qualifiedIdentifier
              (identifier)))
          (objectBody
            (objectProperty
              (identifier)
              (binaryExpr
                (variableExpr
                  (identifier))
                (variableExpr
                  (identifier)))))))))
  (classProperty
    (identifier)
    (propertyCallExpr
      (methodCallExpr
        (methodCallExpr
          (variableExpr
            (identifier))
          (identifier)
          (argumentList
            (intLiteral)))
        (identifier)
        (argumentList
          (intLiteral)))
      (identifier))))
