================================================================================
basic/newInsideIf
================================================================================

class Person {
  name: String
}

res1 = if (true) new { name = "Pigeon" } else null

res2: Person = if (false) null else new { name = "Pigeon" }

local localProperty: Person = if (true) new { name = "Pigeon" } else null
res3 = localProperty

dynamic {
  res4 = if (false) null else new { name = "Pigeon" }

  local localDynamic: Person = if (true) new { name = "Pigeon" } else null
  res5 = localDynamic

  if (false) null else new { name = "Pigeon" }

  ["Pigeon"] = if (true) new { name = "Pigeon" } else null
}

open class Company {
  ceo: Person = if (false) null else new { name = "Pigeon" }
}

class MyCompany extends Company {
  ceo = if (true) new { name = "Pigeon" } else null
}

res6 = new Company {}

res7 = new MyCompany {}

res8 = new Company {
  ceo = if (false) null else new { name = "Pigeon" }
}

res9 = new MyCompany {
  ceo = if (true) new { name = "Pigeon" } else null
}

res10 = new Listing {
  if (false) null else new { name = "Pigeon" }
}
res11 = (res10) {
  [0] = if (true) new { name = "Pigeon" } else false
}

res12: Listing<Person> = new {
  if (false) null else new { name = "Pigeon" }
}
res13 = (res12) {
  [0] = if (true) new { name = "Pigeon" } else null
}

local localListing: Listing<Person> = new {
  if (false) null else new { name = "Pigeon" }
}
res14 = localListing
res15 = (res14) {
  [0] = if (true) new { name = "Pigeon" } else false
}

res16 = new Mapping {
  ["Pigeon"] = if (false) null else new { name = "Pigeon" }
}
res17 = (res16) {
  ["Pigeon"] = if (true) new { name = "Pigeon" } else null
}

res18: Mapping<String, Person> = new {
  ["Pigeon"] = if (false) null else new { name = "Pigeon" }
}
res19 = (res18) {
  ["Pigeon"] = if (true) new { name = "Pigeon" } else null
}

local localMapping: Mapping<String, Person> = new {
  ["Pigeon"] = if (false) null else new { name = "Pigeon" }
}
res20 = localMapping
res21 = (res20) {
  ["Pigeon"] = if (true) new { name = "Pigeon" } else null
}

// not yet implemented
//res22 = let (x = if (false) null else new { name = "Pigeon" }) x
//res23 = let (x: Person = if (true) new { name = "Pigeon" } else false) 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 = if (true) new { name = _name } else null
local function f2(_name): Person = if (true) new { name = _name } else null

class X {
  function f1(_name): Person = if (true) new { name = _name } else null
  local function f2(_name): Person = if (true) new { name = _name } else null
  f2 = f2("Pigeon")
}

one {
  two {
    local function f1(_name): Person = new { name = _name }
    f1 = if (true) f1("Pigeon") else null
  }
}

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

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

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

(module
  (clazz
    (identifier)
    (classBody
      (classProperty
        (identifier)
        (typeAnnotation
          (type
            (qualifiedIdentifier
              (identifier)))))))
  (classProperty
    (identifier)
    (ifExpr
      (trueLiteral)
      (newExpr
        (objectBody
          (objectProperty
            (identifier)
            (slStringLiteral))))
      (nullLiteral)))
  (classProperty
    (identifier)
    (typeAnnotation
      (type
        (qualifiedIdentifier
          (identifier))))
    (ifExpr
      (falseLiteral)
      (nullLiteral)
      (newExpr
        (objectBody
          (objectProperty
            (identifier)
            (slStringLiteral))))))
  (classProperty
    (modifier)
    (identifier)
    (typeAnnotation
      (type
        (qualifiedIdentifier
          (identifier))))
    (ifExpr
      (trueLiteral)
      (newExpr
        (objectBody
          (objectProperty
            (identifier)
            (slStringLiteral))))
      (nullLiteral)))
  (classProperty
    (identifier)
    (variableExpr
      (identifier)))
  (classProperty
    (identifier)
    (objectBody
      (objectProperty
        (identifier)
        (ifExpr
          (falseLiteral)
          (nullLiteral)
          (newExpr
            (objectBody
              (objectProperty
                (identifier)
                (slStringLiteral))))))
      (objectProperty
        (modifier)
        (identifier)
        (typeAnnotation
          (type
            (qualifiedIdentifier
              (identifier))))
        (ifExpr
          (trueLiteral)
          (newExpr
            (objectBody
              (objectProperty
                (identifier)
                (slStringLiteral))))
          (nullLiteral)))
      (objectProperty
        (identifier)
        (variableExpr
          (identifier)))
      (objectElement
        (ifExpr
          (falseLiteral)
          (nullLiteral)
          (newExpr
            (objectBody
              (objectProperty
                (identifier)
                (slStringLiteral))))))
      (objectEntry
        (slStringLiteral)
        (ifExpr
          (trueLiteral)
          (newExpr
            (objectBody
              (objectProperty
                (identifier)
                (slStringLiteral))))
          (nullLiteral)))))
  (clazz
    (modifier)
    (identifier)
    (classBody
      (classProperty
        (identifier)
        (typeAnnotation
          (type
            (qualifiedIdentifier
              (identifier))))
        (ifExpr
          (falseLiteral)
          (nullLiteral)
          (newExpr
            (objectBody
              (objectProperty
                (identifier)
                (slStringLiteral))))))))
  (clazz
    (identifier)
    (classExtendsClause
      (qualifiedIdentifier
        (identifier)))
    (classBody
      (classProperty
        (identifier)
        (ifExpr
          (trueLiteral)
          (newExpr
            (objectBody
              (objectProperty
                (identifier)
                (slStringLiteral))))
          (nullLiteral)))))
  (classProperty
    (identifier)
    (newExpr
      (type
        (qualifiedIdentifier
          (identifier)))
      (objectBody)))
  (classProperty
    (identifier)
    (newExpr
      (type
        (qualifiedIdentifier
          (identifier)))
      (objectBody)))
  (classProperty
    (identifier)
    (newExpr
      (type
        (qualifiedIdentifier
          (identifier)))
      (objectBody
        (objectProperty
          (identifier)
          (ifExpr
            (falseLiteral)
            (nullLiteral)
            (newExpr
              (objectBody
                (objectProperty
                  (identifier)
                  (slStringLiteral)))))))))
  (classProperty
    (identifier)
    (newExpr
      (type
        (qualifiedIdentifier
          (identifier)))
      (objectBody
        (objectProperty
          (identifier)
          (ifExpr
            (trueLiteral)
            (newExpr
              (objectBody
                (objectProperty
                  (identifier)
                  (slStringLiteral))))
            (nullLiteral))))))
  (classProperty
    (identifier)
    (newExpr
      (type
        (qualifiedIdentifier
          (identifier)))
      (objectBody
        (objectElement
          (ifExpr
            (falseLiteral)
            (nullLiteral)
            (newExpr
              (objectBody
                (objectProperty
                  (identifier)
                  (slStringLiteral)))))))))
  (classProperty
    (identifier)
    (objectLiteral
      (parenthesizedExpr
        (variableExpr
          (identifier)))
      (objectBody
        (objectEntry
          (intLiteral)
          (ifExpr
            (trueLiteral)
            (newExpr
              (objectBody
                (objectProperty
                  (identifier)
                  (slStringLiteral))))
            (falseLiteral))))))
  (classProperty
    (identifier)
    (typeAnnotation
      (type
        (qualifiedIdentifier
          (identifier))
        (typeArgumentList
          (type
            (qualifiedIdentifier
              (identifier))))))
    (newExpr
      (objectBody
        (objectElement
          (ifExpr
            (falseLiteral)
            (nullLiteral)
            (newExpr
              (objectBody
                (objectProperty
                  (identifier)
                  (slStringLiteral)))))))))
  (classProperty
    (identifier)
    (objectLiteral
      (parenthesizedExpr
        (variableExpr
          (identifier)))
      (objectBody
        (objectEntry
          (intLiteral)
          (ifExpr
            (trueLiteral)
            (newExpr
              (objectBody
                (objectProperty
                  (identifier)
                  (slStringLiteral))))
            (nullLiteral))))))
  (classProperty
    (modifier)
    (identifier)
    (typeAnnotation
      (type
        (qualifiedIdentifier
          (identifier))
        (typeArgumentList
          (type
            (qualifiedIdentifier
              (identifier))))))
    (newExpr
      (objectBody
        (objectElement
          (ifExpr
            (falseLiteral)
            (nullLiteral)
            (newExpr
              (objectBody
                (objectProperty
                  (identifier)
                  (slStringLiteral)))))))))
  (classProperty
    (identifier)
    (variableExpr
      (identifier)))
  (classProperty
    (identifier)
    (objectLiteral
      (parenthesizedExpr
        (variableExpr
          (identifier)))
      (objectBody
        (objectEntry
          (intLiteral)
          (ifExpr
            (trueLiteral)
            (newExpr
              (objectBody
                (objectProperty
                  (identifier)
                  (slStringLiteral))))
            (falseLiteral))))))
  (classProperty
    (identifier)
    (newExpr
      (type
        (qualifiedIdentifier
          (identifier)))
      (objectBody
        (objectEntry
          (slStringLiteral)
          (ifExpr
            (falseLiteral)
            (nullLiteral)
            (newExpr
              (objectBody
                (objectProperty
                  (identifier)
                  (slStringLiteral)))))))))
  (classProperty
    (identifier)
    (objectLiteral
      (parenthesizedExpr
        (variableExpr
          (identifier)))
      (objectBody
        (objectEntry
          (slStringLiteral)
          (ifExpr
            (trueLiteral)
            (newExpr
              (objectBody
                (objectProperty
                  (identifier)
                  (slStringLiteral))))
            (nullLiteral))))))
  (classProperty
    (identifier)
    (typeAnnotation
      (type
        (qualifiedIdentifier
          (identifier))
        (typeArgumentList
          (type
            (qualifiedIdentifier
              (identifier)))
          (type
            (qualifiedIdentifier
              (identifier))))))
    (newExpr
      (objectBody
        (objectEntry
          (slStringLiteral)
          (ifExpr
            (falseLiteral)
            (nullLiteral)
            (newExpr
              (objectBody
                (objectProperty
                  (identifier)
                  (slStringLiteral)))))))))
  (classProperty
    (identifier)
    (objectLiteral
      (parenthesizedExpr
        (variableExpr
          (identifier)))
      (objectBody
        (objectEntry
          (slStringLiteral)
          (ifExpr
            (trueLiteral)
            (newExpr
              (objectBody
                (objectProperty
                  (identifier)
                  (slStringLiteral))))
            (nullLiteral))))))
  (classProperty
    (modifier)
    (identifier)
    (typeAnnotation
      (type
        (qualifiedIdentifier
          (identifier))
        (typeArgumentList
          (type
            (qualifiedIdentifier
              (identifier)))
          (type
            (qualifiedIdentifier
              (identifier))))))
    (newExpr
      (objectBody
        (objectEntry
          (slStringLiteral)
          (ifExpr
            (falseLiteral)
            (nullLiteral)
            (newExpr
              (objectBody
                (objectProperty
                  (identifier)
                  (slStringLiteral)))))))))
  (classProperty
    (identifier)
    (variableExpr
      (identifier)))
  (classProperty
    (identifier)
    (objectLiteral
      (parenthesizedExpr
        (variableExpr
          (identifier)))
      (objectBody
        (objectEntry
          (slStringLiteral)
          (ifExpr
            (trueLiteral)
            (newExpr
              (objectBody
                (objectProperty
                  (identifier)
                  (slStringLiteral))))
            (nullLiteral))))))
  (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)))))
    (ifExpr
      (trueLiteral)
      (newExpr
        (objectBody
          (objectProperty
            (identifier)
            (variableExpr
              (identifier)))))
      (nullLiteral)))
  (classMethod
    (methodHeader
      (modifier)
      (identifier)
      (parameterList
        (typedIdentifier
          (identifier)))
      (typeAnnotation
        (type
          (qualifiedIdentifier
            (identifier)))))
    (ifExpr
      (trueLiteral)
      (newExpr
        (objectBody
          (objectProperty
            (identifier)
            (variableExpr
              (identifier)))))
      (nullLiteral)))
  (clazz
    (identifier)
    (classBody
      (classMethod
        (methodHeader
          (identifier)
          (parameterList
            (typedIdentifier
              (identifier)))
          (typeAnnotation
            (type
              (qualifiedIdentifier
                (identifier)))))
        (ifExpr
          (trueLiteral)
          (newExpr
            (objectBody
              (objectProperty
                (identifier)
                (variableExpr
                  (identifier)))))
          (nullLiteral)))
      (classMethod
        (methodHeader
          (modifier)
          (identifier)
          (parameterList
            (typedIdentifier
              (identifier)))
          (typeAnnotation
            (type
              (qualifiedIdentifier
                (identifier)))))
        (ifExpr
          (trueLiteral)
          (newExpr
            (objectBody
              (objectProperty
                (identifier)
                (variableExpr
                  (identifier)))))
          (nullLiteral)))
      (classProperty
        (identifier)
        (methodCallExpr
          (identifier)
          (argumentList
            (slStringLiteral))))))
  (classProperty
    (identifier)
    (objectBody
      (objectProperty
        (identifier)
        (objectBody
          (objectMethod
            (methodHeader
              (modifier)
              (identifier)
              (parameterList
                (typedIdentifier
                  (identifier)))
              (typeAnnotation
                (type
                  (qualifiedIdentifier
                    (identifier)))))
            (newExpr
              (objectBody
                (objectProperty
                  (identifier)
                  (variableExpr
                    (identifier))))))
          (objectProperty
            (identifier)
            (ifExpr
              (trueLiteral)
              (methodCallExpr
                (identifier)
                (argumentList
                  (slStringLiteral)))
              (nullLiteral)))))))
  (classMethod
    (methodHeader
      (identifier)
      (parameterList
        (typedIdentifier
          (identifier))))
    (newExpr
      (objectBody
        (objectProperty
          (identifier)
          (variableExpr
            (identifier))))))
  (clazz
    (identifier)
    (classBody
      (classProperty
        (identifier)
        (newExpr
          (objectBody
            (objectProperty
              (identifier)
              (slStringLiteral))))))))
