Browse Source

fixed "using" on macro function

Nicolas Cannasse 14 years ago
parent
commit
0128ce1962
2 changed files with 19 additions and 5 deletions
  1. 1 0
      doc/CHANGES.txt
  2. 18 5
      typer.ml

+ 1 - 0
doc/CHANGES.txt

@@ -10,6 +10,7 @@
 	all : added haxe.Int64
 	all : added haxe.Int32 isNeg,isZero,ucompare, fixed overflows for js/flash8/php
 	all : bugfix when optimizing inlined immediate function call
+	all : fixed "using" on macro function
 
 2011-01-30: 2.07
 	all : fixed completion support with --remap

+ 18 - 5
typer.ml

@@ -1683,11 +1683,24 @@ and type_call ctx e el p =
 			) in
 			make_call ctx (mk (TField (ethis,f.cf_name)) t p) params tret p
 		| AKUsing (et,ef,eparam) ->
-			let params, tret = (match follow et.etype with
-				| TFun ( _ :: args,r) -> unify_call_params ctx (Some (ef.cf_name,ef.cf_meta)) el args p false, r
-				| _ -> assert false
-			) in
-			make_call ctx et (eparam::params) tret p
+			(match et.eexpr with
+			| TField (ec,_) ->
+				(match type_field ctx ec ef.cf_name p MCall with
+				| AKMacro _ ->
+					(match ec.eexpr with
+					| TTypeExpr (TClassDecl c) ->						
+						(match ctx.g.do_macro ctx c.cl_path ef.cf_name (e :: el) p with
+						| None -> type_expr ctx (EConst (Ident "null"),p)
+						| Some e -> type_expr ctx e)
+					| _ -> assert false)
+				| AKExpr _ | AKField _ | AKInline _ ->
+					let params, tret = (match follow et.etype with
+						| TFun ( _ :: args,r) -> unify_call_params ctx (Some (ef.cf_name,ef.cf_meta)) el args p false, r
+						| _ -> assert false
+					) in
+					make_call ctx et (eparam::params) tret p
+				| _ -> assert false)
+			| _ -> assert false)
 		| AKMacro (ethis,f) ->
 			(match ethis.eexpr with
 			| TTypeExpr (TClassDecl c) ->