Browse Source

infer type parameters of @:from functions (fixed issue #1516)

Simon Krajewski 12 years ago
parent
commit
f5ca1d3817
1 changed files with 10 additions and 2 deletions
  1. 10 2
      codegen.ml

+ 10 - 2
codegen.ml

@@ -1319,9 +1319,17 @@ let handle_abstract_casts ctx e =
 	let rec make_static_call c cf a pl args t p =
 		let ta = TAnon { a_fields = c.cl_statics; a_status = ref (Statics c) } in
 		let ethis = mk (TTypeExpr (TClassDecl c)) ta p in
-		let map t = apply_params a.a_types pl (monomorphs cf.cf_params t) in
+		let monos = List.map (fun _ -> mk_mono()) cf.cf_params in
+		let map t = apply_params a.a_types pl (apply_params cf.cf_params monos t) in
+		(* TODO: temp RC fix for from-functions to infer type parameters *)
+		let tcf = match follow (map cf.cf_type),args with
+			| TFun((_,_,ta) :: args,r) as tf,e :: el when Meta.has Meta.From cf.cf_meta ->
+				unify ctx e.etype ta p;
+				tf
+			| t,_ -> t
+		in
 		let def () =
-			let e = mk (TField (ethis,(FStatic (c,cf)))) (map cf.cf_type) p in
+			let e = mk (TField (ethis,(FStatic (c,cf)))) tcf p in
 			mk (TCall(e,args)) (map t) p
 		in
 		let e = match cf.cf_expr with