浏览代码

unify leftmost type on abstract call because using does that too (fixed issue #1587)

Simon Krajewski 12 年之前
父节点
当前提交
fbea3facf7
共有 1 个文件被更改,包括 11 次插入1 次删除
  1. 11 1
      typer.ml

+ 11 - 1
typer.ml

@@ -1112,7 +1112,17 @@ and type_field ctx e i p mode =
 				error (i ^ " cannot be called") p
 			| MGet, Var {v_read = AccNever} ->
 				AKNo f.cf_name
-			| (MGet | MCall), _ ->
+			| MCall, _ ->
+				let t = field_type f in
+				begin match follow t with
+					| TFun((_,_,t1) :: _,_) ->
+						unify ctx (apply_params a.a_types pl a.a_this) t1 p
+					| _ ->
+						error (i ^ " cannot be called") p
+				end;
+				let ef = field_expr f t in
+				AKUsing (ef,c,f,e)
+			| MGet, _ ->
 				let t = field_type f in
 				let ef = field_expr f t in
 				AKUsing (ef,c,f,e)