Browse Source

make sure Std.is is typed when using cast(e,T) (fix for DCE)

Nicolas Cannasse 13 years ago
parent
commit
36ec0bd012
1 changed files with 7 additions and 1 deletions
  1. 7 1
      typer.ml

+ 7 - 1
typer.ml

@@ -1679,7 +1679,13 @@ and type_expr ctx ?(need_val=true) (e,p) =
 		mk (TCast (e,None)) (mk_mono()) p
 	| ECast (e, Some t) ->
 		(* force compilation of class "Std" since we might need it *)
-		ignore(Typeload.load_type_def ctx p { tpackage = []; tparams = []; tname = "Std"; tsub = None });
+		(match ctx.com.platform with
+		| Js | Flash8 | Neko | Flash ->
+			let std = Typeload.load_type_def ctx p { tpackage = []; tparams = []; tname = "Std"; tsub = None } in
+			(* ensure typing / mark for DCE *)
+			ignore(follow (try PMap.find "is" (match std with TClassDecl c -> c.cl_statics | _ -> assert false) with Not_found -> assert false).cf_type)
+		| Cpp | Php | Cross ->
+			());
 		let t = Typeload.load_complex_type ctx (pos e) t in
 		let texpr = (match follow t with
 		| TInst (_,params) | TEnum (_,params) ->