================================================================================
lambdas/amendLambdaParametersTyped
================================================================================

import "pkl:test"

example1 {
  local f = (x) -> new Dynamic {}
  result = (f) { x: Int -> prop = x + 1 }.apply(1)
}

example2 {
  local f = (x, y) -> new Dynamic {}
  result = (f) { a, b: Number -> prop = a + b }.apply(1, 2)
}

example3 {
  local f = (x, y) -> new Dynamic {}
  result = test.catch(() -> (f) { a, b: Number(this > 3) -> prop = a + b }.apply(1, 2))
}

example4 {
  local f = (x, y) -> (z) -> new Dynamic { prop3 = z }
  result = test.catch(() -> (f) { a: String, b -> prop1 = a; prop2 = b }.apply(1, 2).apply(3))
}

class Foo
class Bar
class Baz

example5 {
  local f = (x, y, z) -> new Dynamic { prop3 = z }
  result = (f) { a: Foo, b: Bar, c: Baz -> prop1 = a; prop2 = b }.apply(new Foo {}, new Bar {}, new Baz {})
}

example6 {
  local f = (x, y, z) -> new Dynamic { prop3 = z }
  result = test.catch(() -> (f) { a: Baz, b: Bar, c: Foo -> prop1 = a; prop2 = b }.apply(new Foo {}, new Bar {}, new Baz {}))
}

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

(module
  (importClause
    (stringConstant))
  (classProperty
    (identifier)
    (objectBody
      (objectProperty
        (modifier)
        (identifier)
        (functionLiteral
          (parameterList
            (typedIdentifier
              (identifier)))
          (newExpr
            (type
              (qualifiedIdentifier
                (identifier)))
            (objectBody))))
      (objectProperty
        (identifier)
        (methodCallExpr
          (objectLiteral
            (parenthesizedExpr
              (variableExpr
                (identifier)))
            (objectBody
              (objectBodyParameters
                (typedIdentifier
                  (identifier)
                  (typeAnnotation
                    (type
                      (qualifiedIdentifier
                        (identifier))))))
              (objectProperty
                (identifier)
                (binaryExpr
                  (variableExpr
                    (identifier))
                  (intLiteral)))))
          (identifier)
          (argumentList
            (intLiteral))))))
  (classProperty
    (identifier)
    (objectBody
      (objectProperty
        (modifier)
        (identifier)
        (functionLiteral
          (parameterList
            (typedIdentifier
              (identifier))
            (typedIdentifier
              (identifier)))
          (newExpr
            (type
              (qualifiedIdentifier
                (identifier)))
            (objectBody))))
      (objectProperty
        (identifier)
        (methodCallExpr
          (objectLiteral
            (parenthesizedExpr
              (variableExpr
                (identifier)))
            (objectBody
              (objectBodyParameters
                (typedIdentifier
                  (identifier))
                (typedIdentifier
                  (identifier)
                  (typeAnnotation
                    (type
                      (qualifiedIdentifier
                        (identifier))))))
              (objectProperty
                (identifier)
                (binaryExpr
                  (variableExpr
                    (identifier))
                  (variableExpr
                    (identifier))))))
          (identifier)
          (argumentList
            (intLiteral)
            (intLiteral))))))
  (classProperty
    (identifier)
    (objectBody
      (objectProperty
        (modifier)
        (identifier)
        (functionLiteral
          (parameterList
            (typedIdentifier
              (identifier))
            (typedIdentifier
              (identifier)))
          (newExpr
            (type
              (qualifiedIdentifier
                (identifier)))
            (objectBody))))
      (objectProperty
        (identifier)
        (methodCallExpr
          (variableExpr
            (identifier))
          (identifier)
          (argumentList
            (functionLiteral
              (parameterList)
              (methodCallExpr
                (objectLiteral
                  (parenthesizedExpr
                    (variableExpr
                      (identifier)))
                  (objectBody
                    (objectBodyParameters
                      (typedIdentifier
                        (identifier))
                      (typedIdentifier
                        (identifier)
                        (typeAnnotation
                          (type
                            (type
                              (qualifiedIdentifier
                                (identifier)))
                            (binaryExpr
                              (thisExpr)
                              (intLiteral))))))
                    (objectProperty
                      (identifier)
                      (binaryExpr
                        (variableExpr
                          (identifier))
                        (variableExpr
                          (identifier))))))
                (identifier)
                (argumentList
                  (intLiteral)
                  (intLiteral)))))))))
  (classProperty
    (identifier)
    (objectBody
      (objectProperty
        (modifier)
        (identifier)
        (functionLiteral
          (parameterList
            (typedIdentifier
              (identifier))
            (typedIdentifier
              (identifier)))
          (functionLiteral
            (parameterList
              (typedIdentifier
                (identifier)))
            (newExpr
              (type
                (qualifiedIdentifier
                  (identifier)))
              (objectBody
                (objectProperty
                  (identifier)
                  (variableExpr
                    (identifier))))))))
      (objectProperty
        (identifier)
        (methodCallExpr
          (variableExpr
            (identifier))
          (identifier)
          (argumentList
            (functionLiteral
              (parameterList)
              (methodCallExpr
                (methodCallExpr
                  (objectLiteral
                    (parenthesizedExpr
                      (variableExpr
                        (identifier)))
                    (objectBody
                      (objectBodyParameters
                        (typedIdentifier
                          (identifier)
                          (typeAnnotation
                            (type
                              (qualifiedIdentifier
                                (identifier)))))
                        (typedIdentifier
                          (identifier)))
                      (objectProperty
                        (identifier)
                        (variableExpr
                          (identifier)))
                      (objectProperty
                        (identifier)
                        (variableExpr
                          (identifier)))))
                  (identifier)
                  (argumentList
                    (intLiteral)
                    (intLiteral)))
                (identifier)
                (argumentList
                  (intLiteral)))))))))
  (clazz
    (identifier))
  (clazz
    (identifier))
  (clazz
    (identifier))
  (classProperty
    (identifier)
    (objectBody
      (objectProperty
        (modifier)
        (identifier)
        (functionLiteral
          (parameterList
            (typedIdentifier
              (identifier))
            (typedIdentifier
              (identifier))
            (typedIdentifier
              (identifier)))
          (newExpr
            (type
              (qualifiedIdentifier
                (identifier)))
            (objectBody
              (objectProperty
                (identifier)
                (variableExpr
                  (identifier)))))))
      (objectProperty
        (identifier)
        (methodCallExpr
          (objectLiteral
            (parenthesizedExpr
              (variableExpr
                (identifier)))
            (objectBody
              (objectBodyParameters
                (typedIdentifier
                  (identifier)
                  (typeAnnotation
                    (type
                      (qualifiedIdentifier
                        (identifier)))))
                (typedIdentifier
                  (identifier)
                  (typeAnnotation
                    (type
                      (qualifiedIdentifier
                        (identifier)))))
                (typedIdentifier
                  (identifier)
                  (typeAnnotation
                    (type
                      (qualifiedIdentifier
                        (identifier))))))
              (objectProperty
                (identifier)
                (variableExpr
                  (identifier)))
              (objectProperty
                (identifier)
                (variableExpr
                  (identifier)))))
          (identifier)
          (argumentList
            (newExpr
              (type
                (qualifiedIdentifier
                  (identifier)))
              (objectBody))
            (newExpr
              (type
                (qualifiedIdentifier
                  (identifier)))
              (objectBody))
            (newExpr
              (type
                (qualifiedIdentifier
                  (identifier)))
              (objectBody)))))))
  (classProperty
    (identifier)
    (objectBody
      (objectProperty
        (modifier)
        (identifier)
        (functionLiteral
          (parameterList
            (typedIdentifier
              (identifier))
            (typedIdentifier
              (identifier))
            (typedIdentifier
              (identifier)))
          (newExpr
            (type
              (qualifiedIdentifier
                (identifier)))
            (objectBody
              (objectProperty
                (identifier)
                (variableExpr
                  (identifier)))))))
      (objectProperty
        (identifier)
        (methodCallExpr
          (variableExpr
            (identifier))
          (identifier)
          (argumentList
            (functionLiteral
              (parameterList)
              (methodCallExpr
                (objectLiteral
                  (parenthesizedExpr
                    (variableExpr
                      (identifier)))
                  (objectBody
                    (objectBodyParameters
                      (typedIdentifier
                        (identifier)
                        (typeAnnotation
                          (type
                            (qualifiedIdentifier
                              (identifier)))))
                      (typedIdentifier
                        (identifier)
                        (typeAnnotation
                          (type
                            (qualifiedIdentifier
                              (identifier)))))
                      (typedIdentifier
                        (identifier)
                        (typeAnnotation
                          (type
                            (qualifiedIdentifier
                              (identifier))))))
                    (objectProperty
                      (identifier)
                      (variableExpr
                        (identifier)))
                    (objectProperty
                      (identifier)
                      (variableExpr
                        (identifier)))))
                (identifier)
                (argumentList
                  (newExpr
                    (type
                      (qualifiedIdentifier
                        (identifier)))
                    (objectBody))
                  (newExpr
                    (type
                      (qualifiedIdentifier
                        (identifier)))
                    (objectBody))
                  (newExpr
                    (type
                      (qualifiedIdentifier
                        (identifier)))
                    (objectBody)))))))))))
