================================================================================
mappings/typeCheck
================================================================================

import "pkl:test"

local x1: Mapping<String, List<Int>> = new {
  ["pigeon"] = List(1, 2, 3)
  ["barn owl"] = 42
}

local x2: Mapping<String, List<Int>> = new {
  ["fr" + "ed"] = List(1) + List(2, 3)
  ["bar" + "ney"] = 21 + 21
}

local x3: Mapping<List<Int>, String> = new {
  [List(1, 2, 3)] = "pigeon"
  [42] = "barn owl"
}

local x4: Mapping<List<Int>, String> = new {
  [List(1) + List(2, 3)] = "fr" + "ed"
  [21 + 21] = "bar" + "ney"
}

local x5: Mapping<String(!isEmpty), String> = new {
  [""] = "pigeon"
}
local x6: Mapping<String, String(!isEmpty)> = new {
  ["pigeon"] = ""
}

res1 = test.catch(() -> x1)
res2 = test.catch(() -> x2)
res3 = test.catch(() -> x3)
res4 = test.catch(() -> x4)
res5 = test.catch(() -> x5)
res6 = test.catch(() -> x6)

hidden x7: Mapping = new {
  ["first"] = throw("value unnecessarily evaluated")
}

hidden x8: Mapping<String, Any> = new {
  ["first"] = throw("value unnecessarily evaluated")
}

hidden x9: Mapping<String, unknown> = new {
  ["first"] = throw("value unnecessarily evaluated")
}

hidden x10 = new Mapping {
  ["first"] = throw("value unnecessarily evaluated")
  ["second"] = 42
  ["third"] = throw("value unnecessarily evaluated")
}

res7 = !x7.isEmpty
res8 = !x8.isEmpty
res9 = !x9.isEmpty
res10 = x10["second"] == 42

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

(module
  (importClause
    (stringConstant))
  (classProperty
    (modifier)
    (identifier)
    (typeAnnotation
      (type
        (qualifiedIdentifier
          (identifier))
        (typeArgumentList
          (type
            (qualifiedIdentifier
              (identifier)))
          (type
            (qualifiedIdentifier
              (identifier))
            (typeArgumentList
              (type
                (qualifiedIdentifier
                  (identifier))))))))
    (newExpr
      (objectBody
        (objectEntry
          (slStringLiteral)
          (methodCallExpr
            (identifier)
            (argumentList
              (intLiteral)
              (intLiteral)
              (intLiteral))))
        (objectEntry
          (slStringLiteral)
          (intLiteral)))))
  (classProperty
    (modifier)
    (identifier)
    (typeAnnotation
      (type
        (qualifiedIdentifier
          (identifier))
        (typeArgumentList
          (type
            (qualifiedIdentifier
              (identifier)))
          (type
            (qualifiedIdentifier
              (identifier))
            (typeArgumentList
              (type
                (qualifiedIdentifier
                  (identifier))))))))
    (newExpr
      (objectBody
        (objectEntry
          (binaryExpr
            (slStringLiteral)
            (slStringLiteral))
          (binaryExpr
            (methodCallExpr
              (identifier)
              (argumentList
                (intLiteral)))
            (methodCallExpr
              (identifier)
              (argumentList
                (intLiteral)
                (intLiteral)))))
        (objectEntry
          (binaryExpr
            (slStringLiteral)
            (slStringLiteral))
          (binaryExpr
            (intLiteral)
            (intLiteral))))))
  (classProperty
    (modifier)
    (identifier)
    (typeAnnotation
      (type
        (qualifiedIdentifier
          (identifier))
        (typeArgumentList
          (type
            (qualifiedIdentifier
              (identifier))
            (typeArgumentList
              (type
                (qualifiedIdentifier
                  (identifier)))))
          (type
            (qualifiedIdentifier
              (identifier))))))
    (newExpr
      (objectBody
        (objectEntry
          (methodCallExpr
            (identifier)
            (argumentList
              (intLiteral)
              (intLiteral)
              (intLiteral)))
          (slStringLiteral))
        (objectEntry
          (intLiteral)
          (slStringLiteral)))))
  (classProperty
    (modifier)
    (identifier)
    (typeAnnotation
      (type
        (qualifiedIdentifier
          (identifier))
        (typeArgumentList
          (type
            (qualifiedIdentifier
              (identifier))
            (typeArgumentList
              (type
                (qualifiedIdentifier
                  (identifier)))))
          (type
            (qualifiedIdentifier
              (identifier))))))
    (newExpr
      (objectBody
        (objectEntry
          (binaryExpr
            (methodCallExpr
              (identifier)
              (argumentList
                (intLiteral)))
            (methodCallExpr
              (identifier)
              (argumentList
                (intLiteral)
                (intLiteral))))
          (binaryExpr
            (slStringLiteral)
            (slStringLiteral)))
        (objectEntry
          (binaryExpr
            (intLiteral)
            (intLiteral))
          (binaryExpr
            (slStringLiteral)
            (slStringLiteral))))))
  (classProperty
    (modifier)
    (identifier)
    (typeAnnotation
      (type
        (qualifiedIdentifier
          (identifier))
        (typeArgumentList
          (type
            (type
              (qualifiedIdentifier
                (identifier)))
            (unaryExpr
              (variableExpr
                (identifier))))
          (type
            (qualifiedIdentifier
              (identifier))))))
    (newExpr
      (objectBody
        (objectEntry
          (slStringLiteral)
          (slStringLiteral)))))
  (classProperty
    (modifier)
    (identifier)
    (typeAnnotation
      (type
        (qualifiedIdentifier
          (identifier))
        (typeArgumentList
          (type
            (qualifiedIdentifier
              (identifier)))
          (type
            (type
              (qualifiedIdentifier
                (identifier)))
            (unaryExpr
              (variableExpr
                (identifier)))))))
    (newExpr
      (objectBody
        (objectEntry
          (slStringLiteral)
          (slStringLiteral)))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (functionLiteral
          (parameterList)
          (variableExpr
            (identifier))))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (functionLiteral
          (parameterList)
          (variableExpr
            (identifier))))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (functionLiteral
          (parameterList)
          (variableExpr
            (identifier))))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (functionLiteral
          (parameterList)
          (variableExpr
            (identifier))))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (functionLiteral
          (parameterList)
          (variableExpr
            (identifier))))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (functionLiteral
          (parameterList)
          (variableExpr
            (identifier))))))
  (classProperty
    (modifier)
    (identifier)
    (typeAnnotation
      (type
        (qualifiedIdentifier
          (identifier))))
    (newExpr
      (objectBody
        (objectEntry
          (slStringLiteral)
          (throwExpr
            (parenthesizedExpr
              (slStringLiteral)))))))
  (classProperty
    (modifier)
    (identifier)
    (typeAnnotation
      (type
        (qualifiedIdentifier
          (identifier))
        (typeArgumentList
          (type
            (qualifiedIdentifier
              (identifier)))
          (type
            (qualifiedIdentifier
              (identifier))))))
    (newExpr
      (objectBody
        (objectEntry
          (slStringLiteral)
          (throwExpr
            (parenthesizedExpr
              (slStringLiteral)))))))
  (classProperty
    (modifier)
    (identifier)
    (typeAnnotation
      (type
        (qualifiedIdentifier
          (identifier))
        (typeArgumentList
          (type
            (qualifiedIdentifier
              (identifier)))
          (type))))
    (newExpr
      (objectBody
        (objectEntry
          (slStringLiteral)
          (throwExpr
            (parenthesizedExpr
              (slStringLiteral)))))))
  (classProperty
    (modifier)
    (identifier)
    (newExpr
      (type
        (qualifiedIdentifier
          (identifier)))
      (objectBody
        (objectEntry
          (slStringLiteral)
          (throwExpr
            (parenthesizedExpr
              (slStringLiteral))))
        (objectEntry
          (slStringLiteral)
          (intLiteral))
        (objectEntry
          (slStringLiteral)
          (throwExpr
            (parenthesizedExpr
              (slStringLiteral)))))))
  (classProperty
    (identifier)
    (propertyCallExpr
      (unaryExpr
        (variableExpr
          (identifier)))
      (identifier)))
  (classProperty
    (identifier)
    (propertyCallExpr
      (unaryExpr
        (variableExpr
          (identifier)))
      (identifier)))
  (classProperty
    (identifier)
    (propertyCallExpr
      (unaryExpr
        (variableExpr
          (identifier)))
      (identifier)))
  (classProperty
    (identifier)
    (binaryExpr
      (subscriptExpr
        (variableExpr
          (identifier))
        (slStringLiteral))
      (intLiteral))))
