@@ -104,13 +104,14 @@ let process_getter_setter ~no ~get ~set
104
104
105
105
106
106
107
- let handle_class_type_field self ({pctf_loc = loc } as ctf : Parsetree.class_type_field ) acc =
107
+ let handle_class_type_field self
108
+ ({pctf_loc = loc } as ctf : Parsetree.class_type_field )
109
+ acc =
108
110
match ctf.pctf_desc with
109
111
| Pctf_method
110
112
(name, private_flag, virtual_flag, ty)
111
- ->
112
- begin match Ast_attributes. process_method_attributes_rev ctf.pctf_attributes with
113
- | {get = None ; set = None } , _ ->
113
+ ->
114
+ let no (ty : Parsetree.core_type ) =
114
115
let ty =
115
116
match ty.ptyp_desc with
116
117
| Ptyp_arrow (label, args, body)
@@ -131,51 +132,29 @@ let handle_class_type_field self ({pctf_loc = loc } as ctf : Parsetree.class_typ
131
132
{ctf with
132
133
pctf_desc =
133
134
Pctf_method (name , private_flag, virtual_flag, ty)}
134
- :: acc
135
+ in
136
+ let get ty name pctf_attributes =
137
+ {ctf with
138
+ pctf_desc =
139
+ Pctf_method (name ,
140
+ private_flag,
141
+ virtual_flag,
142
+ self.typ self ty
143
+ );
144
+ pctf_attributes} in
145
+ let set ty name pctf_attributes =
146
+ {ctf with
147
+ pctf_desc =
148
+ Pctf_method (name,
149
+ private_flag,
150
+ virtual_flag,
151
+ Ast_util. to_method_type
152
+ loc self " " ty
153
+ (Ast_literal. type_unit ~loc () )
154
+ );
155
+ pctf_attributes} in
156
+ process_getter_setter ~no ~get ~set loc name ctf.pctf_attributes ty acc
135
157
136
- | st , pctf_attributes
137
- ->
138
- let get_acc =
139
- match st.set with
140
- | Some `No_get -> acc
141
- | None
142
- | Some `Get ->
143
- let lift txt =
144
- Typ. constr ~loc {txt ; loc} [ty] in
145
- let (null,undefined) =
146
- match st with
147
- | {get = Some (null , undefined ) } -> (null, undefined)
148
- | {get = None } -> (false , false ) in
149
- let ty =
150
- match (null,undefined) with
151
- | false , false -> ty
152
- | true , false -> lift Ast_literal.Lid. js_null
153
- | false , true -> lift Ast_literal.Lid. js_undefined
154
- | true , true -> lift Ast_literal.Lid. js_null_undefined in
155
- {ctf with
156
- pctf_desc =
157
- Pctf_method (name ,
158
- private_flag,
159
- virtual_flag,
160
- self.typ self ty
161
- );
162
- pctf_attributes}
163
- :: acc
164
- in
165
- if st.set = None then get_acc
166
- else
167
- {ctf with
168
- pctf_desc =
169
- Pctf_method (name ^ Literals. setter_suffix,
170
- private_flag,
171
- virtual_flag,
172
- Ast_util. to_method_type
173
- loc self " " ty
174
- (Ast_literal. type_unit ~loc () )
175
- );
176
- pctf_attributes}
177
- :: get_acc
178
- end
179
158
| Pctf_inherit _
180
159
| Pctf_val _
181
160
| Pctf_constraint _
0 commit comments