|
@@ -448,7 +448,7 @@ let run com main full =
|
|
List.iter (fun (c,cf,stat) -> mark_dependent_fields dce c cf.cf_name stat) cfl;
|
|
List.iter (fun (c,cf,stat) -> mark_dependent_fields dce c cf.cf_name stat) cfl;
|
|
(* mark fields as used *)
|
|
(* mark fields as used *)
|
|
List.iter (fun (c,cf,stat) ->
|
|
List.iter (fun (c,cf,stat) ->
|
|
- mark_class dce c;
|
|
|
|
|
|
+ if not (is_extern_field cf) then mark_class dce c;
|
|
mark_field dce c cf stat;
|
|
mark_field dce c cf stat;
|
|
mark_t dce cf.cf_pos cf.cf_type
|
|
mark_t dce cf.cf_pos cf.cf_type
|
|
) cfl;
|
|
) cfl;
|
|
@@ -512,8 +512,10 @@ let run com main full =
|
|
b
|
|
b
|
|
) c.cl_ordered_fields;
|
|
) c.cl_ordered_fields;
|
|
(match c.cl_constructor with Some cf when not (keep_field dce cf) -> c.cl_constructor <- None | _ -> ());
|
|
(match c.cl_constructor with Some cf when not (keep_field dce cf) -> c.cl_constructor <- None | _ -> ());
|
|
|
|
+ let inef cf = not (is_extern_field cf) in
|
|
|
|
+ let has_non_extern_fields = List.exists inef c.cl_ordered_fields || List.exists inef c.cl_ordered_statics in
|
|
(* we keep a class if it was used or has a used field *)
|
|
(* we keep a class if it was used or has a used field *)
|
|
- if Meta.has Meta.Used c.cl_meta || c.cl_ordered_statics <> [] || c.cl_ordered_fields <> [] then loop (mt :: acc) l else begin
|
|
|
|
|
|
+ if Meta.has Meta.Used c.cl_meta || has_non_extern_fields then loop (mt :: acc) l else begin
|
|
(match c.cl_init with
|
|
(match c.cl_init with
|
|
| Some f when Meta.has Meta.KeepInit c.cl_meta ->
|
|
| Some f when Meta.has Meta.KeepInit c.cl_meta ->
|
|
(* it means that we only need the __init__ block *)
|
|
(* it means that we only need the __init__ block *)
|