compilation_unit {
  package_statement {
    package_name: "ExplorerTest"
  }
  is_api: true
  declarations {
    interface {
      name {
        name: "Maker"
      }
      members {
        function {
          name {
            name: "Make"
          }
          self_pattern {
            binding_pattern {
              name: "self"
              type {
                expression_pattern {
                  expression {
                    identifier {
                      name: "Self"
                    }
                  }
                }
              }
            }
          }
          param_pattern {
          }
          return_term {
            kind: Expression
            type {
              identifier {
                name: "T"
              }
            }
          }
        }
      }
    }
  }
  declarations {
    constraint {
      name {
        name: "IndirectMaker"
      }
      members {
        interface_extend {
          base {
            call {
              function {
                identifier {
                  name: "Maker"
                }
              }
              argument {
                tuple_literal {
                  fields {
                    operator {
                      op: Ptr
                      arguments {
                        identifier {
                          name: "T"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  declarations {
    constraint {
      name {
        name: "MoreIndirectMaker"
      }
      members {
        interface_extend {
          base {
            call {
              function {
                identifier {
                  name: "IndirectMaker"
                }
              }
              argument {
                tuple_literal {
                  fields {
                    int_type_literal {
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  declarations {
    class_declaration {
      name {
        name: "PointerFactory"
      }
      members {
        variable {
          binding {
            name: "p"
            type {
              expression_pattern {
                expression {
                  operator {
                    op: Ptr
                    arguments {
                      int_type_literal {
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
      members {
        impl {
          kind: ExternalImpl
          impl_type {
            identifier {
              name: "Self"
            }
          }
          interface {
            call {
              function {
                identifier {
                  name: "Maker"
                }
              }
              argument {
                tuple_literal {
                  fields {
                    operator {
                      op: Ptr
                      arguments {
                        int_type_literal {
                        }
                      }
                    }
                  }
                }
              }
            }
          }
          members {
            function {
              name {
                name: "Make"
              }
              self_pattern {
                binding_pattern {
                  name: "self"
                  type {
                    expression_pattern {
                      expression {
                        identifier {
                          name: "Self"
                        }
                      }
                    }
                  }
                }
              }
              param_pattern {
              }
              return_term {
                kind: Expression
                type {
                  operator {
                    op: Ptr
                    arguments {
                      int_type_literal {
                      }
                    }
                  }
                }
              }
              body {
                statements {
                  return_expression_statement {
                    expression {
                      simple_member_access {
                        field: "p"
                        object {
                          identifier {
                            name: "self"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  declarations {
    function {
      name {
        name: "CallIndirect"
      }
      deduced_parameters {
        name: "T"
        type {
          call {
            function {
              identifier {
                name: "IndirectMaker"
              }
            }
            argument {
              tuple_literal {
                fields {
                  int_type_literal {
                  }
                }
              }
            }
          }
        }
      }
      param_pattern {
        fields {
          binding_pattern {
            name: "x"
            type {
              expression_pattern {
                expression {
                  identifier {
                    name: "T"
                  }
                }
              }
            }
          }
        }
      }
      return_term {
        kind: Expression
        type {
          int_type_literal {
          }
        }
      }
      body {
        statements {
          return_expression_statement {
            expression {
              operator {
                op: Deref
                arguments {
                  call {
                    function {
                      simple_member_access {
                        field: "Make"
                        object {
                          identifier {
                            name: "x"
                          }
                        }
                      }
                    }
                    argument {
                      tuple_literal {
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  declarations {
    function {
      name {
        name: "CallMoreIndirect"
      }
      deduced_parameters {
        name: "T"
        type {
          identifier {
            name: "MoreIndirectMaker"
          }
        }
      }
      param_pattern {
        fields {
          binding_pattern {
            name: "x"
            type {
              expression_pattern {
                expression {
                  identifier {
                    name: "T"
                  }
                }
              }
            }
          }
        }
      }
      return_term {
        kind: Expression
        type {
          int_type_literal {
          }
        }
      }
      body {
        statements {
          return_expression_statement {
            expression {
              operator {
                op: Deref
                arguments {
                  call {
                    function {
                      simple_member_access {
                        field: "Make"
                        object {
                          identifier {
                            name: "x"
                          }
                        }
                      }
                    }
                    argument {
                      tuple_literal {
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  declarations {
    function {
      name {
        name: "Main"
      }
      param_pattern {
      }
      return_term {
        kind: Expression
        type {
          int_type_literal {
          }
        }
      }
      body {
        statements {
          variable_definition {
            pattern {
              binding_pattern {
                name: "n"
                type {
                  expression_pattern {
                    expression {
                      int_type_literal {
                      }
                    }
                  }
                }
              }
            }
            init {
              int_literal {
                value: 5
              }
            }
            is_returned: false
          }
        }
        statements {
          variable_definition {
            pattern {
              binding_pattern {
                name: "f"
                type {
                  expression_pattern {
                    expression {
                      identifier {
                        name: "PointerFactory"
                      }
                    }
                  }
                }
              }
            }
            init {
              struct_literal {
                fields {
                  name: "p"
                  expression {
                    operator {
                      op: AddressOf
                      arguments {
                        identifier {
                          name: "n"
                        }
                      }
                    }
                  }
                }
              }
            }
            is_returned: false
          }
        }
        statements {
          expression_statement {
            expression {
              call {
                function {
                  identifier {
                    name: "Print"
                  }
                }
                argument {
                  tuple_literal {
                    fields {
                      string_literal {
                        value: "{0}"
                      }
                    }
                    fields {
                      operator {
                        op: Deref
                        arguments {
                          call {
                            function {
                              compound_member_access {
                                object {
                                  identifier {
                                    name: "f"
                                  }
                                }
                                path {
                                  simple_member_access {
                                    field: "Make"
                                    object {
                                      call {
                                        function {
                                          identifier {
                                            name: "Maker"
                                          }
                                        }
                                        argument {
                                          tuple_literal {
                                            fields {
                                              operator {
                                                op: Ptr
                                                arguments {
                                                  int_type_literal {
                                                  }
                                                }
                                              }
                                            }
                                          }
                                        }
                                      }
                                    }
                                  }
                                }
                              }
                            }
                            argument {
                              tuple_literal {
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
        statements {
          expression_statement {
            expression {
              call {
                function {
                  identifier {
                    name: "Print"
                  }
                }
                argument {
                  tuple_literal {
                    fields {
                      string_literal {
                        value: "{0}"
                      }
                    }
                    fields {
                      operator {
                        op: Deref
                        arguments {
                          call {
                            function {
                              compound_member_access {
                                object {
                                  identifier {
                                    name: "f"
                                  }
                                }
                                path {
                                  simple_member_access {
                                    field: "Make"
                                    object {
                                      call {
                                        function {
                                          identifier {
                                            name: "IndirectMaker"
                                          }
                                        }
                                        argument {
                                          tuple_literal {
                                            fields {
                                              int_type_literal {
                                              }
                                            }
                                          }
                                        }
                                      }
                                    }
                                  }
                                }
                              }
                            }
                            argument {
                              tuple_literal {
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
        statements {
          expression_statement {
            expression {
              call {
                function {
                  identifier {
                    name: "Print"
                  }
                }
                argument {
                  tuple_literal {
                    fields {
                      string_literal {
                        value: "{0}"
                      }
                    }
                    fields {
                      operator {
                        op: Deref
                        arguments {
                          call {
                            function {
                              compound_member_access {
                                object {
                                  identifier {
                                    name: "f"
                                  }
                                }
                                path {
                                  simple_member_access {
                                    field: "Make"
                                    object {
                                      identifier {
                                        name: "MoreIndirectMaker"
                                      }
                                    }
                                  }
                                }
                              }
                            }
                            argument {
                              tuple_literal {
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
        statements {
          expression_statement {
            expression {
              call {
                function {
                  identifier {
                    name: "Print"
                  }
                }
                argument {
                  tuple_literal {
                    fields {
                      string_literal {
                        value: "{0}"
                      }
                    }
                    fields {
                      call {
                        function {
                          identifier {
                            name: "CallIndirect"
                          }
                        }
                        argument {
                          tuple_literal {
                            fields {
                              identifier {
                                name: "f"
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
        statements {
          expression_statement {
            expression {
              call {
                function {
                  identifier {
                    name: "Print"
                  }
                }
                argument {
                  tuple_literal {
                    fields {
                      string_literal {
                        value: "{0}"
                      }
                    }
                    fields {
                      call {
                        function {
                          identifier {
                            name: "CallMoreIndirect"
                          }
                        }
                        argument {
                          tuple_literal {
                            fields {
                              identifier {
                                name: "f"
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
        statements {
          return_expression_statement {
            expression {
              int_literal {
                value: 0
              }
            }
          }
        }
      }
    }
  }
}
