================================================================================
methods/methodParameterConstraints2
================================================================================

import "pkl:test"

class X {
  function int(int: Int(isPositive)) = int
  function l(l: List<String(!isEmpty)>(!isEmpty)) = l
  function map(map: Map<String(!isEmpty), Int(isPositive)>(!isEmpty)) = map
  function optional(optional: String(!isEmpty)?) = optional
}

class Y {
  function int(int): Int(isPositive) = int
  function l(l): List<String(!isEmpty)>(!isEmpty) = l
  function map(map): Map<String(!isEmpty), Int(isPositive)>(!isEmpty) = map
  function optional(optional): String(!isEmpty)? = optional
}

local x = new X {}
res1 = test.catch(() -> x.int(-3))
res2 = test.catch(() -> x.l(List("1", "")))
res3 = test.catch(() -> x.map(Map("1", 1, "2", -2)))
res4 = test.catch(() -> x.optional(""))

local y = new Y {}
res5 = test.catch(() -> y.int(-3))
res6 = test.catch(() -> y.l(List("1", "")))
res7 = test.catch(() -> y.map(Map("1", 1, "2", -2)))
res8 = test.catch(() -> y.optional(""))

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

(module
  (importClause
    (stringConstant))
  (clazz
    (identifier)
    (classBody
      (classMethod
        (methodHeader
          (identifier)
          (parameterList
            (typedIdentifier
              (identifier)
              (typeAnnotation
                (type
                  (type
                    (qualifiedIdentifier
                      (identifier)))
                  (variableExpr
                    (identifier)))))))
        (variableExpr
          (identifier)))
      (classMethod
        (methodHeader
          (identifier)
          (parameterList
            (typedIdentifier
              (identifier)
              (typeAnnotation
                (type
                  (type
                    (qualifiedIdentifier
                      (identifier))
                    (typeArgumentList
                      (type
                        (type
                          (qualifiedIdentifier
                            (identifier)))
                        (unaryExpr
                          (variableExpr
                            (identifier))))))
                  (unaryExpr
                    (variableExpr
                      (identifier))))))))
        (variableExpr
          (identifier)))
      (classMethod
        (methodHeader
          (identifier)
          (parameterList
            (typedIdentifier
              (identifier)
              (typeAnnotation
                (type
                  (type
                    (qualifiedIdentifier
                      (identifier))
                    (typeArgumentList
                      (type
                        (type
                          (qualifiedIdentifier
                            (identifier)))
                        (unaryExpr
                          (variableExpr
                            (identifier))))
                      (type
                        (type
                          (qualifiedIdentifier
                            (identifier)))
                        (variableExpr
                          (identifier)))))
                  (unaryExpr
                    (variableExpr
                      (identifier))))))))
        (variableExpr
          (identifier)))
      (classMethod
        (methodHeader
          (identifier)
          (parameterList
            (typedIdentifier
              (identifier)
              (typeAnnotation
                (type
                  (type
                    (type
                      (qualifiedIdentifier
                        (identifier)))
                    (unaryExpr
                      (variableExpr
                        (identifier)))))))))
        (variableExpr
          (identifier)))))
  (clazz
    (identifier)
    (classBody
      (classMethod
        (methodHeader
          (identifier)
          (parameterList
            (typedIdentifier
              (identifier)))
          (typeAnnotation
            (type
              (type
                (qualifiedIdentifier
                  (identifier)))
              (variableExpr
                (identifier)))))
        (variableExpr
          (identifier)))
      (classMethod
        (methodHeader
          (identifier)
          (parameterList
            (typedIdentifier
              (identifier)))
          (typeAnnotation
            (type
              (type
                (qualifiedIdentifier
                  (identifier))
                (typeArgumentList
                  (type
                    (type
                      (qualifiedIdentifier
                        (identifier)))
                    (unaryExpr
                      (variableExpr
                        (identifier))))))
              (unaryExpr
                (variableExpr
                  (identifier))))))
        (variableExpr
          (identifier)))
      (classMethod
        (methodHeader
          (identifier)
          (parameterList
            (typedIdentifier
              (identifier)))
          (typeAnnotation
            (type
              (type
                (qualifiedIdentifier
                  (identifier))
                (typeArgumentList
                  (type
                    (type
                      (qualifiedIdentifier
                        (identifier)))
                    (unaryExpr
                      (variableExpr
                        (identifier))))
                  (type
                    (type
                      (qualifiedIdentifier
                        (identifier)))
                    (variableExpr
                      (identifier)))))
              (unaryExpr
                (variableExpr
                  (identifier))))))
        (variableExpr
          (identifier)))
      (classMethod
        (methodHeader
          (identifier)
          (parameterList
            (typedIdentifier
              (identifier)))
          (typeAnnotation
            (type
              (type
                (type
                  (qualifiedIdentifier
                    (identifier)))
                (unaryExpr
                  (variableExpr
                    (identifier)))))))
        (variableExpr
          (identifier)))))
  (classProperty
    (modifier)
    (identifier)
    (newExpr
      (type
        (qualifiedIdentifier
          (identifier)))
      (objectBody)))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (functionLiteral
          (parameterList)
          (methodCallExpr
            (variableExpr
              (identifier))
            (identifier)
            (argumentList
              (unaryExpr
                (intLiteral))))))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (functionLiteral
          (parameterList)
          (methodCallExpr
            (variableExpr
              (identifier))
            (identifier)
            (argumentList
              (methodCallExpr
                (identifier)
                (argumentList
                  (slStringLiteral)
                  (slStringLiteral)))))))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (functionLiteral
          (parameterList)
          (methodCallExpr
            (variableExpr
              (identifier))
            (identifier)
            (argumentList
              (methodCallExpr
                (identifier)
                (argumentList
                  (slStringLiteral)
                  (intLiteral)
                  (slStringLiteral)
                  (unaryExpr
                    (intLiteral))))))))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (functionLiteral
          (parameterList)
          (methodCallExpr
            (variableExpr
              (identifier))
            (identifier)
            (argumentList
              (slStringLiteral)))))))
  (classProperty
    (modifier)
    (identifier)
    (newExpr
      (type
        (qualifiedIdentifier
          (identifier)))
      (objectBody)))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (functionLiteral
          (parameterList)
          (methodCallExpr
            (variableExpr
              (identifier))
            (identifier)
            (argumentList
              (unaryExpr
                (intLiteral))))))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (functionLiteral
          (parameterList)
          (methodCallExpr
            (variableExpr
              (identifier))
            (identifier)
            (argumentList
              (methodCallExpr
                (identifier)
                (argumentList
                  (slStringLiteral)
                  (slStringLiteral)))))))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (functionLiteral
          (parameterList)
          (methodCallExpr
            (variableExpr
              (identifier))
            (identifier)
            (argumentList
              (methodCallExpr
                (identifier)
                (argumentList
                  (slStringLiteral)
                  (intLiteral)
                  (slStringLiteral)
                  (unaryExpr
                    (intLiteral))))))))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (functionLiteral
          (parameterList)
          (methodCallExpr
            (variableExpr
              (identifier))
            (identifier)
            (argumentList
              (slStringLiteral))))))))
