From cbfd5cd150bba4e672e8fc2f249b8cbf5557efce Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Sat, 11 Jan 2025 16:10:06 +0100 Subject: [PATCH 1/3] Remove more unused ast nodes for class and class type. --- analysis/reanalyze/src/Annotation.ml | 2 -- compiler/core/js_implementation.ml | 3 +-- compiler/frontend/bs_ast_invariant.ml | 3 --- compiler/frontend/bs_ast_mapper.ml | 4 ---- compiler/gentype/Annotation.ml | 8 ++------ compiler/gentype/TranslateSignature.ml | 6 ------ compiler/gentype/TranslateStructure.ml | 6 ------ compiler/ml/ast_iterator.ml | 4 ---- compiler/ml/ast_mapper.ml | 4 ---- compiler/ml/ast_mapper_from0.ml | 5 +++-- compiler/ml/ast_mapper_to0.ml | 4 ---- compiler/ml/depend.ml | 4 ---- compiler/ml/parsetree.ml | 4 ---- compiler/ml/pprintast.ml | 4 ---- compiler/ml/printast.ml | 4 ---- compiler/ml/printtyped.ml | 4 ---- compiler/ml/rec_check.ml | 2 -- compiler/ml/tast_iterator.ml | 4 ---- compiler/ml/tast_mapper.ml | 6 +----- compiler/ml/translmod.ml | 4 ++-- compiler/ml/typecore.ml | 9 ++------- compiler/ml/typedtree.ml | 4 ---- compiler/ml/typedtree.mli | 4 ---- compiler/ml/typedtreeIter.ml | 4 ---- compiler/ml/typemod.ml | 6 ------ compiler/syntax/src/res_ast_debugger.ml | 4 ---- compiler/syntax/src/res_comments_table.ml | 2 -- compiler/syntax/src/res_printer.ml | 2 -- 28 files changed, 11 insertions(+), 109 deletions(-) diff --git a/analysis/reanalyze/src/Annotation.ml b/analysis/reanalyze/src/Annotation.ml index 3e6429fb4a..ad522762dd 100644 --- a/analysis/reanalyze/src/Annotation.ml +++ b/analysis/reanalyze/src/Annotation.ml @@ -63,8 +63,6 @@ let rec getAttributePayload checkText (attributes : Typedtree.attributes) = | PStr ({pstr_desc = Pstr_recmodule _} :: _) -> Some UnrecognizedPayload | PStr ({pstr_desc = Pstr_modtype _} :: _) -> Some UnrecognizedPayload | PStr ({pstr_desc = Pstr_open _} :: _) -> Some UnrecognizedPayload - | PStr ({pstr_desc = Pstr_class _} :: _) -> Some UnrecognizedPayload - | PStr ({pstr_desc = Pstr_class_type _} :: _) -> Some UnrecognizedPayload | PStr ({pstr_desc = Pstr_include _} :: _) -> Some UnrecognizedPayload | PStr ({pstr_desc = Pstr_attribute _} :: _) -> Some UnrecognizedPayload | PPat _ -> Some UnrecognizedPayload diff --git a/compiler/core/js_implementation.ml b/compiler/core/js_implementation.ml index 9adcf8d0d0..5f4e4e6c76 100644 --- a/compiler/core/js_implementation.ml +++ b/compiler/core/js_implementation.ml @@ -96,8 +96,7 @@ let all_module_alias (ast : Parsetree.structure) = | Pstr_attribute _ -> true | Pstr_eval _ | Pstr_value _ | Pstr_primitive _ | Pstr_type _ | Pstr_typext _ | Pstr_exception _ | Pstr_module _ | Pstr_recmodule _ - | Pstr_modtype _ | Pstr_open _ | Pstr_class _ | Pstr_class_type _ - | Pstr_include _ | Pstr_extension _ -> + | Pstr_modtype _ | Pstr_open _ | Pstr_include _ | Pstr_extension _ -> false) let no_export (rest : Parsetree.structure) : Parsetree.structure = diff --git a/compiler/frontend/bs_ast_invariant.ml b/compiler/frontend/bs_ast_invariant.ml index 7da08fea57..fb4bfa370b 100644 --- a/compiler/frontend/bs_ast_invariant.ml +++ b/compiler/frontend/bs_ast_invariant.ml @@ -86,9 +86,6 @@ let emit_external_warnings : iterator = [{ptype_kind = Ptype_variant ({pcd_res = Some _} :: _)}] ) -> Location.raise_errorf ~loc:str_item.pstr_loc "GADT has to be recursive types, please try `type rec'" - | Pstr_class _ -> - Location.raise_errorf ~loc:str_item.pstr_loc - "OCaml style classes are not supported" | _ -> super.structure_item self str_item); expr = (fun self ({pexp_loc = loc} as a) -> diff --git a/compiler/frontend/bs_ast_mapper.ml b/compiler/frontend/bs_ast_mapper.ml index 292fe15b9c..dd8ca6cf75 100644 --- a/compiler/frontend/bs_ast_mapper.ml +++ b/compiler/frontend/bs_ast_mapper.ml @@ -232,8 +232,6 @@ module MT = struct | Psig_modtype x -> modtype ~loc (sub.module_type_declaration sub x) | Psig_open x -> open_ ~loc (sub.open_description sub x) | Psig_include x -> include_ ~loc (sub.include_description sub x) - | Psig_class () -> assert false - | Psig_class_type () -> assert false | Psig_extension (x, attrs) -> extension ~loc (sub.extension sub x) ~attrs:(sub.attributes sub attrs) | Psig_attribute x -> attribute ~loc (sub.attribute sub x) @@ -287,8 +285,6 @@ module M = struct | Pstr_recmodule l -> rec_module ~loc (List.map (sub.module_binding sub) l) | Pstr_modtype x -> modtype ~loc (sub.module_type_declaration sub x) | Pstr_open x -> open_ ~loc (sub.open_description sub x) - | Pstr_class () -> {pstr_loc = loc; pstr_desc = Pstr_class ()} - | Pstr_class_type () -> {pstr_loc = loc; pstr_desc = Pstr_class_type ()} | Pstr_include x -> include_ ~loc (sub.include_declaration sub x) | Pstr_extension (x, attrs) -> extension ~loc (sub.extension sub x) ~attrs:(sub.attributes sub attrs) diff --git a/compiler/gentype/Annotation.ml b/compiler/gentype/Annotation.ml index 6f1dbd1dce..9c66678b38 100644 --- a/compiler/gentype/Annotation.ml +++ b/compiler/gentype/Annotation.ml @@ -83,8 +83,6 @@ let rec get_attribute_payload check_text (attributes : Typedtree.attributes) = | PStr ({pstr_desc = Pstr_recmodule _} :: _) -> Some UnrecognizedPayload | PStr ({pstr_desc = Pstr_modtype _} :: _) -> Some UnrecognizedPayload | PStr ({pstr_desc = Pstr_open _} :: _) -> Some UnrecognizedPayload - | PStr ({pstr_desc = Pstr_class _} :: _) -> Some UnrecognizedPayload - | PStr ({pstr_desc = Pstr_class_type _} :: _) -> Some UnrecognizedPayload | PStr ({pstr_desc = Pstr_include _} :: _) -> Some UnrecognizedPayload | PStr ({pstr_desc = Pstr_attribute _} :: _) -> Some UnrecognizedPayload | PPat _ -> Some UnrecognizedPayload @@ -224,7 +222,7 @@ and signature_item_check_annotation ~check_annotation module_type_declaration |> module_type_declaration_check_annotation ~check_annotation | Tsig_typext _ | Tsig_exception _ | Tsig_recmodule _ | Tsig_open _ - | Tsig_include _ | Tsig_class _ | Tsig_class_type _ -> + | Tsig_include _ -> false and signature_check_annotation ~check_annotation @@ -260,9 +258,7 @@ let rec structure_item_check_annotation ~check_annotation |> module_type_declaration_check_annotation ~check_annotation | Tstr_attribute attribute -> [attribute] |> check_annotation ~loc:structure_item.str_loc - | Tstr_eval _ | Tstr_typext _ | Tstr_exception _ | Tstr_open _ | Tstr_class _ - | Tstr_class_type _ -> - false + | Tstr_eval _ | Tstr_typext _ | Tstr_exception _ | Tstr_open _ -> false and module_expr_check_annotation ~check_annotation (module_expr : Typedtree.module_expr) = diff --git a/compiler/gentype/TranslateSignature.ml b/compiler/gentype/TranslateSignature.ml index 5c3d835f7b..0033ab1edb 100644 --- a/compiler/gentype/TranslateSignature.ml +++ b/compiler/gentype/TranslateSignature.ml @@ -156,12 +156,6 @@ and translate_signature_item ~config ~output_file_relative ~resolver ~type_env | {Typedtree.sig_desc = Typedtree.Tsig_include _} -> log_not_implemented ("Tsig_include " ^ __LOC__); Translation.empty - | {Typedtree.sig_desc = Typedtree.Tsig_class _} -> - log_not_implemented ("Tsig_class " ^ __LOC__); - Translation.empty - | {Typedtree.sig_desc = Typedtree.Tsig_class_type _} -> - log_not_implemented ("Tsig_class_type " ^ __LOC__); - Translation.empty | {Typedtree.sig_desc = Typedtree.Tsig_attribute _} -> log_not_implemented ("Tsig_attribute " ^ __LOC__); Translation.empty diff --git a/compiler/gentype/TranslateStructure.ml b/compiler/gentype/TranslateStructure.ml index 3def28f4a8..9a64cd34a6 100644 --- a/compiler/gentype/TranslateStructure.ml +++ b/compiler/gentype/TranslateStructure.ml @@ -352,12 +352,6 @@ and translate_structure_item ~config ~output_file_relative ~resolver ~type_env | {str_desc = Tstr_open _} -> log_not_implemented ("Tstr_open " ^ __LOC__); Translation.empty - | {str_desc = Tstr_class _} -> - log_not_implemented ("Tstr_class " ^ __LOC__); - Translation.empty - | {str_desc = Tstr_class_type _} -> - log_not_implemented ("Tstr_class_type " ^ __LOC__); - Translation.empty | {str_desc = Tstr_attribute _} -> log_not_implemented ("Tstr_attribute " ^ __LOC__); Translation.empty diff --git a/compiler/ml/ast_iterator.ml b/compiler/ml/ast_iterator.ml index 2c76f6e5b4..8bae0d9154 100644 --- a/compiler/ml/ast_iterator.ml +++ b/compiler/ml/ast_iterator.ml @@ -216,8 +216,6 @@ module MT = struct | Psig_modtype x -> sub.module_type_declaration sub x | Psig_open x -> sub.open_description sub x | Psig_include x -> sub.include_description sub x - | Psig_class () -> () - | Psig_class_type () -> () | Psig_extension (x, attrs) -> sub.extension sub x; sub.attributes sub attrs @@ -261,8 +259,6 @@ module M = struct | Pstr_recmodule l -> List.iter (sub.module_binding sub) l | Pstr_modtype x -> sub.module_type_declaration sub x | Pstr_open x -> sub.open_description sub x - | Pstr_class () -> () - | Pstr_class_type () -> () | Pstr_include x -> sub.include_declaration sub x | Pstr_extension (x, attrs) -> sub.extension sub x; diff --git a/compiler/ml/ast_mapper.ml b/compiler/ml/ast_mapper.ml index 854e003c99..a4d9e5b382 100644 --- a/compiler/ml/ast_mapper.ml +++ b/compiler/ml/ast_mapper.ml @@ -215,8 +215,6 @@ module MT = struct | Psig_modtype x -> modtype ~loc (sub.module_type_declaration sub x) | Psig_open x -> open_ ~loc (sub.open_description sub x) | Psig_include x -> include_ ~loc (sub.include_description sub x) - | Psig_class _ -> assert false - | Psig_class_type _ -> assert false | Psig_extension (x, attrs) -> extension ~loc (sub.extension sub x) ~attrs:(sub.attributes sub attrs) | Psig_attribute x -> attribute ~loc (sub.attribute sub x) @@ -258,8 +256,6 @@ module M = struct | Pstr_recmodule l -> rec_module ~loc (List.map (sub.module_binding sub) l) | Pstr_modtype x -> modtype ~loc (sub.module_type_declaration sub x) | Pstr_open x -> open_ ~loc (sub.open_description sub x) - | Pstr_class () -> {pstr_loc = loc; pstr_desc = Pstr_class ()} - | Pstr_class_type () -> {pstr_loc = loc; pstr_desc = Pstr_class_type ()} | Pstr_include x -> include_ ~loc (sub.include_declaration sub x) | Pstr_extension (x, attrs) -> extension ~loc (sub.extension sub x) ~attrs:(sub.attributes sub attrs) diff --git a/compiler/ml/ast_mapper_from0.ml b/compiler/ml/ast_mapper_from0.ml index 22d59a792f..fbb5194481 100644 --- a/compiler/ml/ast_mapper_from0.ml +++ b/compiler/ml/ast_mapper_from0.ml @@ -283,8 +283,9 @@ module M = struct | Pstr_recmodule l -> rec_module ~loc (List.map (sub.module_binding sub) l) | Pstr_modtype x -> modtype ~loc (sub.module_type_declaration sub x) | Pstr_open x -> open_ ~loc (sub.open_description sub x) - | Pstr_class () -> {pstr_loc = loc; pstr_desc = Pstr_class ()} - | Pstr_class_type () -> {pstr_loc = loc; pstr_desc = Pstr_class_type ()} + | Pstr_class () -> failwith "Pstr_class is no longer present in ReScript" + | Pstr_class_type () -> + failwith "Pstr_class_type is no longer present in ReScript" | Pstr_include x -> include_ ~loc (sub.include_declaration sub x) | Pstr_extension (x, attrs) -> extension ~loc (sub.extension sub x) ~attrs:(sub.attributes sub attrs) diff --git a/compiler/ml/ast_mapper_to0.ml b/compiler/ml/ast_mapper_to0.ml index 68be8b7cbf..9cbd9f3303 100644 --- a/compiler/ml/ast_mapper_to0.ml +++ b/compiler/ml/ast_mapper_to0.ml @@ -232,8 +232,6 @@ module MT = struct | Psig_modtype x -> modtype ~loc (sub.module_type_declaration sub x) | Psig_open x -> open_ ~loc (sub.open_description sub x) | Psig_include x -> include_ ~loc (sub.include_description sub x) - | Psig_class _ -> assert false - | Psig_class_type _ -> assert false | Psig_extension (x, attrs) -> extension ~loc (sub.extension sub x) ~attrs:(sub.attributes sub attrs) | Psig_attribute x -> attribute ~loc (sub.attribute sub x) @@ -275,8 +273,6 @@ module M = struct | Pstr_recmodule l -> rec_module ~loc (List.map (sub.module_binding sub) l) | Pstr_modtype x -> modtype ~loc (sub.module_type_declaration sub x) | Pstr_open x -> open_ ~loc (sub.open_description sub x) - | Pstr_class () -> {pstr_loc = loc; pstr_desc = Pstr_class ()} - | Pstr_class_type () -> {pstr_loc = loc; pstr_desc = Pstr_class_type ()} | Pstr_include x -> include_ ~loc (sub.include_declaration sub x) | Pstr_extension (x, attrs) -> extension ~loc (sub.extension sub x) ~attrs:(sub.attributes sub attrs) diff --git a/compiler/ml/depend.ml b/compiler/ml/depend.ml index 47d54954f6..be6e3224fc 100644 --- a/compiler/ml/depend.ml +++ b/compiler/ml/depend.ml @@ -385,8 +385,6 @@ and add_sig_item (bv, m) item = add_names s; let add = StringMap.fold StringMap.add m' in (add bv, add m) - | Psig_class () -> (bv, m) - | Psig_class_type () -> (bv, m) | Psig_attribute _ -> (bv, m) | Psig_extension (e, _) -> handle_extension e; @@ -471,8 +469,6 @@ and add_struct_item (bv, m) item : _ StringMap.t * _ StringMap.t = | Some mty -> add_modtype bv mty); (bv, m) | Pstr_open od -> (open_module bv od.popen_lid.txt, m) - | Pstr_class () -> (bv, m) - | Pstr_class_type () -> (bv, m) | Pstr_include incl -> let (Node (s, m')) = add_module_binding bv incl.pincl_mod in add_names s; diff --git a/compiler/ml/parsetree.ml b/compiler/ml/parsetree.ml index a56f4c9439..0c9beb4bb9 100644 --- a/compiler/ml/parsetree.ml +++ b/compiler/ml/parsetree.ml @@ -476,8 +476,6 @@ and signature_item_desc = module type S *) | Psig_open of open_description (* open X *) | Psig_include of include_description (* include MT *) - | Psig_class of unit (* Dummy AST node *) - | Psig_class_type of unit (* Dummy AST node *) | Psig_attribute of attribute (* [@@@id] *) | Psig_extension of extension * attributes (* [%%id] *) @@ -578,8 +576,6 @@ and structure_item_desc = (* module rec X1 = ME1 and ... and Xn = MEn *) | Pstr_modtype of module_type_declaration (* module type S = MT *) | Pstr_open of open_description (* open X *) - | Pstr_class of unit (* Dummy AST node *) - | Pstr_class_type of unit (* Dummy AST node *) | Pstr_include of include_declaration (* include ME *) | Pstr_attribute of attribute (* [@@@id] *) | Pstr_extension of extension * attributes diff --git a/compiler/ml/pprintast.ml b/compiler/ml/pprintast.ml index 2517d60e7d..d6e4c7f0c2 100644 --- a/compiler/ml/pprintast.ml +++ b/compiler/ml/pprintast.ml @@ -883,7 +883,6 @@ and signature_item ctxt f x : unit = (value_description ctxt) vd (item_attributes ctxt) vd.pval_attributes | Psig_typext te -> type_extension ctxt f te | Psig_exception ed -> exception_declaration ctxt f ed - | Psig_class () -> () | Psig_module ({pmd_type = {pmty_desc = Pmty_alias alias; pmty_attributes = []; _}; _} as pmd) -> @@ -908,7 +907,6 @@ and signature_item ctxt f x : unit = pp_print_space f (); pp f "@ =@ %a" (module_type ctxt) mt) md (item_attributes ctxt) attrs - | Psig_class_type () -> () | Psig_recmodule decls -> let rec string_x_module_type_list f ?(first = true) l = match l with @@ -1115,8 +1113,6 @@ and structure_item ctxt f x = pp_print_space f (); pp f "@ =@ %a" (module_type ctxt) mt) md (item_attributes ctxt) attrs - | Pstr_class () -> () - | Pstr_class_type () -> () | Pstr_primitive vd -> pp f "@[external@ %a@ :@ %a@]%a" protect_ident vd.pval_name.txt (value_description ctxt) vd (item_attributes ctxt) vd.pval_attributes diff --git a/compiler/ml/printast.ml b/compiler/ml/printast.ml index 9af6ff95fc..2469a13256 100644 --- a/compiler/ml/printast.ml +++ b/compiler/ml/printast.ml @@ -490,8 +490,6 @@ and signature_item i ppf x = line i ppf "Psig_include\n"; module_type i ppf incl.pincl_mod; attributes i ppf incl.pincl_attributes - | Psig_class () -> () - | Psig_class_type () -> () | Psig_extension ((s, arg), attrs) -> line i ppf "Psig_extension \"%s\"\n" s.txt; attributes i ppf attrs; @@ -586,8 +584,6 @@ and structure_item i ppf x = line i ppf "Pstr_open %a %a\n" fmt_override_flag od.popen_override fmt_longident_loc od.popen_lid; attributes i ppf od.popen_attributes - | Pstr_class () -> () - | Pstr_class_type () -> () | Pstr_include incl -> line i ppf "Pstr_include"; attributes i ppf incl.pincl_attributes; diff --git a/compiler/ml/printtyped.ml b/compiler/ml/printtyped.ml index 24aea0b5f6..c7ff2df230 100644 --- a/compiler/ml/printtyped.ml +++ b/compiler/ml/printtyped.ml @@ -499,8 +499,6 @@ and signature_item i ppf x = line i ppf "Tsig_include\n"; attributes i ppf incl.incl_attributes; module_type i ppf incl.incl_mod - | Tsig_class () -> () - | Tsig_class_type () -> () | Tsig_attribute (s, arg) -> line i ppf "Tsig_attribute \"%s\"\n" s.txt; Printast.payload i ppf arg @@ -595,8 +593,6 @@ and structure_item i ppf x = line i ppf "Tstr_open %a %a\n" fmt_override_flag od.open_override fmt_path od.open_path; attributes i ppf od.open_attributes - | Tstr_class () -> () - | Tstr_class_type () -> () | Tstr_include incl -> line i ppf "Tstr_include"; attributes i ppf incl.incl_attributes; diff --git a/compiler/ml/rec_check.ml b/compiler/ml/rec_check.ml index e8b523882e..43f13b4e2c 100644 --- a/compiler/ml/rec_check.ml +++ b/compiler/ml/rec_check.ml @@ -356,8 +356,6 @@ and structure_item : Env.env -> Typedtree.structure_item -> Env.env * Use.t = | Tstr_exception _ -> (Env.empty, Use.empty) | Tstr_modtype _ -> (Env.empty, Use.empty) | Tstr_open _ -> (Env.empty, Use.empty) - | Tstr_class () -> (Env.empty, Use.empty) - | Tstr_class_type _ -> (Env.empty, Use.empty) | Tstr_include inc -> (* This is a kind of projection. There's no need to add anything to the environment because everything is used in diff --git a/compiler/ml/tast_iterator.ml b/compiler/ml/tast_iterator.ml index e9d0d1688f..cb546aba4f 100644 --- a/compiler/ml/tast_iterator.ml +++ b/compiler/ml/tast_iterator.ml @@ -69,8 +69,6 @@ let structure_item sub {str_desc; str_env; _} = | Tstr_module mb -> sub.module_binding sub mb | Tstr_recmodule list -> List.iter (sub.module_binding sub) list | Tstr_modtype x -> sub.module_type_declaration sub x - | Tstr_class _ -> () - | Tstr_class_type () -> () | Tstr_include incl -> include_infos (sub.module_expr sub) incl | Tstr_open _ -> () | Tstr_attribute _ -> () @@ -226,8 +224,6 @@ let signature_item sub {sig_desc; sig_env; _} = | Tsig_recmodule list -> List.iter (sub.module_declaration sub) list | Tsig_modtype x -> sub.module_type_declaration sub x | Tsig_include incl -> include_infos (sub.module_type sub) incl - | Tsig_class () -> () - | Tsig_class_type () -> () | Tsig_open _od -> () | Tsig_attribute _ -> () diff --git a/compiler/ml/tast_mapper.ml b/compiler/ml/tast_mapper.ml index 2a351d783e..0b3bbdef67 100644 --- a/compiler/ml/tast_mapper.ml +++ b/compiler/ml/tast_mapper.ml @@ -99,8 +99,6 @@ let structure_item sub {str_desc; str_loc; str_env} = | Tstr_recmodule list -> Tstr_recmodule (List.map (sub.module_binding sub) list) | Tstr_modtype x -> Tstr_modtype (sub.module_type_declaration sub x) - | Tstr_class () -> Tstr_class () - | Tstr_class_type () -> Tstr_class_type () | Tstr_include incl -> Tstr_include (include_infos (sub.module_expr sub) incl) | (Tstr_open _ | Tstr_attribute _) as d -> d @@ -283,9 +281,7 @@ let signature_item sub x = | Tsig_modtype x -> Tsig_modtype (sub.module_type_declaration sub x) | Tsig_include incl -> Tsig_include (include_infos (sub.module_type sub) incl) - | (Tsig_class_type _ | Tsig_class _ | Tsig_open _ | Tsig_attribute _) as d - -> - d + | (Tsig_open _ | Tsig_attribute _) as d -> d in {x with sig_desc; sig_env} diff --git a/compiler/ml/translmod.ml b/compiler/ml/translmod.ml index 60f02bcfc9..e3e0ead663 100644 --- a/compiler/ml/translmod.ml +++ b/compiler/ml/translmod.ml @@ -474,8 +474,8 @@ and transl_structure loc fields cc rootpath final_env = function transl_module Tcoerce_none None modl, body ), size ) - | Tstr_class _ | Tstr_primitive _ | Tstr_type _ | Tstr_modtype _ - | Tstr_open _ | Tstr_class_type _ | Tstr_attribute _ -> + | Tstr_primitive _ | Tstr_type _ | Tstr_modtype _ | Tstr_open _ + | Tstr_attribute _ -> transl_structure loc fields cc rootpath final_env rem) (* Update forward declaration in Translcore *) diff --git a/compiler/ml/typecore.ml b/compiler/ml/typecore.ml index 1780de9958..90eb7797e3 100644 --- a/compiler/ml/typecore.ml +++ b/compiler/ml/typecore.ml @@ -197,14 +197,11 @@ let iter_expression f e = | Pstr_eval (e, _) -> expr e | Pstr_value (_, pel) -> List.iter binding pel | Pstr_primitive _ | Pstr_type _ | Pstr_typext _ | Pstr_exception _ - | Pstr_modtype _ | Pstr_open _ - | Pstr_class_type () - | Pstr_attribute _ | Pstr_extension _ -> + | Pstr_modtype _ | Pstr_open _ | Pstr_attribute _ | Pstr_extension _ -> () | Pstr_include {pincl_mod = me} | Pstr_module {pmb_expr = me} -> module_expr me | Pstr_recmodule l -> List.iter (fun x -> module_expr x.pmb_expr) l - | Pstr_class () -> () in expr e @@ -1853,8 +1850,7 @@ and is_nonexpansive_mod mexp = (fun item -> match item.str_desc with | Tstr_eval _ | Tstr_primitive _ | Tstr_type _ | Tstr_modtype _ - | Tstr_open _ - | Tstr_class_type () -> + | Tstr_open _ -> true | Tstr_value (_, pat_exp_list) -> List.for_all (fun vb -> is_nonexpansive vb.vb_expr) pat_exp_list @@ -1873,7 +1869,6 @@ and is_nonexpansive_mod mexp = | {ext_kind = Text_decl _} -> false | {ext_kind = Text_rebind _} -> true) te.tyext_constructors - | Tstr_class () -> assert false (* impossible *) | Tstr_attribute _ -> true) str.str_items | Tmod_apply _ -> false diff --git a/compiler/ml/typedtree.ml b/compiler/ml/typedtree.ml index 52a08ef16c..c9e7fd9ae2 100644 --- a/compiler/ml/typedtree.ml +++ b/compiler/ml/typedtree.ml @@ -180,8 +180,6 @@ and structure_item_desc = | Tstr_recmodule of module_binding list | Tstr_modtype of module_type_declaration | Tstr_open of open_description - | Tstr_class of unit - | Tstr_class_type of unit | Tstr_include of include_declaration | Tstr_attribute of attribute @@ -257,8 +255,6 @@ and signature_item_desc = | Tsig_modtype of module_type_declaration | Tsig_open of open_description | Tsig_include of include_description - | Tsig_class of unit - | Tsig_class_type of unit | Tsig_attribute of attribute and module_declaration = { diff --git a/compiler/ml/typedtree.mli b/compiler/ml/typedtree.mli index 5d8819668f..ac69b510fb 100644 --- a/compiler/ml/typedtree.mli +++ b/compiler/ml/typedtree.mli @@ -286,8 +286,6 @@ and structure_item_desc = | Tstr_recmodule of module_binding list | Tstr_modtype of module_type_declaration | Tstr_open of open_description - | Tstr_class of unit - | Tstr_class_type of unit | Tstr_include of include_declaration | Tstr_attribute of attribute @@ -362,8 +360,6 @@ and signature_item_desc = | Tsig_modtype of module_type_declaration | Tsig_open of open_description | Tsig_include of include_description - | Tsig_class of unit - | Tsig_class_type of unit | Tsig_attribute of attribute and module_declaration = { diff --git a/compiler/ml/typedtreeIter.ml b/compiler/ml/typedtreeIter.ml index 008d9cab56..c616ae257d 100644 --- a/compiler/ml/typedtreeIter.ml +++ b/compiler/ml/typedtreeIter.ml @@ -118,8 +118,6 @@ end = struct | Tstr_recmodule list -> List.iter iter_module_binding list | Tstr_modtype mtd -> iter_module_type_declaration mtd | Tstr_open _ -> () - | Tstr_class () -> () - | Tstr_class_type () -> () | Tstr_include incl -> iter_module_expr incl.incl_mod | Tstr_attribute _ -> ()); Iter.leave_structure_item item @@ -321,8 +319,6 @@ end = struct | Tsig_modtype mtd -> iter_module_type_declaration mtd | Tsig_open _ -> () | Tsig_include incl -> iter_module_type incl.incl_mod - | Tsig_class () -> () - | Tsig_class_type () -> () | Tsig_attribute _ -> ()); Iter.leave_signature_item item diff --git a/compiler/ml/typemod.ml b/compiler/ml/typemod.ml index 8ff9cb44c5..be6ac27e51 100644 --- a/compiler/ml/typemod.ml +++ b/compiler/ml/typemod.ml @@ -573,8 +573,6 @@ and approx_sig env ssg = in let newenv = Env.add_signature sg env in sg @ approx_sig newenv srem - | Psig_class_type () -> assert false - | Psig_class () -> assert false | _ -> approx_sig env srem) and approx_modtype_info env sinfo = @@ -870,8 +868,6 @@ and transl_signature env sg = in let trem, rem, final_env = transl_sig newenv srem in (mksig (Tsig_include incl) env loc :: trem, sg @ rem, final_env) - | Psig_class _ -> assert false - | Psig_class_type _ -> assert false | Psig_attribute x -> Builtin_attributes.warning_attribute x; let trem, rem, final_env = transl_sig env srem in @@ -1567,8 +1563,6 @@ and type_structure ?(toplevel = false) funct_body anchor env sstr scope = | Pstr_open sod -> let _path, newenv, od = type_open ~toplevel env sod in (Tstr_open od, [], newenv) - | Pstr_class () -> assert false - | Pstr_class_type () -> assert false | Pstr_include sincl -> let smodl = sincl.pincl_mod in let modl = diff --git a/compiler/syntax/src/res_ast_debugger.ml b/compiler/syntax/src/res_ast_debugger.ml index 6ed8dbbea4..caaaaa6bdd 100644 --- a/compiler/syntax/src/res_ast_debugger.ml +++ b/compiler/syntax/src/res_ast_debugger.ml @@ -179,8 +179,6 @@ module SexpAst = struct [Sexp.atom "Pstr_modtype"; module_type_declaration mod_typ_decl] | Pstr_open open_desc -> Sexp.list [Sexp.atom "Pstr_open"; open_description open_desc] - | Pstr_class _ -> Sexp.atom "Pstr_class" - | Pstr_class_type _ -> Sexp.atom "Pstr_class_type" | Pstr_include id -> Sexp.list [Sexp.atom "Pstr_include"; include_declaration id] | Pstr_attribute attr -> @@ -361,8 +359,6 @@ module SexpAst = struct Sexp.list [Sexp.atom "Psig_open"; open_description open_desc] | Psig_include incl_decl -> Sexp.list [Sexp.atom "Psig_include"; include_description incl_decl] - | Psig_class _ -> Sexp.list [Sexp.atom "Psig_class"] - | Psig_class_type _ -> Sexp.list [Sexp.atom "Psig_class_type"] | Psig_attribute attr -> Sexp.list [Sexp.atom "Psig_attribute"; attribute attr] | Psig_extension (ext, attrs) -> diff --git a/compiler/syntax/src/res_comments_table.ml b/compiler/syntax/src/res_comments_table.ml index 4f40f7f151..523d1289c8 100644 --- a/compiler/syntax/src/res_comments_table.ml +++ b/compiler/syntax/src/res_comments_table.ml @@ -436,7 +436,6 @@ and walk_structure_item si t comments = | Pstr_exception extension_constructor -> walk_extension_constructor extension_constructor t comments | Pstr_typext type_extension -> walk_type_extension type_extension t comments - | Pstr_class_type _ | Pstr_class _ -> () and walk_value_description vd t comments = let leading, trailing = @@ -545,7 +544,6 @@ and walk_signature_item (si : Parsetree.signature_item) t comments = walk_include_description include_description t comments | Psig_attribute attribute -> walk_attribute attribute t comments | Psig_extension (extension, _) -> walk_extension extension t comments - | Psig_class _ | Psig_class_type _ -> () and walk_include_description id t comments = let before, inside, after = partition_by_loc comments id.pincl_mod.pmty_loc in diff --git a/compiler/syntax/src/res_printer.ml b/compiler/syntax/src/res_printer.ml index 60e302a1cb..6aa9aa809f 100644 --- a/compiler/syntax/src/res_printer.ml +++ b/compiler/syntax/src/res_printer.ml @@ -614,7 +614,6 @@ and print_structure_item ~state (si : Parsetree.structure_item) cmt_tbl = print_exception_def ~state extension_constructor cmt_tbl | Pstr_typext type_extension -> print_type_extension ~state type_extension cmt_tbl - | Pstr_class _ | Pstr_class_type _ -> Doc.nil and print_type_extension ~state (te : Parsetree.type_extension) cmt_tbl = let prefix = Doc.text "type " in @@ -974,7 +973,6 @@ and print_signature_item ~state (si : Parsetree.signature_item) cmt_tbl = Doc.concat [print_extension ~state ~at_module_lvl:true extension cmt_tbl]; ] - | Psig_class _ | Psig_class_type _ -> Doc.nil and print_rec_module_declarations ~state module_declarations cmt_tbl = print_listi From 03e148624b59546ffc33b18381e5630ac3e6e70a Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Sat, 11 Jan 2025 16:16:01 +0100 Subject: [PATCH 2/3] Remove unused arg of Texp_coerce --- CHANGELOG.md | 1 + compiler/ml/printtyped.ml | 2 +- compiler/ml/tast_iterator.ml | 2 +- compiler/ml/tast_mapper.ml | 2 +- compiler/ml/typecore.ml | 2 +- compiler/ml/typedtree.ml | 2 +- compiler/ml/typedtree.mli | 3 +-- compiler/ml/typedtreeIter.ml | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae187fc1ff..83be210053 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ - AST cleanup: Remove `@res.async` attribute from the internal representation, and add a flag to untyped and typed ASTs instead. https://github.com/rescript-lang/rescript/pull/7234 - AST cleanup: Remove `expression_desc.Pexp_new`, `expression_desc.Pexp_setinstvar`, `expression_desc.Pexp_override`, `expression_desc.Pexp_poly`, `exp_extra.Texp_poly`, `expression_desc.Texp_new`, `expression_desc.Texp_setinstvar`, `expression_desc.Texp_override` & `expression_desc.Texp_instvar` from AST as it is unused. https://github.com/rescript-lang/rescript/pull/7239 - AST cleanup: Remove `@res.partial` attribute from the internal representation, and add a flag to untyped and typed ASTs instead. https://github.com/rescript-lang/rescript/pull/7238 https://github.com/rescript-lang/rescript/pull/7240 +- AST cleanup: Remove more unused ast nodes for class and class type. https://github.com/rescript-lang/rescript/pull/7243 # 12.0.0-alpha.7 diff --git a/compiler/ml/printtyped.ml b/compiler/ml/printtyped.ml index c7ff2df230..31cb9ef213 100644 --- a/compiler/ml/printtyped.ml +++ b/compiler/ml/printtyped.ml @@ -252,7 +252,7 @@ and expression_extra i ppf x attrs = line i ppf "Texp_constraint\n"; attributes i ppf attrs; core_type i ppf ct - | Texp_coerce ((), cto2) -> + | Texp_coerce cto2 -> line i ppf "Texp_coerce\n"; attributes i ppf attrs; core_type i ppf cto2 diff --git a/compiler/ml/tast_iterator.ml b/compiler/ml/tast_iterator.ml index cb546aba4f..3220aa87fe 100644 --- a/compiler/ml/tast_iterator.ml +++ b/compiler/ml/tast_iterator.ml @@ -140,7 +140,7 @@ let pat sub {pat_extra; pat_desc; pat_env; _} = let expr sub {exp_extra; exp_desc; exp_env; _} = let extra = function | Texp_constraint cty -> sub.typ sub cty - | Texp_coerce ((), cty2) -> sub.typ sub cty2 + | Texp_coerce cty2 -> sub.typ sub cty2 | Texp_newtype _ -> () | Texp_open (_, _, _, _) -> () in diff --git a/compiler/ml/tast_mapper.ml b/compiler/ml/tast_mapper.ml index 0b3bbdef67..8064d65990 100644 --- a/compiler/ml/tast_mapper.ml +++ b/compiler/ml/tast_mapper.ml @@ -183,7 +183,7 @@ let pat sub x = let expr sub x = let extra = function | Texp_constraint cty -> Texp_constraint (sub.typ sub cty) - | Texp_coerce ((), cty2) -> Texp_coerce ((), sub.typ sub cty2) + | Texp_coerce cty2 -> Texp_coerce (sub.typ sub cty2) | Texp_open (ovf, path, loc, env) -> Texp_open (ovf, path, loc, sub.env sub env) | Texp_newtype _ as d -> d diff --git a/compiler/ml/typecore.ml b/compiler/ml/typecore.ml index 90eb7797e3..c35a45702f 100644 --- a/compiler/ml/typecore.ml +++ b/compiler/ml/typecore.ml @@ -2974,7 +2974,7 @@ and type_expect_ ?type_clash_context ?in_function ?(recarg = Rejected) env sexp exp_attributes = arg.exp_attributes; exp_env = env; exp_extra = - (Texp_coerce ((), cty'), loc, sexp.pexp_attributes) :: arg.exp_extra; + (Texp_coerce cty', loc, sexp.pexp_attributes) :: arg.exp_extra; } | Pexp_send (e, {txt = met}) -> ( let obj = type_exp env e in diff --git a/compiler/ml/typedtree.ml b/compiler/ml/typedtree.ml index c9e7fd9ae2..daa9880711 100644 --- a/compiler/ml/typedtree.ml +++ b/compiler/ml/typedtree.ml @@ -67,7 +67,7 @@ and expression = { and exp_extra = | Texp_constraint of core_type - | Texp_coerce of unit * core_type + | Texp_coerce of core_type | Texp_open of override_flag * Path.t * Longident.t loc * Env.t | Texp_newtype of string diff --git a/compiler/ml/typedtree.mli b/compiler/ml/typedtree.mli index ac69b510fb..f88f5198e4 100644 --- a/compiler/ml/typedtree.mli +++ b/compiler/ml/typedtree.mli @@ -110,8 +110,7 @@ and expression = { and exp_extra = | Texp_constraint of core_type (** E : T *) - | Texp_coerce of unit * core_type - (** E :> T [Texp_coerce T] + | Texp_coerce of core_type (** _ :> T [Texp_coerce T] *) | Texp_open of override_flag * Path.t * Longident.t loc * Env.t (** let open[!] M in [Texp_open (!, P, M, env)] diff --git a/compiler/ml/typedtreeIter.ml b/compiler/ml/typedtreeIter.ml index c616ae257d..e0fe1e228e 100644 --- a/compiler/ml/typedtreeIter.ml +++ b/compiler/ml/typedtreeIter.ml @@ -217,7 +217,7 @@ end = struct | cstr, _, _attrs -> ( match cstr with | Texp_constraint ct -> iter_core_type ct - | Texp_coerce ((), cty2) -> iter_core_type cty2 + | Texp_coerce cty2 -> iter_core_type cty2 | Texp_open _ -> () | Texp_newtype _ -> ())) exp.exp_extra; From 630415ea1fb967ac3b3a8c2a8b287fc4786813ea Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Sat, 11 Jan 2025 16:54:13 +0100 Subject: [PATCH 3/3] Remove `Sig_class` and `Sig_class_type`. --- analysis/src/CreateInterface.ml | 6 ------ .../gentype/TranslateSignatureFromTypes.ml | 6 ------ .../gentype/TranslateTypeExprFromTypes.ml | 3 +-- compiler/ml/btype.ml | 3 --- compiler/ml/ctype.ml | 4 ---- compiler/ml/env.ml | 8 +------ compiler/ml/includemod.ml | 17 +++------------ compiler/ml/mtype.ml | 21 ++++++------------- compiler/ml/printtyp.ml | 3 --- compiler/ml/subst.ml | 4 ---- compiler/ml/transl_recmodule.ml | 2 -- compiler/ml/translmod.ml | 1 - compiler/ml/typecore.ml | 7 +------ compiler/ml/types.ml | 3 --- compiler/ml/types.mli | 3 --- compiler/ml/typetexp.ml | 2 -- 16 files changed, 12 insertions(+), 81 deletions(-) diff --git a/analysis/src/CreateInterface.ml b/analysis/src/CreateInterface.ml index 962ea4469c..a2763a123d 100644 --- a/analysis/src/CreateInterface.ml +++ b/analysis/src/CreateInterface.ml @@ -257,12 +257,6 @@ let printSignature ~extractor ~signature = in Buffer.add_string buf (indent ^ newItemStr ^ "\n"); processSignature ~indent items - | Sig_class _ :: items -> - (* not needed *) - processSignature ~indent items - | Sig_class_type _ :: items -> - (* not needed *) - processSignature ~indent items | [] -> () and processModuleType ~indent (mt : Types.module_type) = match mt with diff --git a/compiler/gentype/TranslateSignatureFromTypes.ml b/compiler/gentype/TranslateSignatureFromTypes.ml index 2a12d6e350..16d972add5 100644 --- a/compiler/gentype/TranslateSignatureFromTypes.ml +++ b/compiler/gentype/TranslateSignatureFromTypes.ml @@ -93,12 +93,6 @@ and translate_signature_item_from_types ~config ~output_file_relative ~resolver | Types.Sig_modtype _ -> log_not_implemented ("Sig_modtype " ^ __LOC__); Translation.empty - | Types.Sig_class _ -> - log_not_implemented ("Sig_class " ^ __LOC__); - Translation.empty - | Types.Sig_class_type _ -> - log_not_implemented ("Sig_class_type " ^ __LOC__); - Translation.empty (** Like translateSignature but from Types not Typedtree *) and translate_signature_from_types ~config ~output_file_relative ~resolver diff --git a/compiler/gentype/TranslateTypeExprFromTypes.ml b/compiler/gentype/TranslateTypeExprFromTypes.ml index 100c42dc2a..7aaa709f28 100644 --- a/compiler/gentype/TranslateTypeExprFromTypes.ml +++ b/compiler/gentype/TranslateTypeExprFromTypes.ml @@ -519,8 +519,7 @@ and signature_to_module_runtime_representation ~config ~type_vars_gen ~type_env } in (dependencies, [field]) - | Types.Sig_type _ | Types.Sig_typext _ | Types.Sig_modtype _ - | Types.Sig_class _ | Types.Sig_class_type _ -> + | Types.Sig_type _ | Types.Sig_typext _ | Types.Sig_modtype _ -> ([], [])) in let dependencies, fields = diff --git a/compiler/ml/btype.ml b/compiler/ml/btype.ml index 7afaf52f4b..dd771437fe 100644 --- a/compiler/ml/btype.ml +++ b/compiler/ml/btype.ml @@ -335,8 +335,6 @@ let type_iterators = | Sig_typext (_, td, _) -> it.it_extension_constructor it td | Sig_module (_, md, _) -> it.it_module_declaration it md | Sig_modtype (_, mtd) -> it.it_modtype_declaration it mtd - | Sig_class () -> assert false - | Sig_class_type () -> assert false and it_value_description it vd = it.it_type_expr it vd.val_type and it_type_declaration it td = List.iter (it.it_type_expr it) td.type_params; @@ -404,7 +402,6 @@ let copy_row f fixed row keep more = { row_fields = fields; row_more = more; - row_bound = (); row_fixed = row.row_fixed && fixed; row_closed = row.row_closed; row_name = name; diff --git a/compiler/ml/ctype.ml b/compiler/ml/ctype.ml index 9605e37279..de2ad58632 100644 --- a/compiler/ml/ctype.ml +++ b/compiler/ml/ctype.ml @@ -933,7 +933,6 @@ let rec copy ?env ?partial ?keep_names ty = { row_fields = Ext_list.filter row.row_fields not_reither; row_more = more'; - row_bound = (); row_closed = false; row_fixed = false; row_name = None; @@ -1722,7 +1721,6 @@ let mkvariant fields closed = row_fields = fields; row_closed = closed; row_more = newvar (); - row_bound = (); row_fixed = false; row_name = None; }) @@ -2554,7 +2552,6 @@ and unify_row env row1 row2 = { row_fields = []; row_more = more; - row_bound = (); row_closed = closed; row_fixed = fixed; row_name = name; @@ -3486,7 +3483,6 @@ let rec build_subtype env visited loops posi level t = { row_fields = List.map fst fields; row_more = newvar (); - row_bound = (); row_closed = posi; row_fixed = false; row_name = (if c > Unchanged then None else row.row_name); diff --git a/compiler/ml/env.ml b/compiler/ml/env.ml index 474f45d805..2dfe625122 100644 --- a/compiler/ml/env.ml +++ b/compiler/ml/env.ml @@ -1490,8 +1490,6 @@ let rec prefix_idents root pos sub = function prefix_idents root pos (Subst.add_modtype id (Mty_ident p) sub) rem in (p :: pl, final_sub) - | Sig_class _ :: _ -> assert false - | Sig_class_type _ :: _ -> assert false let prefix_idents root sub sg = if sub = Subst.identity then ( @@ -1587,9 +1585,7 @@ and components_of_module_maker (env, sub, path, mty) = let decl' = Subst.modtype_declaration sub decl in c.comp_modtypes <- Tbl.add (Ident.name id) (decl', nopos) c.comp_modtypes; - env := store_modtype id decl !env - | Sig_class () -> assert false - | Sig_class_type () -> assert false) + env := store_modtype id decl !env) sg pl; Some (Structure_comps c) | Mty_functor (param, ty_arg, ty_res) -> @@ -1833,8 +1829,6 @@ let add_item comp env = | Sig_typext (id, ext, _) -> add_extension ~check:false id ext env | Sig_module (id, md, _) -> add_module_declaration ~check:false id md env | Sig_modtype (id, decl) -> add_modtype id decl env - | Sig_class () -> env - | Sig_class_type () -> env let rec add_signature sg env = match sg with diff --git a/compiler/ml/includemod.ml b/compiler/ml/includemod.ml index bc20d929dd..b6bf2435e3 100644 --- a/compiler/ml/includemod.ml +++ b/compiler/ml/includemod.ml @@ -126,20 +126,13 @@ let item_ident_name = function | Sig_typext (id, d, _) -> (id, d.ext_loc, Field_typext (Ident.name id)) | Sig_module (id, d, _) -> (id, d.md_loc, Field_module (Ident.name id)) | Sig_modtype (id, d) -> (id, d.mtd_loc, Field_modtype (Ident.name id)) - | Sig_class () -> assert false - | Sig_class_type () -> assert false let is_runtime_component = function | Sig_value (_, {val_kind = Val_prim _}) | Sig_type (_, _, _) - | Sig_modtype (_, _) - | Sig_class_type () -> + | Sig_modtype (_, _) -> false - | Sig_value (_, _) - | Sig_typext (_, _, _) - | Sig_module (_, _, _) - | Sig_class () -> - true + | Sig_value (_, _) | Sig_typext (_, _, _) | Sig_module (_, _, _) -> true (* Print a coercion *) @@ -301,7 +294,6 @@ and signatures ~loc env cxt subst sig1 sig2 = | Sig_modtype (i, _) | Sig_type (i, _, _) -> Ident.name i - | Sig_class () | Sig_class_type () -> assert false in List.fold_right (fun item fields -> @@ -360,8 +352,7 @@ and signatures ~loc env cxt subst sig1 sig2 = | Sig_module _ -> Subst.add_module id2 (Pident id1) subst | Sig_modtype _ -> Subst.add_modtype id2 (Mty_ident (Pident id1)) subst - | Sig_value _ | Sig_typext _ | Sig_class _ | Sig_class_type () -> - subst + | Sig_value _ | Sig_typext _ -> subst in pair_components new_subst ((item1, item2, pos1) :: paired) unpaired rem | exception Not_found -> @@ -399,8 +390,6 @@ and signature_components ~loc old_env env cxt subst paired = | (Sig_modtype (id1, info1), Sig_modtype (_id2, info2), _pos) :: rem -> modtype_infos ~loc env cxt subst id1 info1 info2; comps_rec rem - | (Sig_class (), Sig_class (), _) :: _ -> assert false - | (Sig_class_type (), Sig_class_type (), _pos) :: _ -> assert false | _ -> assert false and module_declarations ~loc env cxt subst id1 md1 md2 = diff --git a/compiler/ml/mtype.ml b/compiler/ml/mtype.ml index 449d89ae5a..9f6768cd4f 100644 --- a/compiler/ml/mtype.ml +++ b/compiler/ml/mtype.ml @@ -89,11 +89,7 @@ and strengthen_sig ~aliasable env sg p pos = in Sig_modtype (id, newdecl) :: strengthen_sig ~aliasable (Env.add_modtype id decl env) rem p pos - (* Need to add the module type in case it is manifest *) - | (Sig_class _ as sigelt) :: rem -> - sigelt :: strengthen_sig ~aliasable env rem p (pos + 1) - | (Sig_class_type _ as sigelt) :: rem -> - sigelt :: strengthen_sig ~aliasable env rem p pos +(* Need to add the module type in case it is manifest *) and strengthen_decl ~aliasable env md p = match md.md_type with @@ -160,9 +156,7 @@ let nondep_supertype env mid mty = {mtd_type = None; mtd_loc = Location.none; mtd_attributes = []} ) :: rem' - | _ -> raise Not_found)) - | Sig_class () -> assert false - | Sig_class_type () -> assert false) + | _ -> raise Not_found))) and nondep_modtype_decl env mtd = {mtd with mtd_type = Misc.may_map (nondep_mty env Strict) mtd.mtd_type} in @@ -229,8 +223,7 @@ and type_paths_sig env p pos sg = p (pos + 1) rem | Sig_modtype (id, decl) :: rem -> type_paths_sig (Env.add_modtype id decl env) p pos rem - | (Sig_typext _ | Sig_class _) :: rem -> type_paths_sig env p (pos + 1) rem - | Sig_class_type _ :: rem -> type_paths_sig env p pos rem + | Sig_typext _ :: rem -> type_paths_sig env p (pos + 1) rem let rec no_code_needed env mty = match scrape env mty with @@ -252,9 +245,8 @@ and no_code_needed_sig env sg = && no_code_needed_sig (Env.add_module_declaration ~check:false id md env) rem - | (Sig_type _ | Sig_modtype _ | Sig_class_type _) :: rem -> - no_code_needed_sig env rem - | (Sig_typext _ | Sig_class _) :: _ -> false + | (Sig_type _ | Sig_modtype _) :: rem -> no_code_needed_sig env rem + | Sig_typext _ :: _ -> false (* Check whether a module type may return types *) @@ -286,8 +278,7 @@ and contains_type_item env = function is kept local to expressions. *) raise Exit | Sig_module (_, {md_type = mty}, _) -> contains_type env mty - | Sig_value _ | Sig_type _ | Sig_typext _ | Sig_class _ | Sig_class_type _ -> - () + | Sig_value _ | Sig_type _ | Sig_typext _ -> () let contains_type env mty = try diff --git a/compiler/ml/printtyp.ml b/compiler/ml/printtyp.ml index 90a9fa1289..fe32e69453 100644 --- a/compiler/ml/printtyp.ml +++ b/compiler/ml/printtyp.ml @@ -1031,7 +1031,6 @@ let wrap_env fenv ftree arg = let filter_rem_sig item rem = match (item, rem) with - | Sig_class_type _, tydecl1 :: tydecl2 :: rem -> ([tydecl1; tydecl2], rem) | _ -> ([], rem) let dummy = @@ -1118,8 +1117,6 @@ and trees_of_sigitem = function in [tree_of_module id md.md_type rs ~ellipsis] | Sig_modtype (id, decl) -> [tree_of_modtype_declaration id decl] - | Sig_class () -> [] - | Sig_class_type () -> [] and tree_of_modtype_declaration id decl = let mty = diff --git a/compiler/ml/subst.ml b/compiler/ml/subst.ml index 0b99cf7949..821051374b 100644 --- a/compiler/ml/subst.ml +++ b/compiler/ml/subst.ml @@ -336,11 +336,9 @@ let rec rename_bound_idents s idents = function rename_bound_idents (add_modtype id (Mty_ident (Pident id')) s) (id' :: idents) sg - | Sig_class_type () :: _ -> assert false | (Sig_value (id, _) | Sig_typext (id, _, _)) :: sg -> let id' = Ident.rename id in rename_bound_idents s (id' :: idents) sg - | Sig_class _ :: _ -> assert false let rec modtype s = function | Mty_ident p as mty -> ( match p with @@ -370,8 +368,6 @@ and signature_component s comp newid = Sig_typext (newid, extension_constructor s ext, es) | Sig_module (_id, d, rs) -> Sig_module (newid, module_declaration s d, rs) | Sig_modtype (_id, d) -> Sig_modtype (newid, modtype_declaration s d) - | Sig_class () -> Sig_class () - | Sig_class_type () -> Sig_class_type () and module_declaration s decl = { diff --git a/compiler/ml/transl_recmodule.ml b/compiler/ml/transl_recmodule.ml index 17aa511aa2..1c28ed8c14 100644 --- a/compiler/ml/transl_recmodule.ml +++ b/compiler/ml/transl_recmodule.ml @@ -90,8 +90,6 @@ let init_shape modl = rem | Sig_modtype (id, minfo) :: rem -> init_shape_struct (Env.add_modtype id minfo env) rem - | Sig_class _ :: _ -> assert false - | Sig_class_type _ :: rem -> init_shape_struct env rem in try Some diff --git a/compiler/ml/translmod.ml b/compiler/ml/translmod.ml index e3e0ead663..2ebfcbf083 100644 --- a/compiler/ml/translmod.ml +++ b/compiler/ml/translmod.ml @@ -201,7 +201,6 @@ let rec bound_value_identifiers : Types.signature_item list -> Ident.t list = id :: bound_value_identifiers rem | Sig_typext (id, _, _) :: rem -> id :: bound_value_identifiers rem | Sig_module (id, _, _) :: rem -> id :: bound_value_identifiers rem - | Sig_class _ :: _ -> assert false | _ :: rem -> bound_value_identifiers rem (* Compile one or more functors, merging curried functors to produce diff --git a/compiler/ml/typecore.ml b/compiler/ml/typecore.ml index c35a45702f..56abb543ab 100644 --- a/compiler/ml/typecore.ml +++ b/compiler/ml/typecore.ml @@ -363,7 +363,7 @@ let finalize_variant pat = (* Force check of well-formedness WHY? *) (* unify_pat pat.pat_env pat (newty(Tvariant{row_fields=[]; row_more=newvar(); row_closed=false; - row_bound=(); row_fixed=false; row_name=None})); *)) + row_fixed=false; row_name=None})); *)) | _ -> () let rec iter_pattern f p = @@ -474,7 +474,6 @@ let rec build_as_type env p = { row_fields = [(l, Rpresent ty)]; row_more = newvar (); - row_bound = (); row_name = None; row_fixed = false; row_closed = false; @@ -553,7 +552,6 @@ let build_or_pat env loc lid = { row_fields = List.rev fields; row_more = newvar (); - row_bound = (); row_closed = false; row_fixed = false; row_name = Some (path, tyl); @@ -1429,7 +1427,6 @@ and type_pat_aux ~constrs ~labels ~no_existentials ~mode ~explode ~env sp let row = { row_fields = [(l, Reither (sarg = None, arg_type, true, ref None))]; - row_bound = (); row_closed = false; row_more = newvar (); row_fixed = false; @@ -2124,7 +2121,6 @@ let check_absent_variant env = { row_fields = [(s, Reither (arg = None, ty_arg, true, ref None))]; row_more = newvar (); - row_bound = (); row_closed = false; row_fixed = false; row_name = None; @@ -2559,7 +2555,6 @@ and type_expect_ ?type_clash_context ?in_function ?(recarg = Rejected) env sexp { row_fields = [(l, Rpresent arg_type)]; row_more = newvar (); - row_bound = (); row_closed = false; row_fixed = false; row_name = None; diff --git a/compiler/ml/types.ml b/compiler/ml/types.ml index 215f7e72b6..a8ecc64d60 100644 --- a/compiler/ml/types.ml +++ b/compiler/ml/types.ml @@ -39,7 +39,6 @@ and type_desc = and row_desc = { row_fields: (label * row_field) list; row_more: type_expr; - row_bound: unit; row_closed: bool; row_fixed: bool; row_name: (Path.t * type_expr list) option; @@ -226,8 +225,6 @@ and signature_item = | Sig_typext of Ident.t * extension_constructor * ext_status | Sig_module of Ident.t * module_declaration * rec_status | Sig_modtype of Ident.t * modtype_declaration - | Sig_class of unit - | Sig_class_type of unit (* Dummy AST node *) and module_declaration = { md_type: module_type; diff --git a/compiler/ml/types.mli b/compiler/ml/types.mli index ac09932a09..811f839f91 100644 --- a/compiler/ml/types.mli +++ b/compiler/ml/types.mli @@ -113,7 +113,6 @@ and type_desc = and row_desc = { row_fields: (label * row_field) list; row_more: type_expr; - row_bound: unit; (* kept for compatibility *) row_closed: bool; row_fixed: bool; row_name: (Path.t * type_expr list) option; @@ -358,8 +357,6 @@ and signature_item = | Sig_typext of Ident.t * extension_constructor * ext_status | Sig_module of Ident.t * module_declaration * rec_status | Sig_modtype of Ident.t * modtype_declaration - | Sig_class of unit - | Sig_class_type of unit (* Dummy AST node *) and module_declaration = { md_type: module_type; diff --git a/compiler/ml/typetexp.ml b/compiler/ml/typetexp.ml index bbd02d5498..30ab5cffd0 100644 --- a/compiler/ml/typetexp.ml +++ b/compiler/ml/typetexp.ml @@ -422,7 +422,6 @@ and transl_type_aux env policy styp = { row_fields = [(l, f)]; row_more = newvar (); - row_bound = (); row_closed = true; row_fixed = false; row_name = None; @@ -509,7 +508,6 @@ and transl_type_aux env policy styp = { row_fields = List.rev fields; row_more = newvar (); - row_bound = (); row_closed = closed = Closed; row_fixed = false; row_name = !name;