Skip to content

Remove more unused ast nodes for class and class type. #7243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 0 additions & 2 deletions analysis/reanalyze/src/Annotation.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions analysis/src/CreateInterface.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions compiler/core/js_implementation.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
3 changes: 0 additions & 3 deletions compiler/frontend/bs_ast_invariant.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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) ->
Expand Down
4 changes: 0 additions & 4 deletions compiler/frontend/bs_ast_mapper.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 2 additions & 6 deletions compiler/gentype/Annotation.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) =
Expand Down
6 changes: 0 additions & 6 deletions compiler/gentype/TranslateSignature.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions compiler/gentype/TranslateSignatureFromTypes.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions compiler/gentype/TranslateStructure.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions compiler/gentype/TranslateTypeExprFromTypes.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
4 changes: 0 additions & 4 deletions compiler/ml/ast_iterator.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 0 additions & 4 deletions compiler/ml/ast_mapper.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions compiler/ml/ast_mapper_from0.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 0 additions & 4 deletions compiler/ml/ast_mapper_to0.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 0 additions & 3 deletions compiler/ml/btype.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 0 additions & 4 deletions compiler/ml/ctype.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
})
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 0 additions & 4 deletions compiler/ml/depend.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 1 addition & 7 deletions compiler/ml/env.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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) ->
Expand Down Expand Up @@ -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
Expand Down
17 changes: 3 additions & 14 deletions compiler/ml/includemod.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 *)

Expand Down Expand Up @@ -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 ->
Expand Down Expand Up @@ -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 ->
Expand Down Expand Up @@ -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 =
Expand Down
Loading
Loading