================================================================================
Type references
================================================================================

something as Int
something as? A
something as! A

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

(source_file
  (as_expression
    (simple_identifier)
    (as_operator)
    (user_type
      (type_identifier)))
  (as_expression
    (simple_identifier)
    (as_operator)
    (user_type
      (type_identifier)))
  (as_expression
    (simple_identifier)
    (as_operator)
    (user_type
      (type_identifier))))

================================================================================
Nested types
================================================================================

something as Some.NestedType

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

(source_file
  (as_expression
    (simple_identifier)
    (as_operator)
    (user_type
      (type_identifier)
      (type_identifier))))

================================================================================
Deeply nested types
================================================================================

somethingElse as A.Deeply.Nested.Type

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

(source_file
  (as_expression
    (simple_identifier)
    (as_operator)
    (user_type
      (type_identifier)
      (type_identifier)
      (type_identifier)
      (type_identifier))))

================================================================================
Generic parameterized types
================================================================================

something as Generic<T>
something as Generic<A, Type>

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

(source_file
  (as_expression
    (simple_identifier)
    (as_operator)
    (user_type
      (type_identifier)
      (type_arguments
        (user_type
          (type_identifier)))))
  (as_expression
    (simple_identifier)
    (as_operator)
    (user_type
      (type_identifier)
      (type_arguments
        (user_type
          (type_identifier))
        (user_type
          (type_identifier))))))

================================================================================
Function types
================================================================================

unitFunction as () -> Unit
consumer as (Int) -> Unit
configurator as (inout Config) -> Unit

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

(source_file
  (as_expression
    (simple_identifier)
    (as_operator)
    (function_type
      (tuple_type)
      (user_type
        (type_identifier))))
  (as_expression
    (simple_identifier)
    (as_operator)
    (function_type
      (tuple_type
        (tuple_type_item
          (user_type
            (type_identifier))))
      (user_type
        (type_identifier))))
  (as_expression
    (simple_identifier)
    (as_operator)
    (function_type
      (tuple_type
        (tuple_type_item
          (parameter_modifiers
            (parameter_modifier))
          (user_type
            (type_identifier))))
      (user_type
        (type_identifier)))))

================================================================================
Function types with multiple parameters
================================================================================

a as (Int, Generic<T>, Boolean) -> Unit
b as (Nested.Type, (Int)) -> Unit

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

(source_file
  (as_expression
    (simple_identifier)
    (as_operator)
    (function_type
      (tuple_type
        (tuple_type_item
          (user_type
            (type_identifier)))
        (tuple_type_item
          (user_type
            (type_identifier)
            (type_arguments
              (user_type
                (type_identifier)))))
        (tuple_type_item
          (user_type
            (type_identifier))))
      (user_type
        (type_identifier))))
  (as_expression
    (simple_identifier)
    (as_operator)
    (function_type
      (tuple_type
        (tuple_type_item
          (user_type
            (type_identifier)
            (type_identifier)))
        (tuple_type_item
          (tuple_type
            (tuple_type_item
              (user_type
                (type_identifier))))))
      (user_type
        (type_identifier)))))

================================================================================
Types with named parameters (function or tuple)
================================================================================

a as (first: A, second: B)
-> Unit
let c: (third: C, fourth: D)

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

(source_file
  (as_expression
    (simple_identifier)
    (as_operator)
    (function_type
      (tuple_type
        (tuple_type_item
          (simple_identifier)
          (user_type
            (type_identifier)))
        (tuple_type_item
          (simple_identifier)
          (user_type
            (type_identifier))))
      (user_type
        (type_identifier))))
  (property_declaration
    (value_binding_pattern
      (non_binding_pattern
        (simple_identifier)))
    (type_annotation
      (tuple_type
        (tuple_type_item
          (simple_identifier)
          (user_type
            (type_identifier)))
        (tuple_type_item
          (simple_identifier)
          (user_type
            (type_identifier)))))))

================================================================================
Nested optional types
================================================================================

private var dictionary: [String: Any?]?

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

(source_file
  (property_declaration
    (modifiers
      (visibility_modifier))
    (value_binding_pattern
      (non_binding_pattern
        (simple_identifier)))
    (type_annotation
      (optional_type
        (dictionary_type
          (user_type
            (type_identifier))
          (optional_type
            (user_type
              (type_identifier))))))))

================================================================================
Implicitly unwrapped optional types
================================================================================

private var dictionary: [String: Any?]!

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

(source_file
  (property_declaration
    (modifiers
      (visibility_modifier))
    (value_binding_pattern
      (non_binding_pattern
        (simple_identifier)))
    (type_annotation
      (dictionary_type
        (user_type
          (type_identifier))
        (optional_type
          (user_type
            (type_identifier)))))))

================================================================================
Type aliases
================================================================================

public typealias Callback<T> = (T) -> Void
public typealias IntCallback = Callback<T>

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

(source_file
  (typealias_declaration
    (modifiers
      (visibility_modifier))
    (type_identifier)
    (type_parameters
      (type_parameter
        (type_identifier)))
    (function_type
      (tuple_type
        (tuple_type_item
          (user_type
            (type_identifier))))
      (user_type
        (type_identifier))))
  (typealias_declaration
    (modifiers
      (visibility_modifier))
    (type_identifier)
    (user_type
      (type_identifier)
      (type_arguments
        (user_type
          (type_identifier))))))

================================================================================
Metatypes
================================================================================

_ = foo as [String].Type

protocol GetType {
   func getType() -> AnyObject.Type
}

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

(source_file
  (assignment
    (directly_assignable_expression
      (simple_identifier))
    (navigation_expression
      (as_expression
        (simple_identifier)
        (as_operator)
        (array_type
          (user_type
            (type_identifier))))
      (navigation_suffix
        (simple_identifier))))
  (protocol_declaration
    (type_identifier)
    (protocol_body
      (protocol_function_declaration
        (simple_identifier)
        (user_type
          (type_identifier)
          (type_identifier))))))
