================================================================================
generators/spreadSyntaxListing
================================================================================

import "pkl:test"

local listing: Listing = new { 1; 2; 3 }
local mapping: Mapping = new { ["a"] = 1; ["b"] = 2 }
local list: List<Int> = List(1, 2, 3)
local map: Map<String, Int> = Map("a", 1, "b", 2)
local intseq: IntSeq = IntSeq(0, 5).step(2)
local set: Set<Int> = Set(10, 20, 30)

res1: Listing = new {
  0
  ...listing
  4
  5
  6
}

res2 = res1.length == 7

res3: Listing = (res1) {
  ...listing
}

res4: Listing = (listing) {
  for (_, _ in listing) {
    ...listing
  }
}

res5 = test.catch(() -> new Listing { ...d1 })

local class Listings {
  res1: Listing<String>
}

// spreading ints into a `Listing<String>` is an error
res6 = test.catch(() -> new Listings { res1 { ...listing } }.res1[0])

res7 = test.catch(() -> new Listing { ...mapping })

local nested = new Listing {
  new Listing { 1; 2; 3 }
  new Listing { 4; 5; 6 }
}

res8: Listing = new {
  for (elem in nested) { ...elem }
}

res9: Listing = new { ...listing; ...listing; ...listing }

res10: Listing = new { ...listing; ...listing; ...listing; 10; 11; ...listing }

res11: Listing = new { ...intseq }

res12: Listing = new { ...list }

res13 = test.catch(() -> new Listing { ...map })

res14: Listing = new { ...set }

res15 = new Listing {
  ...listing
}

res16 = new Listing {
  0
  ...listing
  0
  0
  0
}

res17 = res16.length

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

(module
  (importClause
    (stringConstant))
  (classProperty
    (modifier)
    (identifier)
    (typeAnnotation
      (type
        (qualifiedIdentifier
          (identifier))))
    (newExpr
      (objectBody
        (objectElement
          (intLiteral))
        (objectElement
          (intLiteral))
        (objectElement
          (intLiteral)))))
  (classProperty
    (modifier)
    (identifier)
    (typeAnnotation
      (type
        (qualifiedIdentifier
          (identifier))))
    (newExpr
      (objectBody
        (objectEntry
          (slStringLiteral)
          (intLiteral))
        (objectEntry
          (slStringLiteral)
          (intLiteral)))))
  (classProperty
    (modifier)
    (identifier)
    (typeAnnotation
      (type
        (qualifiedIdentifier
          (identifier))
        (typeArgumentList
          (type
            (qualifiedIdentifier
              (identifier))))))
    (methodCallExpr
      (identifier)
      (argumentList
        (intLiteral)
        (intLiteral)
        (intLiteral))))
  (classProperty
    (modifier)
    (identifier)
    (typeAnnotation
      (type
        (qualifiedIdentifier
          (identifier))
        (typeArgumentList
          (type
            (qualifiedIdentifier
              (identifier)))
          (type
            (qualifiedIdentifier
              (identifier))))))
    (methodCallExpr
      (identifier)
      (argumentList
        (slStringLiteral)
        (intLiteral)
        (slStringLiteral)
        (intLiteral))))
  (classProperty
    (modifier)
    (identifier)
    (typeAnnotation
      (type
        (qualifiedIdentifier
          (identifier))))
    (methodCallExpr
      (methodCallExpr
        (identifier)
        (argumentList
          (intLiteral)
          (intLiteral)))
      (identifier)
      (argumentList
        (intLiteral))))
  (classProperty
    (modifier)
    (identifier)
    (typeAnnotation
      (type
        (qualifiedIdentifier
          (identifier))
        (typeArgumentList
          (type
            (qualifiedIdentifier
              (identifier))))))
    (methodCallExpr
      (identifier)
      (argumentList
        (intLiteral)
        (intLiteral)
        (intLiteral))))
  (classProperty
    (identifier)
    (typeAnnotation
      (type
        (qualifiedIdentifier
          (identifier))))
    (newExpr
      (objectBody
        (objectElement
          (intLiteral))
        (objectSpread
          (variableExpr
            (identifier)))
        (objectElement
          (intLiteral))
        (objectElement
          (intLiteral))
        (objectElement
          (intLiteral)))))
  (classProperty
    (identifier)
    (binaryExpr
      (propertyCallExpr
        (variableExpr
          (identifier))
        (identifier))
      (intLiteral)))
  (classProperty
    (identifier)
    (typeAnnotation
      (type
        (qualifiedIdentifier
          (identifier))))
    (objectLiteral
      (parenthesizedExpr
        (variableExpr
          (identifier)))
      (objectBody
        (objectSpread
          (variableExpr
            (identifier))))))
  (classProperty
    (identifier)
    (typeAnnotation
      (type
        (qualifiedIdentifier
          (identifier))))
    (objectLiteral
      (parenthesizedExpr
        (variableExpr
          (identifier)))
      (objectBody
        (forGenerator
          (typedIdentifier
            (identifier))
          (typedIdentifier
            (identifier))
          (variableExpr
            (identifier))
          (objectBody
            (objectSpread
              (variableExpr
                (identifier))))))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (functionLiteral
          (parameterList)
          (newExpr
            (type
              (qualifiedIdentifier
                (identifier)))
            (objectBody
              (objectSpread
                (variableExpr
                  (identifier)))))))))
  (clazz
    (modifier)
    (identifier)
    (classBody
      (classProperty
        (identifier)
        (typeAnnotation
          (type
            (qualifiedIdentifier
              (identifier))
            (typeArgumentList
              (type
                (qualifiedIdentifier
                  (identifier)))))))))
  (lineComment)
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (functionLiteral
          (parameterList)
          (subscriptExpr
            (propertyCallExpr
              (newExpr
                (type
                  (qualifiedIdentifier
                    (identifier)))
                (objectBody
                  (objectProperty
                    (identifier)
                    (objectBody
                      (objectSpread
                        (variableExpr
                          (identifier)))))))
              (identifier))
            (intLiteral))))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (functionLiteral
          (parameterList)
          (newExpr
            (type
              (qualifiedIdentifier
                (identifier)))
            (objectBody
              (objectSpread
                (variableExpr
                  (identifier)))))))))
  (classProperty
    (modifier)
    (identifier)
    (newExpr
      (type
        (qualifiedIdentifier
          (identifier)))
      (objectBody
        (objectElement
          (newExpr
            (type
              (qualifiedIdentifier
                (identifier)))
            (objectBody
              (objectElement
                (intLiteral))
              (objectElement
                (intLiteral))
              (objectElement
                (intLiteral)))))
        (objectElement
          (newExpr
            (type
              (qualifiedIdentifier
                (identifier)))
            (objectBody
              (objectElement
                (intLiteral))
              (objectElement
                (intLiteral))
              (objectElement
                (intLiteral))))))))
  (classProperty
    (identifier)
    (typeAnnotation
      (type
        (qualifiedIdentifier
          (identifier))))
    (newExpr
      (objectBody
        (forGenerator
          (typedIdentifier
            (identifier))
          (variableExpr
            (identifier))
          (objectBody
            (objectSpread
              (variableExpr
                (identifier))))))))
  (classProperty
    (identifier)
    (typeAnnotation
      (type
        (qualifiedIdentifier
          (identifier))))
    (newExpr
      (objectBody
        (objectSpread
          (variableExpr
            (identifier)))
        (objectSpread
          (variableExpr
            (identifier)))
        (objectSpread
          (variableExpr
            (identifier))))))
  (classProperty
    (identifier)
    (typeAnnotation
      (type
        (qualifiedIdentifier
          (identifier))))
    (newExpr
      (objectBody
        (objectSpread
          (variableExpr
            (identifier)))
        (objectSpread
          (variableExpr
            (identifier)))
        (objectSpread
          (variableExpr
            (identifier)))
        (objectElement
          (intLiteral))
        (objectElement
          (intLiteral))
        (objectSpread
          (variableExpr
            (identifier))))))
  (classProperty
    (identifier)
    (typeAnnotation
      (type
        (qualifiedIdentifier
          (identifier))))
    (newExpr
      (objectBody
        (objectSpread
          (variableExpr
            (identifier))))))
  (classProperty
    (identifier)
    (typeAnnotation
      (type
        (qualifiedIdentifier
          (identifier))))
    (newExpr
      (objectBody
        (objectSpread
          (variableExpr
            (identifier))))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (functionLiteral
          (parameterList)
          (newExpr
            (type
              (qualifiedIdentifier
                (identifier)))
            (objectBody
              (objectSpread
                (variableExpr
                  (identifier)))))))))
  (classProperty
    (identifier)
    (typeAnnotation
      (type
        (qualifiedIdentifier
          (identifier))))
    (newExpr
      (objectBody
        (objectSpread
          (variableExpr
            (identifier))))))
  (classProperty
    (identifier)
    (newExpr
      (type
        (qualifiedIdentifier
          (identifier)))
      (objectBody
        (objectSpread
          (variableExpr
            (identifier))))))
  (classProperty
    (identifier)
    (newExpr
      (type
        (qualifiedIdentifier
          (identifier)))
      (objectBody
        (objectElement
          (intLiteral))
        (objectSpread
          (variableExpr
            (identifier)))
        (objectElement
          (intLiteral))
        (objectElement
          (intLiteral))
        (objectElement
          (intLiteral)))))
  (classProperty
    (identifier)
    (propertyCallExpr
      (variableExpr
        (identifier))
      (identifier))))
