================================================================================
basic/newInsideLet
================================================================================

class Person {
  name: String
}

res1 = let (x = 1) new { name = "Pigeon" }

res2: Person = let (x = 1) new { name = "Pigeon" }

local localProperty: Person = let (x = 1) new { name = "Pigeon" }
res3 = localProperty

dynamic {
  res4 = let (x = 1) new { name = "Pigeon" }

  local localDynamic: Person = let (x = 1) new { name = "Pigeon" }
  res5 = localDynamic

  let (x = 1) new { name = "Pigeon" }

  ["Pigeon"] = let (x = 1) new { name = "Pigeon" }
}

open class Company {
  ceo: Person = let (x = 1) new { name = "Pigeon" }
}

class MyCompany extends Company {
  ceo = let (x = 1) new { name = "Pigeon" }
}

res6 = new Company {}

res7 = new MyCompany {}

res8 = new Company {
  ceo = let (x = 1) new { name = "Pigeon" }
}

res9 = new MyCompany {
  ceo = let (x = 1) new { name = "Pigeon" }
}

res10 = new Listing {
  let (x = 1) new { name = "Pigeon" }
}
res11 = (res10) {
  [0] = let (x = 1) new { name = "Pigeon" }
}

res12: Listing<Person> = new {
  let (x = 1) new { name = "Pigeon" }
}
res13 = (res12) {
  [0] = let (x = 1) new { name = "Pigeon" }
}

local localListing: Listing<Person> = new {
  let (x = 1) new { name = "Pigeon" }
}
res14 = localListing
res15 = (res14) {
  [0] = let (x = 1) new { name = "Pigeon" }
}

res16 = new Mapping {
  ["Pigeon"] = let (x = 1) new { name = "Pigeon" }
}
res17 = (res16) {
  ["Pigeon"] = let (x = 1) new { name = "Pigeon" }
}

res18: Mapping<String, Person> = new {
  ["Pigeon"] = let (x = 1) new { name = "Pigeon" }
}
res19 = (res18) {
  ["Pigeon"] = let (x = 1) new { name = "Pigeon" }
}

local localMapping: Mapping<String, Person> = new {
  ["Pigeon"] = let (x = 1) new { name = "Pigeon" }
}
res20 = localMapping
res21 = (res20) {
  ["Pigeon"] = let (x = 1) new { name = "Pigeon" }
}

// not yet implemented
//res22 = let (x = 1) let (x = new { name = "Pigeon" }) x
//res23 = let (x = 1) let (x: Person = new { name = "Pigeon" }) x

res24 = f1("Pigeon")
res24b = res24 is Person
res25 = f2("Pigeon")
res25b = res25 is Person
res26 = new X {}.f1("Pigeon")
res26b = res26 is Person
res27 = new X {}.f2
res27b = res27 is Person
res28 = one.two.f1
res28b = res28 is Person
res29 = f3("Pigeon")
res29b = res29 is Dynamic
res30 = new Person2 {}.friend
res30b = res30 is Dynamic

function f1(_name): Person = let (x = 1) new { name = _name }
local function f2(_name): Person = let (x = 1) new { name = _name }

class X {
  function f1(_name): Person = let (x = 1) new { name = _name }
  local function f2(_name): Person = let (x = 1) new { name = _name }
  f2 = f2("Pigeon")
}

one {
  two {
    local function f1(_name): Person = let (x = 1) new { name = _name }
    f1 = f1("Pigeon")
  }
}

function f3(_name) = new { name = _name }

class Person2 {
  friend = new { name = "Pigeon" }
}

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

(module
  (clazz
    (identifier)
    (classBody
      (classProperty
        (identifier)
        (typeAnnotation
          (type
            (qualifiedIdentifier
              (identifier)))))))
  (classProperty
    (identifier)
    (letExpr
      (typedIdentifier
        (identifier))
      (intLiteral)
      (newExpr
        (objectBody
          (objectProperty
            (identifier)
            (slStringLiteral))))))
  (classProperty
    (identifier)
    (typeAnnotation
      (type
        (qualifiedIdentifier
          (identifier))))
    (letExpr
      (typedIdentifier
        (identifier))
      (intLiteral)
      (newExpr
        (objectBody
          (objectProperty
            (identifier)
            (slStringLiteral))))))
  (classProperty
    (modifier)
    (identifier)
    (typeAnnotation
      (type
        (qualifiedIdentifier
          (identifier))))
    (letExpr
      (typedIdentifier
        (identifier))
      (intLiteral)
      (newExpr
        (objectBody
          (objectProperty
            (identifier)
            (slStringLiteral))))))
  (classProperty
    (identifier)
    (variableExpr
      (identifier)))
  (classProperty
    (identifier)
    (objectBody
      (objectProperty
        (identifier)
        (letExpr
          (typedIdentifier
            (identifier))
          (intLiteral)
          (newExpr
            (objectBody
              (objectProperty
                (identifier)
                (slStringLiteral))))))
      (objectProperty
        (modifier)
        (identifier)
        (typeAnnotation
          (type
            (qualifiedIdentifier
              (identifier))))
        (letExpr
          (typedIdentifier
            (identifier))
          (intLiteral)
          (newExpr
            (objectBody
              (objectProperty
                (identifier)
                (slStringLiteral))))))
      (objectProperty
        (identifier)
        (variableExpr
          (identifier)))
      (objectElement
        (letExpr
          (typedIdentifier
            (identifier))
          (intLiteral)
          (newExpr
            (objectBody
              (objectProperty
                (identifier)
                (slStringLiteral))))))
      (objectEntry
        (slStringLiteral)
        (letExpr
          (typedIdentifier
            (identifier))
          (intLiteral)
          (newExpr
            (objectBody
              (objectProperty
                (identifier)
                (slStringLiteral))))))))
  (clazz
    (modifier)
    (identifier)
    (classBody
      (classProperty
        (identifier)
        (typeAnnotation
          (type
            (qualifiedIdentifier
              (identifier))))
        (letExpr
          (typedIdentifier
            (identifier))
          (intLiteral)
          (newExpr
            (objectBody
              (objectProperty
                (identifier)
                (slStringLiteral))))))))
  (clazz
    (identifier)
    (classExtendsClause
      (qualifiedIdentifier
        (identifier)))
    (classBody
      (classProperty
        (identifier)
        (letExpr
          (typedIdentifier
            (identifier))
          (intLiteral)
          (newExpr
            (objectBody
              (objectProperty
                (identifier)
                (slStringLiteral))))))))
  (classProperty
    (identifier)
    (newExpr
      (type
        (qualifiedIdentifier
          (identifier)))
      (objectBody)))
  (classProperty
    (identifier)
    (newExpr
      (type
        (qualifiedIdentifier
          (identifier)))
      (objectBody)))
  (classProperty
    (identifier)
    (newExpr
      (type
        (qualifiedIdentifier
          (identifier)))
      (objectBody
        (objectProperty
          (identifier)
          (letExpr
            (typedIdentifier
              (identifier))
            (intLiteral)
            (newExpr
              (objectBody
                (objectProperty
                  (identifier)
                  (slStringLiteral)))))))))
  (classProperty
    (identifier)
    (newExpr
      (type
        (qualifiedIdentifier
          (identifier)))
      (objectBody
        (objectProperty
          (identifier)
          (letExpr
            (typedIdentifier
              (identifier))
            (intLiteral)
            (newExpr
              (objectBody
                (objectProperty
                  (identifier)
                  (slStringLiteral)))))))))
  (classProperty
    (identifier)
    (newExpr
      (type
        (qualifiedIdentifier
          (identifier)))
      (objectBody
        (objectElement
          (letExpr
            (typedIdentifier
              (identifier))
            (intLiteral)
            (newExpr
              (objectBody
                (objectProperty
                  (identifier)
                  (slStringLiteral)))))))))
  (classProperty
    (identifier)
    (objectLiteral
      (parenthesizedExpr
        (variableExpr
          (identifier)))
      (objectBody
        (objectEntry
          (intLiteral)
          (letExpr
            (typedIdentifier
              (identifier))
            (intLiteral)
            (newExpr
              (objectBody
                (objectProperty
                  (identifier)
                  (slStringLiteral)))))))))
  (classProperty
    (identifier)
    (typeAnnotation
      (type
        (qualifiedIdentifier
          (identifier))
        (typeArgumentList
          (type
            (qualifiedIdentifier
              (identifier))))))
    (newExpr
      (objectBody
        (objectElement
          (letExpr
            (typedIdentifier
              (identifier))
            (intLiteral)
            (newExpr
              (objectBody
                (objectProperty
                  (identifier)
                  (slStringLiteral)))))))))
  (classProperty
    (identifier)
    (objectLiteral
      (parenthesizedExpr
        (variableExpr
          (identifier)))
      (objectBody
        (objectEntry
          (intLiteral)
          (letExpr
            (typedIdentifier
              (identifier))
            (intLiteral)
            (newExpr
              (objectBody
                (objectProperty
                  (identifier)
                  (slStringLiteral)))))))))
  (classProperty
    (modifier)
    (identifier)
    (typeAnnotation
      (type
        (qualifiedIdentifier
          (identifier))
        (typeArgumentList
          (type
            (qualifiedIdentifier
              (identifier))))))
    (newExpr
      (objectBody
        (objectElement
          (letExpr
            (typedIdentifier
              (identifier))
            (intLiteral)
            (newExpr
              (objectBody
                (objectProperty
                  (identifier)
                  (slStringLiteral)))))))))
  (classProperty
    (identifier)
    (variableExpr
      (identifier)))
  (classProperty
    (identifier)
    (objectLiteral
      (parenthesizedExpr
        (variableExpr
          (identifier)))
      (objectBody
        (objectEntry
          (intLiteral)
          (letExpr
            (typedIdentifier
              (identifier))
            (intLiteral)
            (newExpr
              (objectBody
                (objectProperty
                  (identifier)
                  (slStringLiteral)))))))))
  (classProperty
    (identifier)
    (newExpr
      (type
        (qualifiedIdentifier
          (identifier)))
      (objectBody
        (objectEntry
          (slStringLiteral)
          (letExpr
            (typedIdentifier
              (identifier))
            (intLiteral)
            (newExpr
              (objectBody
                (objectProperty
                  (identifier)
                  (slStringLiteral)))))))))
  (classProperty
    (identifier)
    (objectLiteral
      (parenthesizedExpr
        (variableExpr
          (identifier)))
      (objectBody
        (objectEntry
          (slStringLiteral)
          (letExpr
            (typedIdentifier
              (identifier))
            (intLiteral)
            (newExpr
              (objectBody
                (objectProperty
                  (identifier)
                  (slStringLiteral)))))))))
  (classProperty
    (identifier)
    (typeAnnotation
      (type
        (qualifiedIdentifier
          (identifier))
        (typeArgumentList
          (type
            (qualifiedIdentifier
              (identifier)))
          (type
            (qualifiedIdentifier
              (identifier))))))
    (newExpr
      (objectBody
        (objectEntry
          (slStringLiteral)
          (letExpr
            (typedIdentifier
              (identifier))
            (intLiteral)
            (newExpr
              (objectBody
                (objectProperty
                  (identifier)
                  (slStringLiteral)))))))))
  (classProperty
    (identifier)
    (objectLiteral
      (parenthesizedExpr
        (variableExpr
          (identifier)))
      (objectBody
        (objectEntry
          (slStringLiteral)
          (letExpr
            (typedIdentifier
              (identifier))
            (intLiteral)
            (newExpr
              (objectBody
                (objectProperty
                  (identifier)
                  (slStringLiteral)))))))))
  (classProperty
    (modifier)
    (identifier)
    (typeAnnotation
      (type
        (qualifiedIdentifier
          (identifier))
        (typeArgumentList
          (type
            (qualifiedIdentifier
              (identifier)))
          (type
            (qualifiedIdentifier
              (identifier))))))
    (newExpr
      (objectBody
        (objectEntry
          (slStringLiteral)
          (letExpr
            (typedIdentifier
              (identifier))
            (intLiteral)
            (newExpr
              (objectBody
                (objectProperty
                  (identifier)
                  (slStringLiteral)))))))))
  (classProperty
    (identifier)
    (variableExpr
      (identifier)))
  (classProperty
    (identifier)
    (objectLiteral
      (parenthesizedExpr
        (variableExpr
          (identifier)))
      (objectBody
        (objectEntry
          (slStringLiteral)
          (letExpr
            (typedIdentifier
              (identifier))
            (intLiteral)
            (newExpr
              (objectBody
                (objectProperty
                  (identifier)
                  (slStringLiteral)))))))))
  (lineComment)
  (lineComment)
  (lineComment)
  (classProperty
    (identifier)
    (methodCallExpr
      (identifier)
      (argumentList
        (slStringLiteral))))
  (classProperty
    (identifier)
    (isExpr
      (variableExpr
        (identifier))
      (type
        (qualifiedIdentifier
          (identifier)))))
  (classProperty
    (identifier)
    (methodCallExpr
      (identifier)
      (argumentList
        (slStringLiteral))))
  (classProperty
    (identifier)
    (isExpr
      (variableExpr
        (identifier))
      (type
        (qualifiedIdentifier
          (identifier)))))
  (classProperty
    (identifier)
    (methodCallExpr
      (newExpr
        (type
          (qualifiedIdentifier
            (identifier)))
        (objectBody))
      (identifier)
      (argumentList
        (slStringLiteral))))
  (classProperty
    (identifier)
    (isExpr
      (variableExpr
        (identifier))
      (type
        (qualifiedIdentifier
          (identifier)))))
  (classProperty
    (identifier)
    (propertyCallExpr
      (newExpr
        (type
          (qualifiedIdentifier
            (identifier)))
        (objectBody))
      (identifier)))
  (classProperty
    (identifier)
    (isExpr
      (variableExpr
        (identifier))
      (type
        (qualifiedIdentifier
          (identifier)))))
  (classProperty
    (identifier)
    (propertyCallExpr
      (propertyCallExpr
        (variableExpr
          (identifier))
        (identifier))
      (identifier)))
  (classProperty
    (identifier)
    (isExpr
      (variableExpr
        (identifier))
      (type
        (qualifiedIdentifier
          (identifier)))))
  (classProperty
    (identifier)
    (methodCallExpr
      (identifier)
      (argumentList
        (slStringLiteral))))
  (classProperty
    (identifier)
    (isExpr
      (variableExpr
        (identifier))
      (type
        (qualifiedIdentifier
          (identifier)))))
  (classProperty
    (identifier)
    (propertyCallExpr
      (newExpr
        (type
          (qualifiedIdentifier
            (identifier)))
        (objectBody))
      (identifier)))
  (classProperty
    (identifier)
    (isExpr
      (variableExpr
        (identifier))
      (type
        (qualifiedIdentifier
          (identifier)))))
  (classMethod
    (methodHeader
      (identifier)
      (parameterList
        (typedIdentifier
          (identifier)))
      (typeAnnotation
        (type
          (qualifiedIdentifier
            (identifier)))))
    (letExpr
      (typedIdentifier
        (identifier))
      (intLiteral)
      (newExpr
        (objectBody
          (objectProperty
            (identifier)
            (variableExpr
              (identifier)))))))
  (classMethod
    (methodHeader
      (modifier)
      (identifier)
      (parameterList
        (typedIdentifier
          (identifier)))
      (typeAnnotation
        (type
          (qualifiedIdentifier
            (identifier)))))
    (letExpr
      (typedIdentifier
        (identifier))
      (intLiteral)
      (newExpr
        (objectBody
          (objectProperty
            (identifier)
            (variableExpr
              (identifier)))))))
  (clazz
    (identifier)
    (classBody
      (classMethod
        (methodHeader
          (identifier)
          (parameterList
            (typedIdentifier
              (identifier)))
          (typeAnnotation
            (type
              (qualifiedIdentifier
                (identifier)))))
        (letExpr
          (typedIdentifier
            (identifier))
          (intLiteral)
          (newExpr
            (objectBody
              (objectProperty
                (identifier)
                (variableExpr
                  (identifier)))))))
      (classMethod
        (methodHeader
          (modifier)
          (identifier)
          (parameterList
            (typedIdentifier
              (identifier)))
          (typeAnnotation
            (type
              (qualifiedIdentifier
                (identifier)))))
        (letExpr
          (typedIdentifier
            (identifier))
          (intLiteral)
          (newExpr
            (objectBody
              (objectProperty
                (identifier)
                (variableExpr
                  (identifier)))))))
      (classProperty
        (identifier)
        (methodCallExpr
          (identifier)
          (argumentList
            (slStringLiteral))))))
  (classProperty
    (identifier)
    (objectBody
      (objectProperty
        (identifier)
        (objectBody
          (objectMethod
            (methodHeader
              (modifier)
              (identifier)
              (parameterList
                (typedIdentifier
                  (identifier)))
              (typeAnnotation
                (type
                  (qualifiedIdentifier
                    (identifier)))))
            (letExpr
              (typedIdentifier
                (identifier))
              (intLiteral)
              (newExpr
                (objectBody
                  (objectProperty
                    (identifier)
                    (variableExpr
                      (identifier)))))))
          (objectProperty
            (identifier)
            (methodCallExpr
              (identifier)
              (argumentList
                (slStringLiteral))))))))
  (classMethod
    (methodHeader
      (identifier)
      (parameterList
        (typedIdentifier
          (identifier))))
    (newExpr
      (objectBody
        (objectProperty
          (identifier)
          (variableExpr
            (identifier))))))
  (clazz
    (identifier)
    (classBody
      (classProperty
        (identifier)
        (newExpr
          (objectBody
            (objectProperty
              (identifier)
              (slStringLiteral))))))))
