Skip to content

Commit 1338ea2

Browse files
authored
AST: Remove Pstr_class (#7242)
* Remove Pstr_class * Remove Psig_class * Remove Pstr_class_type * Remove Psig_class_type * Remove Tstr_class, Tstr_class_type, Tsig_class & Tsig_class_type * Add changelog entry * Remove unit in Texp_coerce * Remove row_bound in row_desc
1 parent c2ad39e commit 1338ea2

34 files changed

+19
-133
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
- 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
2727
- 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
2828
- 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
29+
- AST cleanup: Remove `structure_item_desc.Pstr_class`, `signature_item_desc.Psig_class`, `structure_item_desc.Pstr_class_type`, `signature_item_desc.Psig_class_type`, `structure_item_desc.Tstr_class`, `structure_item_desc.Tstr_class_type`, `signature_item_desc.Tsig_class`, `signature_item_desc.Tsig_class_type` from AST as it is unused. https://github.com/rescript-lang/rescript/pull/7242
2930

3031
# 12.0.0-alpha.7
3132

analysis/reanalyze/src/Annotation.ml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ let rec getAttributePayload checkText (attributes : Typedtree.attributes) =
6363
| PStr ({pstr_desc = Pstr_recmodule _} :: _) -> Some UnrecognizedPayload
6464
| PStr ({pstr_desc = Pstr_modtype _} :: _) -> Some UnrecognizedPayload
6565
| PStr ({pstr_desc = Pstr_open _} :: _) -> Some UnrecognizedPayload
66-
| PStr ({pstr_desc = Pstr_class _} :: _) -> Some UnrecognizedPayload
67-
| PStr ({pstr_desc = Pstr_class_type _} :: _) -> Some UnrecognizedPayload
6866
| PStr ({pstr_desc = Pstr_include _} :: _) -> Some UnrecognizedPayload
6967
| PStr ({pstr_desc = Pstr_attribute _} :: _) -> Some UnrecognizedPayload
7068
| PPat _ -> Some UnrecognizedPayload

compiler/core/js_implementation.ml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@ let all_module_alias (ast : Parsetree.structure) =
9696
| Pstr_attribute _ -> true
9797
| Pstr_eval _ | Pstr_value _ | Pstr_primitive _ | Pstr_type _
9898
| Pstr_typext _ | Pstr_exception _ | Pstr_module _ | Pstr_recmodule _
99-
| Pstr_modtype _ | Pstr_open _ | Pstr_class _ | Pstr_class_type _
100-
| Pstr_include _ | Pstr_extension _ ->
99+
| Pstr_modtype _ | Pstr_open _ | Pstr_include _ | Pstr_extension _ ->
101100
false)
102101

103102
let no_export (rest : Parsetree.structure) : Parsetree.structure =

compiler/frontend/bs_ast_invariant.ml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,6 @@ let emit_external_warnings : iterator =
8686
[{ptype_kind = Ptype_variant ({pcd_res = Some _} :: _)}] ) ->
8787
Location.raise_errorf ~loc:str_item.pstr_loc
8888
"GADT has to be recursive types, please try `type rec'"
89-
| Pstr_class _ ->
90-
Location.raise_errorf ~loc:str_item.pstr_loc
91-
"OCaml style classes are not supported"
9289
| _ -> super.structure_item self str_item);
9390
expr =
9491
(fun self ({pexp_loc = loc} as a) ->

compiler/frontend/bs_ast_mapper.ml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,6 @@ module MT = struct
232232
| Psig_modtype x -> modtype ~loc (sub.module_type_declaration sub x)
233233
| Psig_open x -> open_ ~loc (sub.open_description sub x)
234234
| Psig_include x -> include_ ~loc (sub.include_description sub x)
235-
| Psig_class () -> assert false
236-
| Psig_class_type () -> assert false
237235
| Psig_extension (x, attrs) ->
238236
extension ~loc (sub.extension sub x) ~attrs:(sub.attributes sub attrs)
239237
| Psig_attribute x -> attribute ~loc (sub.attribute sub x)
@@ -287,8 +285,6 @@ module M = struct
287285
| Pstr_recmodule l -> rec_module ~loc (List.map (sub.module_binding sub) l)
288286
| Pstr_modtype x -> modtype ~loc (sub.module_type_declaration sub x)
289287
| Pstr_open x -> open_ ~loc (sub.open_description sub x)
290-
| Pstr_class () -> {pstr_loc = loc; pstr_desc = Pstr_class ()}
291-
| Pstr_class_type () -> {pstr_loc = loc; pstr_desc = Pstr_class_type ()}
292288
| Pstr_include x -> include_ ~loc (sub.include_declaration sub x)
293289
| Pstr_extension (x, attrs) ->
294290
extension ~loc (sub.extension sub x) ~attrs:(sub.attributes sub attrs)

compiler/gentype/Annotation.ml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@ let rec get_attribute_payload check_text (attributes : Typedtree.attributes) =
8383
| PStr ({pstr_desc = Pstr_recmodule _} :: _) -> Some UnrecognizedPayload
8484
| PStr ({pstr_desc = Pstr_modtype _} :: _) -> Some UnrecognizedPayload
8585
| PStr ({pstr_desc = Pstr_open _} :: _) -> Some UnrecognizedPayload
86-
| PStr ({pstr_desc = Pstr_class _} :: _) -> Some UnrecognizedPayload
87-
| PStr ({pstr_desc = Pstr_class_type _} :: _) -> Some UnrecognizedPayload
8886
| PStr ({pstr_desc = Pstr_include _} :: _) -> Some UnrecognizedPayload
8987
| PStr ({pstr_desc = Pstr_attribute _} :: _) -> Some UnrecognizedPayload
9088
| PPat _ -> Some UnrecognizedPayload
@@ -224,7 +222,7 @@ and signature_item_check_annotation ~check_annotation
224222
module_type_declaration
225223
|> module_type_declaration_check_annotation ~check_annotation
226224
| Tsig_typext _ | Tsig_exception _ | Tsig_recmodule _ | Tsig_open _
227-
| Tsig_include _ | Tsig_class _ | Tsig_class_type _ ->
225+
| Tsig_include _ ->
228226
false
229227

230228
and signature_check_annotation ~check_annotation
@@ -260,9 +258,7 @@ let rec structure_item_check_annotation ~check_annotation
260258
|> module_type_declaration_check_annotation ~check_annotation
261259
| Tstr_attribute attribute ->
262260
[attribute] |> check_annotation ~loc:structure_item.str_loc
263-
| Tstr_eval _ | Tstr_typext _ | Tstr_exception _ | Tstr_open _ | Tstr_class _
264-
| Tstr_class_type _ ->
265-
false
261+
| Tstr_eval _ | Tstr_typext _ | Tstr_exception _ | Tstr_open _ -> false
266262

267263
and module_expr_check_annotation ~check_annotation
268264
(module_expr : Typedtree.module_expr) =

compiler/gentype/TranslateSignature.ml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,6 @@ and translate_signature_item ~config ~output_file_relative ~resolver ~type_env
156156
| {Typedtree.sig_desc = Typedtree.Tsig_include _} ->
157157
log_not_implemented ("Tsig_include " ^ __LOC__);
158158
Translation.empty
159-
| {Typedtree.sig_desc = Typedtree.Tsig_class _} ->
160-
log_not_implemented ("Tsig_class " ^ __LOC__);
161-
Translation.empty
162-
| {Typedtree.sig_desc = Typedtree.Tsig_class_type _} ->
163-
log_not_implemented ("Tsig_class_type " ^ __LOC__);
164-
Translation.empty
165159
| {Typedtree.sig_desc = Typedtree.Tsig_attribute _} ->
166160
log_not_implemented ("Tsig_attribute " ^ __LOC__);
167161
Translation.empty

compiler/gentype/TranslateStructure.ml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -352,12 +352,6 @@ and translate_structure_item ~config ~output_file_relative ~resolver ~type_env
352352
| {str_desc = Tstr_open _} ->
353353
log_not_implemented ("Tstr_open " ^ __LOC__);
354354
Translation.empty
355-
| {str_desc = Tstr_class _} ->
356-
log_not_implemented ("Tstr_class " ^ __LOC__);
357-
Translation.empty
358-
| {str_desc = Tstr_class_type _} ->
359-
log_not_implemented ("Tstr_class_type " ^ __LOC__);
360-
Translation.empty
361355
| {str_desc = Tstr_attribute _} ->
362356
log_not_implemented ("Tstr_attribute " ^ __LOC__);
363357
Translation.empty

compiler/ml/ast_iterator.ml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,6 @@ module MT = struct
216216
| Psig_modtype x -> sub.module_type_declaration sub x
217217
| Psig_open x -> sub.open_description sub x
218218
| Psig_include x -> sub.include_description sub x
219-
| Psig_class () -> ()
220-
| Psig_class_type () -> ()
221219
| Psig_extension (x, attrs) ->
222220
sub.extension sub x;
223221
sub.attributes sub attrs
@@ -261,8 +259,6 @@ module M = struct
261259
| Pstr_recmodule l -> List.iter (sub.module_binding sub) l
262260
| Pstr_modtype x -> sub.module_type_declaration sub x
263261
| Pstr_open x -> sub.open_description sub x
264-
| Pstr_class () -> ()
265-
| Pstr_class_type () -> ()
266262
| Pstr_include x -> sub.include_declaration sub x
267263
| Pstr_extension (x, attrs) ->
268264
sub.extension sub x;

compiler/ml/ast_mapper.ml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,6 @@ module MT = struct
215215
| Psig_modtype x -> modtype ~loc (sub.module_type_declaration sub x)
216216
| Psig_open x -> open_ ~loc (sub.open_description sub x)
217217
| Psig_include x -> include_ ~loc (sub.include_description sub x)
218-
| Psig_class _ -> assert false
219-
| Psig_class_type _ -> assert false
220218
| Psig_extension (x, attrs) ->
221219
extension ~loc (sub.extension sub x) ~attrs:(sub.attributes sub attrs)
222220
| Psig_attribute x -> attribute ~loc (sub.attribute sub x)
@@ -258,8 +256,6 @@ module M = struct
258256
| Pstr_recmodule l -> rec_module ~loc (List.map (sub.module_binding sub) l)
259257
| Pstr_modtype x -> modtype ~loc (sub.module_type_declaration sub x)
260258
| Pstr_open x -> open_ ~loc (sub.open_description sub x)
261-
| Pstr_class () -> {pstr_loc = loc; pstr_desc = Pstr_class ()}
262-
| Pstr_class_type () -> {pstr_loc = loc; pstr_desc = Pstr_class_type ()}
263259
| Pstr_include x -> include_ ~loc (sub.include_declaration sub x)
264260
| Pstr_extension (x, attrs) ->
265261
extension ~loc (sub.extension sub x) ~attrs:(sub.attributes sub attrs)

0 commit comments

Comments
 (0)