Browse Source

restore the field cf_kind (fixed issue #1256)

Nicolas Cannasse 13 years ago
parent
commit
1e76612c39
1 changed files with 5 additions and 0 deletions
  1. 5 0
      codegen.ml

+ 5 - 0
codegen.ml

@@ -548,6 +548,8 @@ let save_class_state ctx t = match t with
 		let meta = c.cl_meta and path = c.cl_path and ext = c.cl_extern in
 		let fl = c.cl_fields and ofl = c.cl_ordered_fields and st = c.cl_statics and ost = c.cl_ordered_statics in
 		let cst = c.cl_constructor and over = c.cl_overrides in
+		let oflk = List.map (fun f -> f.cf_kind) ofl in
+		let ostk = List.map (fun f -> f.cf_kind) ost in
 		c.cl_restore <- (fun() ->
 			c.cl_meta <- meta;
 			c.cl_extern <- ext;
@@ -558,6 +560,9 @@ let save_class_state ctx t = match t with
 			c.cl_ordered_statics <- ost;
 			c.cl_constructor <- cst;
 			c.cl_overrides <- over;
+			(* DCE might modify the cf_kind, so let's restore it as well *)
+			List.iter2 (fun f k -> f.cf_kind <- k) ofl oflk;
+			List.iter2 (fun f k -> f.cf_kind <- k) ost ostk;
 		)
 	| _ ->
 		()