浏览代码

bugfix with interface + optional args

Nicolas Cannasse 14 年之前
父节点
当前提交
5785a90e94
共有 1 个文件被更改,包括 8 次插入1 次删除
  1. 8 1
      genswf9.ml

+ 8 - 1
genswf9.ml

@@ -1873,8 +1873,15 @@ let generate_field_kind ctx f c stat =
 	| _ when c.cl_interface && not stat ->
 		(match follow f.cf_type, f.cf_kind with
 		| TFun (args,tret), Method (MethNormal | MethInline) ->
+			let dparams = ref None in
+			List.iter (fun (_,o,t) ->
+				match !dparams with
+				| None -> if o then dparams := Some [HVNone]
+				| Some l -> dparams := Some (HVNone :: l)
+			) args;
+			let dparams = (match !dparams with None -> None | Some l -> Some (List.rev l)) in
 			Some (HFMethod {
-				hlm_type = end_fun ctx (List.map (fun (a,opt,t) -> a, (if opt then Some TNull else None), t) args) None tret;
+				hlm_type = end_fun ctx (List.map (fun (a,opt,t) -> a, (if opt then Some TNull else None), t) args) dparams tret;
 				hlm_final = false;
 				hlm_override = false;
 				hlm_kind = MK3Normal;