소스 검색

make sure that used type-values are always compiled with DCE (fixed issue #774)

Nicolas Cannasse 13 년 전
부모
커밋
50be8da121
1개의 변경된 파일2개의 추가작업 그리고 0개의 파일을 삭제
  1. 2 0
      typer.ml

+ 2 - 0
typer.ml

@@ -214,6 +214,7 @@ let rec type_module_type ctx t tparams p =
 			t_types = [];
 			t_types = [];
 			t_meta = no_meta;
 			t_meta = no_meta;
 		} in
 		} in
+		if ctx.com.dead_code_elimination && not (has_meta ":?used" c.cl_meta) then c.cl_meta <- (":?used",[],p) :: c.cl_meta;
 		mk (TTypeExpr (TClassDecl c)) (TType (t_tmp,[])) p
 		mk (TTypeExpr (TClassDecl c)) (TType (t_tmp,[])) p
 	| TEnumDecl e ->
 	| TEnumDecl e ->
 		let types = (match tparams with None -> List.map (fun _ -> mk_mono()) e.e_types | Some l -> l) in
 		let types = (match tparams with None -> List.map (fun _ -> mk_mono()) e.e_types | Some l -> l) in
@@ -246,6 +247,7 @@ let rec type_module_type ctx t tparams p =
 			t_types = e.e_types;
 			t_types = e.e_types;
 			t_meta = no_meta;
 			t_meta = no_meta;
 		} in
 		} in
+		if ctx.com.dead_code_elimination && not (has_meta ":?used" e.e_meta) then e.e_meta <- (":?used",[],p) :: e.e_meta;
 		mk (TTypeExpr (TEnumDecl e)) (TType (t_tmp,types)) p
 		mk (TTypeExpr (TEnumDecl e)) (TType (t_tmp,types)) p
 	| TTypeDecl s ->
 	| TTypeDecl s ->
 		let t = apply_params s.t_types (List.map (fun _ -> mk_mono()) s.t_types) s.t_type in
 		let t = apply_params s.t_types (List.map (fun _ -> mk_mono()) s.t_types) s.t_type in