浏览代码

fixed issue #1268

Nicolas Cannasse 13 年之前
父节点
当前提交
702021cbfd
共有 2 个文件被更改,包括 8 次插入4 次删除
  1. 8 3
      optimizer.ml
  2. 0 1
      std/sys/db/Manager.hx

+ 8 - 3
optimizer.ml

@@ -152,6 +152,11 @@ let rec type_inline ctx cf f ethis params tret p force =
 				we need to force a local var to be created on some platforms.
 				we need to force a local var to be created on some platforms.
 			*)
 			*)
 			if ctx.com.config.pf_static && not (is_nullable v.v_type) && is_null e.etype then (local v).i_write <- true;
 			if ctx.com.config.pf_static && not (is_nullable v.v_type) && is_null e.etype then (local v).i_write <- true;
+			(*
+				if we cast from Dynamic, create a local var as well to do the cast
+				once and allow DCE to perform properly.
+			*)
+			if v.v_type != t_dynamic && follow e.etype == t_dynamic then (local v).i_write <- true;
 			(match e.eexpr, opt with
 			(match e.eexpr, opt with
 			| TConst TNull , Some c -> mk (TConst c) v.v_type e.epos
 			| TConst TNull , Some c -> mk (TConst c) v.v_type e.epos
 			| _ -> e) :: loop pl al
 			| _ -> e) :: loop pl al
@@ -346,12 +351,12 @@ let rec type_inline ctx cf f ethis params tret p force =
 			(* we can't mute the type of the expression because it is not correct to do so *)
 			(* we can't mute the type of the expression because it is not correct to do so *)
 			(try
 			(try
 				(* if the expression is "untyped" and we don't want to unify it accidentally ! *)
 				(* if the expression is "untyped" and we don't want to unify it accidentally ! *)
-				(match follow e.etype with 
-				| TMono _ -> 
+				(match follow e.etype with
+				| TMono _ ->
 					(match follow tret with
 					(match follow tret with
 					| TEnum ({ e_path = [],"Void" },_) | TAbstract ({ a_path = [],"Void" },_) -> e
 					| TEnum ({ e_path = [],"Void" },_) | TAbstract ({ a_path = [],"Void" },_) -> e
 					| _ -> raise (Unify_error []))
 					| _ -> raise (Unify_error []))
-				| _ -> 
+				| _ ->
 					type_eq EqStrict (if has_params then map_type e.etype else e.etype) tret;
 					type_eq EqStrict (if has_params then map_type e.etype else e.etype) tret;
 					e)
 					e)
 			with Unify_error _ ->
 			with Unify_error _ ->

+ 0 - 1
std/sys/db/Manager.hx

@@ -192,7 +192,6 @@ class Manager<T : Object> {
 	}
 	}
 
 
 	inline function hasBinaryChanged( a : haxe.io.Bytes, b : haxe.io.Bytes ) {
 	inline function hasBinaryChanged( a : haxe.io.Bytes, b : haxe.io.Bytes ) {
-		var a = a; // tmp fix for issue #1268
 		return a != b && (a == null || b == null || a.compare(b) != 0);
 		return a != b && (a == null || b == null || a.compare(b) != 0);
 	}
 	}