瀏覽代碼

if method is kept, constructor should be kept also (#6819)

Alexander Kuzmenko 7 年之前
父節點
當前提交
75edacf944
共有 2 個文件被更改,包括 6 次插入1 次删除
  1. 1 1
      src/optimization/dce.ml
  2. 5 0
      src/typing/type.ml

+ 1 - 1
src/optimization/dce.ml

@@ -128,7 +128,7 @@ and mark_field dce c cf stat =
 			| Some (c,_) -> mark_field dce c cf stat
 			| Some (c,_) -> mark_field dce c cf stat
 		end else
 		end else
 			add cf;
 			add cf;
-		if not stat && is_physical_var_field cf then
+		if not stat && is_physical_field cf then
 			match c.cl_constructor with
 			match c.cl_constructor with
 				| None -> ()
 				| None -> ()
 				| Some ctor -> mark_field dce c ctor false
 				| Some ctor -> mark_field dce c ctor false

+ 5 - 0
src/typing/type.ml

@@ -776,6 +776,11 @@ let is_physical_var_field f =
 	| Var _ -> Meta.has Meta.IsVar f.cf_meta
 	| Var _ -> Meta.has Meta.IsVar f.cf_meta
 	| _ -> false
 	| _ -> false
 
 
+let is_physical_field f =
+	match f.cf_kind with
+	| Method _ -> true
+	| _ -> is_physical_var_field f
+
 let is_extern_field f =
 let is_extern_field f =
 	match f.cf_kind with
 	match f.cf_kind with
 	| Method _ -> false
 	| Method _ -> false