@@ -37,7 +37,7 @@ type additional_action =
37
37
(* The [Prepare_for_saving] function should be applied to all layouts when
38
38
saving; this commons them up, truncates their histories, and runs
39
39
a check that all unconstrained variables have been defaulted to value. *)
40
- | Copy_types
40
+ | Duplicate_variables
41
41
| No_action
42
42
43
43
type t =
@@ -77,7 +77,7 @@ let add_modtype_path p ty s =
77
77
let add_modtype id ty s = add_modtype_path (Pident id) ty s
78
78
79
79
type additional_action_config =
80
- | Copy_types
80
+ | Duplicate_variables
81
81
| Prepare_for_saving
82
82
83
83
let with_additional_action (config : additional_action_config ) s =
@@ -93,7 +93,7 @@ let with_additional_action (config : additional_action_config) s =
93
93
*)
94
94
let additional_action : additional_action =
95
95
match config with
96
- | Copy_types -> Copy_types
96
+ | Duplicate_variables -> Duplicate_variables
97
97
| Prepare_for_saving ->
98
98
let reason = Layout. Imported in
99
99
let any = Layout. of_const Any ~why: reason in
@@ -122,7 +122,7 @@ let with_additional_action (config : additional_action_config) s =
122
122
let apply_prepare_layout s lay loc =
123
123
match s.additional_action with
124
124
| Prepare_for_saving prepare_layout -> prepare_layout loc lay
125
- | Copy_types | No_action -> lay
125
+ | Duplicate_variables | No_action -> lay
126
126
127
127
let change_locs s loc = { s with loc = Some loc; last_compose = None }
128
128
@@ -131,7 +131,7 @@ let loc s x =
131
131
| Some l -> l
132
132
| None -> begin
133
133
match s.additional_action with
134
- | Prepare_for_saving _ | Copy_types ->
134
+ | Prepare_for_saving _ | Duplicate_variables ->
135
135
if not ! Clflags. keep_locs then Location. none else x
136
136
| No_action -> x
137
137
end
@@ -148,21 +148,21 @@ let is_not_doc = function
148
148
| _ -> true
149
149
150
150
let attrs s x =
151
- (* Now that we track [Copy_types ] and [Prepare_for_saving] as
152
- separate states, we should reconsider whether the [Copy_types ]
151
+ (* Now that we track [Duplicate_variables ] and [Prepare_for_saving] as
152
+ separate states, we should reconsider whether the [Duplicate_variables ]
153
153
callsites really need to scrub docs and locations. For now, we're keeping
154
154
the scrubbing behavior for backward compatibility.
155
155
*)
156
156
let x =
157
157
match s.additional_action with
158
- | Prepare_for_saving _ | Copy_types ->
158
+ | Prepare_for_saving _ | Duplicate_variables ->
159
159
if not ! Clflags. keep_docs
160
160
then List. filter is_not_doc x
161
161
else x
162
162
| No_action -> x
163
163
in
164
164
match s.additional_action with
165
- | Prepare_for_saving _ | Copy_types ->
165
+ | Prepare_for_saving _ | Duplicate_variables ->
166
166
if not ! Clflags. keep_locs
167
167
then remove_loc.Ast_mapper. attributes remove_loc x
168
168
else x
@@ -248,18 +248,18 @@ let ctype_apply_env_empty = ref (fun _ -> assert false)
248
248
249
249
(* Similar to [Ctype.nondep_type_rec]. *)
250
250
let rec typexp copy_scope s ty =
251
- let should_copy_types =
251
+ let should_duplicate_vars =
252
252
match s.additional_action with
253
- | Copy_types | Prepare_for_saving _ -> true
253
+ | Duplicate_variables | Prepare_for_saving _ -> true
254
254
| No_action -> false
255
255
in
256
256
let desc = get_desc ty in
257
257
match desc with
258
258
Tvar _ | Tunivar _ ->
259
- if should_copy_types || get_id ty < 0 then
259
+ if should_duplicate_vars || get_id ty < 0 then
260
260
let ty' =
261
261
match s.additional_action with
262
- | Copy_types -> newpersty desc
262
+ | Duplicate_variables -> newpersty desc
263
263
| Prepare_for_saving prepare_layout ->
264
264
newpersty (norm desc ~prepare_layout )
265
265
| No_action -> newty2 ~level: (get_level ty) desc
@@ -269,7 +269,7 @@ let rec typexp copy_scope s ty =
269
269
else ty
270
270
| Tsubst (ty , _ ) ->
271
271
ty
272
- | Tfield (m, k, _t1, _t2) when not should_copy_types && m = dummy_method
272
+ | Tfield (m, k, _t1, _t2) when not should_duplicate_vars && m = dummy_method
273
273
&& field_kind_repr k <> Fabsent && get_level ty < generic_level ->
274
274
(* do not copy the type of self when it is not generalized *)
275
275
ty
@@ -284,7 +284,7 @@ let rec typexp copy_scope s ty =
284
284
(* Make a stub *)
285
285
let layout = Layout. any ~why: Dummy_layout in
286
286
let ty' =
287
- if should_copy_types then newpersty (Tvar {name = None ; layout})
287
+ if should_duplicate_vars then newpersty (Tvar {name = None ; layout})
288
288
else newgenstub ~scope: (get_scope ty) layout
289
289
in
290
290
For_copy. redirect_desc copy_scope ty (Tsubst (ty', None ));
@@ -331,15 +331,15 @@ let rec typexp copy_scope s ty =
331
331
Tlink ty2
332
332
| _ ->
333
333
let dup =
334
- should_copy_types || get_level more = generic_level ||
334
+ should_duplicate_vars || get_level more = generic_level ||
335
335
static_row row || is_Tconstr more in
336
336
(* Various cases for the row variable *)
337
337
let more' =
338
338
match mored with
339
339
Tsubst (ty , None) -> ty
340
340
| Tconstr _ | Tnil -> typexp copy_scope s more
341
341
| Tunivar _ | Tvar _ ->
342
- if should_copy_types then newpersty mored
342
+ if should_duplicate_vars then newpersty mored
343
343
else if dup && is_Tvar more then newgenty mored
344
344
else more
345
345
| _ -> assert false
@@ -446,7 +446,7 @@ let type_declaration' copy_scope s decl =
446
446
| Type_variant (cstrs , rep ) ->
447
447
let rep =
448
448
match s.additional_action with
449
- | No_action | Copy_types -> rep
449
+ | No_action | Duplicate_variables -> rep
450
450
| Prepare_for_saving prepare_layout ->
451
451
variant_representation ~prepare_layout decl.type_loc rep
452
452
in
@@ -455,7 +455,7 @@ let type_declaration' copy_scope s decl =
455
455
| Type_record (lbls , rep ) ->
456
456
let rep =
457
457
match s.additional_action with
458
- | No_action | Copy_types -> rep
458
+ | No_action | Duplicate_variables -> rep
459
459
| Prepare_for_saving prepare_layout ->
460
460
record_representation ~prepare_layout decl.type_loc rep
461
461
in
@@ -473,7 +473,7 @@ let type_declaration' copy_scope s decl =
473
473
match s.additional_action with
474
474
| Prepare_for_saving prepare_layout ->
475
475
prepare_layout decl.type_loc decl.type_layout
476
- | Copy_types | No_action -> decl.type_layout
476
+ | Duplicate_variables | No_action -> decl.type_layout
477
477
end ;
478
478
type_private = decl.type_private;
479
479
type_variance = decl.type_variance;
@@ -558,15 +558,15 @@ let extension_constructor' copy_scope s ext =
558
558
ext_arg_layouts = begin match s.additional_action with
559
559
| Prepare_for_saving prepare_layout ->
560
560
Array. map (prepare_layout ext.ext_loc) ext.ext_arg_layouts
561
- | Copy_types | No_action -> ext.ext_arg_layouts
561
+ | Duplicate_variables | No_action -> ext.ext_arg_layouts
562
562
end ;
563
563
ext_constant = ext.ext_constant;
564
564
ext_ret_type =
565
565
Option. map (typexp copy_scope s ext.ext_loc) ext.ext_ret_type;
566
566
ext_private = ext.ext_private;
567
567
ext_attributes = attrs s ext.ext_attributes;
568
568
ext_loc = begin match s.additional_action with
569
- | Prepare_for_saving _ | Copy_types -> Location. none
569
+ | Prepare_for_saving _ | Duplicate_variables -> Location. none
570
570
| No_action -> ext.ext_loc
571
571
end ;
572
572
ext_uid = ext.ext_uid;
@@ -821,13 +821,13 @@ and compose s1 s2 =
821
821
additional_action = begin
822
822
match s1.additional_action, s2.additional_action with
823
823
| action , No_action | No_action , action -> action
824
- | Copy_types , Copy_types -> Copy_types
824
+ | Duplicate_variables , Duplicate_variables -> Duplicate_variables
825
825
826
826
(* Preparing for saving runs a superset of the things involved with
827
827
copying variables, so we prefer that if composing substitutions.
828
828
*)
829
- | (Prepare_for_saving _ as prepare), Copy_types
830
- | Copy_types , (Prepare_for_saving _ as prepare)
829
+ | (Prepare_for_saving _ as prepare), Duplicate_variables
830
+ | Duplicate_variables , (Prepare_for_saving _ as prepare)
831
831
-> prepare
832
832
833
833
(* Note [Preparing_for_saving always the same]
0 commit comments