Skip to content

Commit 62c1286

Browse files
committed
Remove class_type_field
1 parent b4ed742 commit 62c1286

13 files changed

+11
-154
lines changed

jscomp/frontend/bs_ast_mapper.ml

-18
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ type mapper = {
3030
case: mapper -> case -> case;
3131
cases: mapper -> case list -> case list;
3232
class_type: mapper -> class_type -> class_type;
33-
class_type_field: mapper -> class_type_field -> class_type_field;
3433
constructor_declaration:
3534
mapper -> constructor_declaration -> constructor_declaration;
3635
expr: mapper -> expression -> expression;
@@ -202,22 +201,6 @@ module CT = struct
202201
| Pcty_extension x -> extension ~loc ~attrs (sub.extension sub x)
203202
| Pcty_open (ovf, lid, ct) ->
204203
open_ ~loc ~attrs ovf (map_loc sub lid) (sub.class_type sub ct)
205-
206-
let map_field sub {pctf_desc = desc; pctf_loc = loc; pctf_attributes = attrs}
207-
=
208-
let open Ctf in
209-
let loc = sub.location sub loc in
210-
let attrs = sub.attributes sub attrs in
211-
match desc with
212-
| Pctf_inherit ct -> inherit_ ~loc ~attrs (sub.class_type sub ct)
213-
| Pctf_val (s, m, v, t) ->
214-
val_ ~loc ~attrs (map_loc sub s) m v (sub.typ sub t)
215-
| Pctf_method (s, p, v, t) ->
216-
method_ ~loc ~attrs (map_loc sub s) p v (sub.typ sub t)
217-
| Pctf_constraint (t1, t2) ->
218-
constraint_ ~loc ~attrs (sub.typ sub t1) (sub.typ sub t2)
219-
| Pctf_attribute x -> attribute ~loc (sub.attribute sub x)
220-
| Pctf_extension x -> extension ~loc ~attrs (sub.extension sub x)
221204
end
222205

223206
module MT = struct
@@ -467,7 +450,6 @@ let default_mapper =
467450
module_type = MT.map;
468451
with_constraint = MT.map_with_constraint;
469452
class_type = CT.map;
470-
class_type_field = CT.map_field;
471453
type_declaration = T.map_type_declaration;
472454
(* #if true then *)
473455
type_declaration_list = T.map_type_declaration_list;

jscomp/frontend/bs_ast_mapper.mli

-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ type mapper = {
5858
case: mapper -> case -> case;
5959
cases: mapper -> case list -> case list;
6060
class_type: mapper -> class_type -> class_type;
61-
class_type_field: mapper -> class_type_field -> class_type_field;
6261
constructor_declaration:
6362
mapper -> constructor_declaration -> constructor_declaration;
6463
expr: mapper -> expression -> expression;

jscomp/ml/ast_helper.ml

-25
Original file line numberDiff line numberDiff line change
@@ -287,31 +287,6 @@ module Cty = struct
287287
let open_ ?loc ?attrs a b c = mk ?loc ?attrs (Pcty_open (a, b, c))
288288
end
289289

290-
module Ctf = struct
291-
let mk ?(loc = !default_loc) ?(attrs = [])
292-
?(docs = empty_docs) d =
293-
{
294-
pctf_desc = d;
295-
pctf_loc = loc;
296-
pctf_attributes = add_docs_attrs docs attrs;
297-
}
298-
299-
let inherit_ ?loc ?attrs a = mk ?loc ?attrs (Pctf_inherit a)
300-
let val_ ?loc ?attrs a b c d = mk ?loc ?attrs (Pctf_val (a, b, c, d))
301-
let method_ ?loc ?attrs a b c d = mk ?loc ?attrs (Pctf_method (a, b, c, d))
302-
let constraint_ ?loc ?attrs a b = mk ?loc ?attrs (Pctf_constraint (a, b))
303-
let extension ?loc ?attrs a = mk ?loc ?attrs (Pctf_extension a)
304-
let attribute ?loc a = mk ?loc (Pctf_attribute a)
305-
let text txt =
306-
let f_txt = Ext_list.filter txt (fun ds -> docstring_body ds <> "")in
307-
List.map
308-
(fun ds -> attribute ~loc:(docstring_loc ds) (text_attr ds))
309-
f_txt
310-
311-
let attr d a = {d with pctf_attributes = d.pctf_attributes @ [a]}
312-
313-
end
314-
315290

316291
module Val = struct
317292
let mk ?(loc = !default_loc) ?(attrs = []) ?(docs = empty_docs)

jscomp/ml/ast_helper.mli

-19
Original file line numberDiff line numberDiff line change
@@ -350,25 +350,6 @@ module Cty:
350350
-> class_type
351351
end
352352

353-
(** Class type fields *)
354-
module Ctf:
355-
sig
356-
val mk: ?loc:loc -> ?attrs:attrs -> ?docs:docs ->
357-
class_type_field_desc -> class_type_field
358-
val attr: class_type_field -> attribute -> class_type_field
359-
360-
val inherit_: ?loc:loc -> ?attrs:attrs -> class_type -> class_type_field
361-
val val_: ?loc:loc -> ?attrs:attrs -> str -> mutable_flag ->
362-
virtual_flag -> core_type -> class_type_field
363-
val method_: ?loc:loc -> ?attrs:attrs -> str -> private_flag ->
364-
virtual_flag -> core_type -> class_type_field
365-
val constraint_: ?loc:loc -> ?attrs:attrs -> core_type -> core_type ->
366-
class_type_field
367-
val extension: ?loc:loc -> ?attrs:attrs -> extension -> class_type_field
368-
val attribute: ?loc:loc -> attribute -> class_type_field
369-
val text: text -> class_type_field list
370-
end
371-
372353
(** Classes *)
373354
module Ci:
374355
sig

jscomp/ml/ast_iterator.ml

-16
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ type iterator = {
3030
case: iterator -> case -> unit;
3131
cases: iterator -> case list -> unit;
3232
class_type: iterator -> class_type -> unit;
33-
class_type_field: iterator -> class_type_field -> unit;
3433
constructor_declaration: iterator -> constructor_declaration -> unit;
3534
expr: iterator -> expression -> unit;
3635
extension: iterator -> extension -> unit;
@@ -181,20 +180,6 @@ module CT = struct
181180
| Pcty_extension x -> sub.extension sub x
182181
| Pcty_open (_ovf, lid, e) ->
183182
iter_loc sub lid; sub.class_type sub e
184-
185-
let iter_field sub {pctf_desc = desc; pctf_loc = loc; pctf_attributes = attrs}
186-
=
187-
sub.location sub loc;
188-
sub.attributes sub attrs;
189-
match desc with
190-
| Pctf_inherit ct -> sub.class_type sub ct
191-
| Pctf_val (_s, _m, _v, t) -> sub.typ sub t
192-
| Pctf_method (_s, _p, _v, t) -> sub.typ sub t
193-
| Pctf_constraint (t1, t2) ->
194-
sub.typ sub t1; sub.typ sub t2
195-
| Pctf_attribute x -> sub.attribute sub x
196-
| Pctf_extension x -> sub.extension sub x
197-
198183
end
199184

200185
module MT = struct
@@ -413,7 +398,6 @@ let default_iterator =
413398
module_type = MT.iter;
414399
with_constraint = MT.iter_with_constraint;
415400
class_type = CT.iter;
416-
class_type_field = CT.iter_field;
417401
type_declaration = T.iter_type_declaration;
418402
type_kind = T.iter_type_kind;
419403
typ = T.iter;

jscomp/ml/ast_iterator.mli

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ type iterator = {
2727
case: iterator -> case -> unit;
2828
cases: iterator -> case list -> unit;
2929
class_type: iterator -> class_type -> unit;
30-
class_type_field: iterator -> class_type_field -> unit;
3130
constructor_declaration: iterator -> constructor_declaration -> unit;
3231
expr: iterator -> expression -> unit;
3332
extension: iterator -> extension -> unit;

jscomp/ml/ast_mapper.ml

-19
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ type mapper = {
3131
case: mapper -> case -> case;
3232
cases: mapper -> case list -> case list;
3333
class_type: mapper -> class_type -> class_type;
34-
class_type_field: mapper -> class_type_field -> class_type_field;
3534
constructor_declaration: mapper -> constructor_declaration
3635
-> constructor_declaration;
3736
expr: mapper -> expression -> expression;
@@ -189,23 +188,6 @@ module CT = struct
189188
| Pcty_extension x -> extension ~loc ~attrs (sub.extension sub x)
190189
| Pcty_open (ovf, lid, ct) ->
191190
open_ ~loc ~attrs ovf (map_loc sub lid) (sub.class_type sub ct)
192-
193-
let map_field sub {pctf_desc = desc; pctf_loc = loc; pctf_attributes = attrs}
194-
=
195-
let open Ctf in
196-
let loc = sub.location sub loc in
197-
let attrs = sub.attributes sub attrs in
198-
match desc with
199-
| Pctf_inherit ct -> inherit_ ~loc ~attrs (sub.class_type sub ct)
200-
| Pctf_val (s, m, v, t) ->
201-
val_ ~loc ~attrs (map_loc sub s) m v (sub.typ sub t)
202-
| Pctf_method (s, p, v, t) ->
203-
method_ ~loc ~attrs (map_loc sub s) p v (sub.typ sub t)
204-
| Pctf_constraint (t1, t2) ->
205-
constraint_ ~loc ~attrs (sub.typ sub t1) (sub.typ sub t2)
206-
| Pctf_attribute x -> attribute ~loc (sub.attribute sub x)
207-
| Pctf_extension x -> extension ~loc ~attrs (sub.extension sub x)
208-
209191
end
210192

211193
module MT = struct
@@ -433,7 +415,6 @@ let default_mapper =
433415
module_type = MT.map;
434416
with_constraint = MT.map_with_constraint;
435417
class_type = CT.map;
436-
class_type_field = CT.map_field;
437418
type_declaration = T.map_type_declaration;
438419
type_kind = T.map_type_kind;
439420
typ = T.map;

jscomp/ml/ast_mapper.mli

-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ type mapper = {
5858
case: mapper -> case -> case;
5959
cases: mapper -> case list -> case list;
6060
class_type: mapper -> class_type -> class_type;
61-
class_type_field: mapper -> class_type_field -> class_type_field;
6261
constructor_declaration: mapper -> constructor_declaration
6362
-> constructor_declaration;
6463
expr: mapper -> expression -> expression;

jscomp/ml/parser.ml

+9-10
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,7 @@ let mksig d = Sig.mk ~loc:(symbol_rloc()) d
137137
let mkmod ?attrs d = Mod.mk ~loc:(symbol_rloc()) ?attrs d
138138
let mkstr d = Str.mk ~loc:(symbol_rloc()) d
139139
let mkcty ?attrs d = Cty.mk ~loc:(symbol_rloc()) ?attrs d
140-
let mkctf ?attrs ?docs d =
141-
Ctf.mk ~loc:(symbol_rloc()) ?attrs ?docs d
140+
let mkctf ?attrs ?docs _d = let _ = (attrs, docs) in assert false
142141
let mkcf ?attrs ?docs _d = let _ = (attrs, docs) in assert false
143142

144143
let mkrhs rhs pos = mkloc rhs (rhs_loc pos)
@@ -346,7 +345,7 @@ let mksig_ext d ext =
346345
let text_str pos = Str.text (rhs_text pos)
347346
let text_sig pos = Sig.text (rhs_text pos)
348347
let text_cstr _pos = assert false
349-
let text_csig pos = Ctf.text (rhs_text pos)
348+
let text_csig _pos = assert false
350349

351350

352351
let extra_text text pos items =
@@ -7487,7 +7486,7 @@ let yyact = [|
74877486
let _4 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in
74887487
Obj.repr(
74897488
# 995 "ml/parser.mly"
7490-
( mkctf (Pctf_inherit _3) ~attrs:(_2@_4) ~docs:(symbol_docs ()) )
7489+
( mkctf (assert false) ~attrs:(_2@_4) ~docs:(symbol_docs ()) )
74917490
# 7495 "ml/parser.ml"
74927491
: 'class_sig_field))
74937492
; (fun __caml_parser_env ->
@@ -7496,7 +7495,7 @@ let yyact = [|
74967495
let _4 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in
74977496
Obj.repr(
74987497
# 997 "ml/parser.mly"
7499-
( mkctf (Pctf_val _3) ~attrs:(_2@_4) ~docs:(symbol_docs ()) )
7498+
( mkctf (assert false) ~attrs:(_2@_4) ~docs:(symbol_docs ()) )
75007499
# 7504 "ml/parser.ml"
75017500
: 'class_sig_field))
75027501
; (fun __caml_parser_env ->
@@ -7508,8 +7507,8 @@ let yyact = [|
75087507
Obj.repr(
75097508
# 1000 "ml/parser.mly"
75107509
(
7511-
let (p, v) = _3 in
7512-
mkctf (Pctf_method (mkrhs _4 4, p, v, _6)) ~attrs:(_2@_7) ~docs:(symbol_docs ())
7510+
let (_p, _v) = _3 in
7511+
mkctf (assert false) ~attrs:(_2@_7) ~docs:(symbol_docs ())
75137512
)
75147513
# 7518 "ml/parser.ml"
75157514
: 'class_sig_field))
@@ -7519,23 +7518,23 @@ let yyact = [|
75197518
let _4 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in
75207519
Obj.repr(
75217520
# 1005 "ml/parser.mly"
7522-
( mkctf (Pctf_constraint _3) ~attrs:(_2@_4) ~docs:(symbol_docs ()) )
7521+
( mkctf (assert false) ~attrs:(_2@_4) ~docs:(symbol_docs ()) )
75237522
# 7527 "ml/parser.ml"
75247523
: 'class_sig_field))
75257524
; (fun __caml_parser_env ->
75267525
let _1 = (Parsing.peek_val __caml_parser_env 1 : 'item_extension) in
75277526
let _2 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in
75287527
Obj.repr(
75297528
# 1007 "ml/parser.mly"
7530-
( mkctf (Pctf_extension _1) ~attrs:_2 ~docs:(symbol_docs ()) )
7529+
( mkctf (assert false) ~attrs:_2 ~docs:(symbol_docs ()) )
75317530
# 7535 "ml/parser.ml"
75327531
: 'class_sig_field))
75337532
; (fun __caml_parser_env ->
75347533
let _1 = (Parsing.peek_val __caml_parser_env 0 : 'floating_attribute) in
75357534
Obj.repr(
75367535
# 1009 "ml/parser.mly"
75377536
( mark_symbol_docs ();
7538-
mkctf(Pctf_attribute _1) )
7537+
mkctf(assert false) )
75397538
# 7543 "ml/parser.ml"
75407539
: 'class_sig_field))
75417540
; (fun __caml_parser_env ->

jscomp/ml/parser.mly

+2-3
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ let mksig d = Sig.mk ~loc:(symbol_rloc()) d
3131
let mkmod ?attrs d = Mod.mk ~loc:(symbol_rloc()) ?attrs d
3232
let mkstr d = Str.mk ~loc:(symbol_rloc()) d
3333
let mkcty ?attrs d = Cty.mk ~loc:(symbol_rloc()) ?attrs d
34-
let mkctf ?attrs ?docs d =
35-
Ctf.mk ~loc:(symbol_rloc()) ?attrs ?docs d
34+
let mkctf ?attrs ?docs d = let _ = (attrs, docs) in assert false
3635
let mkcf ?attrs ?docs d = assert false
3736

3837
let mkrhs rhs pos = mkloc rhs (rhs_loc pos)
@@ -240,7 +239,7 @@ let mksig_ext d ext =
240239
let text_str pos = Str.text (rhs_text pos)
241240
let text_sig pos = Sig.text (rhs_text pos)
242241
let text_cstr pos = assert false
243-
let text_csig pos = Ctf.text (rhs_text pos)
242+
let text_csig _pos = assert false
244243

245244

246245
let extra_text text pos items =

jscomp/ml/parsetree.ml

-24
Original file line numberDiff line numberDiff line change
@@ -508,30 +508,6 @@ and class_type_desc =
508508
| Pcty_open of override_flag * Longident.t loc * class_type
509509
(* let open M in CT *)
510510

511-
and class_type_field =
512-
{
513-
pctf_desc: class_type_field_desc;
514-
pctf_loc: Location.t;
515-
pctf_attributes: attributes; (* ... [@@id1] [@@id2] *)
516-
}
517-
518-
and class_type_field_desc =
519-
| Pctf_inherit of class_type
520-
(* inherit CT *)
521-
| Pctf_val of (label loc * mutable_flag * virtual_flag * core_type)
522-
(* val x: T *)
523-
| Pctf_method of (label loc * private_flag * virtual_flag * core_type)
524-
(* method x: T
525-
526-
Note: T can be a Ptyp_poly.
527-
*)
528-
| Pctf_constraint of (core_type * core_type)
529-
(* constraint T1 = T2 *)
530-
| Pctf_attribute of attribute
531-
(* [@@@id] *)
532-
| Pctf_extension of extension
533-
(* [%%id] *)
534-
535511
and 'a class_infos =
536512
{
537513
pci_virt: virtual_flag;

jscomp/ml/untypeast.ml

-16
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ type mapper = {
2828
class_type: mapper -> T.class_type -> class_type;
2929
class_type_declaration: mapper -> T.class_type_declaration
3030
-> class_type_declaration;
31-
class_type_field: mapper -> T.class_type_field -> class_type_field;
3231
constructor_declaration: mapper -> T.constructor_declaration
3332
-> constructor_declaration;
3433
expr: mapper -> T.expression -> expression;
@@ -600,20 +599,6 @@ let class_type sub ct =
600599
in
601600
Cty.mk ~loc ~attrs desc
602601

603-
let class_type_field sub ctf =
604-
let loc = sub.location sub ctf.ctf_loc in
605-
let attrs = sub.attributes sub ctf.ctf_attributes in
606-
let desc = match ctf.ctf_desc with
607-
Tctf_inherit ct -> Pctf_inherit (sub.class_type sub ct)
608-
| Tctf_val (s, mut, virt, ct) ->
609-
Pctf_val (mkloc s loc, mut, virt, sub.typ sub ct)
610-
| Tctf_method (s, priv, virt, ct) ->
611-
Pctf_method (mkloc s loc, priv, virt, sub.typ sub ct)
612-
| Tctf_constraint (ct1, ct2) ->
613-
Pctf_constraint (sub.typ sub ct1, sub.typ sub ct2)
614-
| Tctf_attribute x -> Pctf_attribute x
615-
in
616-
Ctf.mk ~loc ~attrs desc
617602

618603
let core_type sub ct =
619604
let loc = sub.location sub ct.ctyp_loc in
@@ -672,7 +657,6 @@ let default_mapper =
672657
module_type = module_type;
673658
with_constraint = with_constraint;
674659
class_type = class_type;
675-
class_type_field = class_type_field;
676660
class_type_declaration = class_type_declaration;
677661
type_declaration = type_declaration;
678662
type_kind = type_kind;

jscomp/ml/untypeast.mli

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ type mapper = {
2525
class_type: mapper -> Typedtree.class_type -> class_type;
2626
class_type_declaration: mapper -> Typedtree.class_type_declaration
2727
-> class_type_declaration;
28-
class_type_field: mapper -> Typedtree.class_type_field -> class_type_field;
2928
constructor_declaration: mapper -> Typedtree.constructor_declaration
3029
-> constructor_declaration;
3130
expr: mapper -> Typedtree.expression -> expression;

0 commit comments

Comments
 (0)