Răsfoiți Sursa

make sure DCE also checks parent interfaces

Simon Krajewski 13 ani în urmă
părinte
comite
c80783fdbf
1 a modificat fișierele cu 9 adăugiri și 1 ștergeri
  1. 9 1
      dce.ml

+ 9 - 1
dce.ml

@@ -159,6 +159,7 @@ let rec field dce c n stat =
 			| Some cf -> cf
 			| Some cf -> cf
 		else PMap.find n (if stat then c.cl_statics else c.cl_fields)
 		else PMap.find n (if stat then c.cl_statics else c.cl_fields)
 	in
 	in
+	let not_found () = if dce.debug then prerr_endline ("[DCE] Field " ^ n ^ " not found on " ^ (s_type_path c.cl_path)) else () in
 	(try
 	(try
 		let cf = find_field n in
 		let cf = find_field n in
 		mark_field dce c cf stat;
 		mark_field dce c cf stat;
@@ -182,7 +183,14 @@ let rec field dce c n stat =
 		end;
 		end;
 		raise Not_found
 		raise Not_found
 	with Not_found ->
 	with Not_found ->
-		match c.cl_super with Some (csup,_) -> field dce csup n stat | None -> ());
+		if c.cl_interface then begin
+			let rec loop cl = match cl with
+				| [] -> not_found()
+				| (c,_) :: cl ->
+					try field dce c n stat with Not_found -> loop cl
+			in
+			loop c.cl_implements
+		end else match c.cl_super with Some (csup,_) -> field dce csup n stat | None -> not_found())
 
 
 and expr dce e =
 and expr dce e =
 	match e.eexpr with
 	match e.eexpr with