Simon Krajewski 4 năm trước cách đây
mục cha
commit
02ae586b20
76 tập tin đã thay đổi với 387 bổ sung371 xóa
  1. 12 8
      src/codegen/codegen.ml
  2. 11 11
      src/codegen/gencommon/castDetect.ml
  3. 19 19
      src/codegen/gencommon/closuresToClass.ml
  4. 1 1
      src/codegen/gencommon/enumToClass.ml
  5. 7 7
      src/codegen/gencommon/enumToClass2.ml
  6. 6 6
      src/codegen/gencommon/fixOverrides.ml
  7. 5 5
      src/codegen/gencommon/gencommon.ml
  8. 1 1
      src/codegen/gencommon/initFunction.ml
  9. 2 2
      src/codegen/gencommon/interfaceVarsDeleteModf.ml
  10. 2 2
      src/codegen/gencommon/normalize.ml
  11. 3 3
      src/codegen/gencommon/overloadingConstructor.ml
  12. 7 7
      src/codegen/gencommon/realTypeParams.ml
  13. 17 17
      src/codegen/gencommon/reflectionCFs.ml
  14. 2 2
      src/codegen/genxml.ml
  15. 3 3
      src/codegen/overloads.ml
  16. 3 3
      src/compiler/displayOutput.ml
  17. 4 4
      src/context/abstractCast.ml
  18. 2 2
      src/context/display/display.ml
  19. 1 1
      src/context/display/displayEmitter.ml
  20. 1 1
      src/context/display/displayException.ml
  21. 6 6
      src/context/display/displayFields.ml
  22. 2 2
      src/context/display/displayToplevel.ml
  23. 4 4
      src/context/typecore.ml
  24. 5 2
      src/core/display/completionItem.ml
  25. 2 2
      src/core/error.ml
  26. 3 2
      src/core/json/genjson.ml
  27. 8 8
      src/core/tFunctions.ml
  28. 1 1
      src/core/tOther.ml
  29. 3 3
      src/core/tPrinting.ml
  30. 1 1
      src/core/tType.ml
  31. 7 7
      src/core/tUnification.ml
  32. 1 1
      src/filters/ES6Ctors.ml
  33. 1 1
      src/filters/capturedVars.ml
  34. 3 3
      src/filters/defaultArguments.ml
  35. 5 5
      src/filters/exceptions.ml
  36. 1 1
      src/filters/filters.ml
  37. 37 37
      src/generators/gencpp.ml
  38. 16 16
      src/generators/gencs.ml
  39. 9 9
      src/generators/genhl.ml
  40. 4 4
      src/generators/genhxold.ml
  41. 17 17
      src/generators/genjava.ml
  42. 2 2
      src/generators/genjs.ml
  43. 8 8
      src/generators/genjvm.ml
  44. 2 2
      src/generators/genlua.ml
  45. 4 4
      src/generators/genneko.ml
  46. 8 8
      src/generators/genphp7.ml
  47. 5 5
      src/generators/genpy.ml
  48. 1 1
      src/generators/genswf.ml
  49. 4 4
      src/generators/genswf9.ml
  50. 1 1
      src/macro/eval/evalMain.ml
  51. 2 2
      src/macro/eval/evalPrototype.ml
  52. 4 4
      src/macro/macroApi.ml
  53. 1 1
      src/optimization/dce.ml
  54. 2 2
      src/optimization/inline.ml
  55. 2 2
      src/optimization/optimizer.ml
  56. 6 6
      src/typing/callUnification.ml
  57. 6 6
      src/typing/calls.ml
  58. 2 2
      src/typing/fields.ml
  59. 1 1
      src/typing/finalization.ml
  60. 4 4
      src/typing/forLoop.ml
  61. 2 2
      src/typing/generic.ml
  62. 1 1
      src/typing/macroContext.ml
  63. 8 8
      src/typing/matcher.ml
  64. 3 3
      src/typing/nullSafety.ml
  65. 2 2
      src/typing/operators.ml
  66. 2 2
      src/typing/overloadResolution.ml
  67. 10 6
      src/typing/typeload.ml
  68. 7 3
      src/typing/typeloadCheck.ml
  69. 12 12
      src/typing/typeloadFields.ml
  70. 2 2
      src/typing/typeloadFunction.ml
  71. 1 1
      src/typing/typeloadModule.ml
  72. 1 1
      src/typing/typeloadParse.ml
  73. 11 11
      src/typing/typer.ml
  74. 2 2
      src/typing/typerBase.ml
  75. 12 12
      src/typing/typerDisplay.ml
  76. 1 1
      std/haxe/macro/Type.hx

+ 12 - 8
src/codegen/codegen.ml

@@ -90,7 +90,7 @@ let update_cache_dependencies t =
 		| TAbstract(a,tl) ->
 			add_dependency m a.a_module;
 			List.iter (check_t m) tl;
-		| TFun(targs,tret) ->
+		| TFun(targs,tret,_) ->
 			List.iter (fun (_,_,t) -> check_t m t) targs;
 			check_t m tret;
 		| TAnon an ->
@@ -157,9 +157,13 @@ let rec find_field com c f =
 
 let fix_override com c f fd =
 	let f2 = (try Some (find_field com c f) with Not_found -> None) in
+	let extract_fun f2 = match follow f2.cf_type with
+		| TFun (args,ret,coro) -> args, ret, coro
+		| _ -> die "" __LOC__
+	in
 	match f2,fd with
 		| Some (f2), Some(fd) ->
-			let targs, tret = (match follow f2.cf_type with TFun (args,ret) -> args, ret | _ -> die "" __LOC__) in
+			let targs, tret, coro = extract_fun f2 in
 			let changed_args = ref [] in
 			let prefix = "_tmp_" in
 			let nargs = List.map2 (fun ((v,ct) as cur) (_,_,t2) ->
@@ -197,10 +201,10 @@ let fix_override com c f fd =
 			let targs = List.map (fun(v,c) -> (v.v_name, Option.is_some c, v.v_type)) nargs in
 			let fde = (match f.cf_expr with None -> die "" __LOC__ | Some e -> e) in
 			f.cf_expr <- Some { fde with eexpr = TFunction fd2 };
-			f.cf_type <- TFun(targs,tret);
+			f.cf_type <- TFun(targs,tret,coro);
 		| Some(f2), None when (has_class_flag c CInterface) ->
-			let targs, tret = (match follow f2.cf_type with TFun (args,ret) -> args, ret | _ -> die "" __LOC__) in
-			f.cf_type <- TFun(targs,tret)
+			let targs, tret, coro = extract_fun f2 in
+			f.cf_type <- TFun(targs,tret,coro)
 		| _ ->
 			()
 
@@ -334,7 +338,7 @@ module Dump = struct
 							| Some e -> " = " ^ (s_cf_expr f));
 						| Method m -> if ((has_class_flag c CExtern) || (has_class_flag c CInterface)) then (
 							match f.cf_type with
-							| TFun(al,t) -> print "(%s):%s;" (String.concat ", " (
+							| TFun(al,t,_) -> print "(%s):%s;" (String.concat ", " (
 								List.map (fun (n,o,t) -> n ^ ":" ^ (s_type t)) al))
 								(s_type t)
 							| _ -> ()
@@ -365,7 +369,7 @@ module Dump = struct
 					let f = PMap.find n e.e_constrs in
 					print "\t%s%s;\n" f.ef_name (
 						match f.ef_type with
-						| TFun (al,t) -> Printf.sprintf "(%s)" (String.concat ", "
+						| TFun (al,t,_) -> Printf.sprintf "(%s)" (String.concat ", "
 							(List.map (fun (n,o,t) -> (if o then "?" else "") ^ n ^ ":" ^ (s_type t)) al))
 						| _ -> "")
 				) e.e_names;
@@ -502,7 +506,7 @@ module UnificationCallback = struct
 		List.rev (loop [] el tl)
 
 	let check_call f el t = match follow t with
-		| TFun(args,_) ->
+		| TFun(args,_,_) ->
 			check_call_params f el args
 		| _ ->
 			List.map (fun e -> f e t_dynamic) el

+ 11 - 11
src/codegen/gencommon/castDetect.ml

@@ -176,7 +176,7 @@ let rec type_eq gen param a b =
 	| TInst (c1,tl1) , TInst (c2,tl2) ->
 		if c1 != c2 && not (param = EqCoreType && c1.cl_path = c2.cl_path) && (match c1.cl_kind, c2.cl_kind with KExpr _, KExpr _ -> false | _ -> true) then Type.error [cannot_unify a b];
 		List.iter2 (type_eq gen param) tl1 tl2
-	| TFun (l1,r1) , TFun (l2,r2) when List.length l1 = List.length l2 ->
+	| TFun (l1,r1,coro1) , TFun (l2,r2,coro2) when coro1 = coro2 && List.length l1 = List.length l2 ->
 		(try
 			type_eq gen param r1 r2;
 			List.iter2 (fun (n,o1,t1) (_,o2,t2) ->
@@ -513,7 +513,7 @@ let rec handle_cast gen e real_to_t real_from_t =
 				e
 			else
 				mk_cast true to_t e
-		| TFun(args, ret), TFun(args2, ret2) ->
+		| TFun(args, ret, coro1), TFun(args2, ret2, coro2) when coro1 = coro2 ->
 			let get_args = List.map (fun (_,_,t) -> t) in
 			(try List.iter2 (type_eq gen (EqBothDynamic)) (ret :: get_args args) (ret2 :: get_args args2); e with | Unify_error _ | Invalid_argument _ -> mk_cast true to_t e)
 		| _, _ ->
@@ -611,7 +611,7 @@ let choose_ctor gen cl tparams etl maybe_empty_t p =
 			let count = ref 0 in
 			let is_empty_call = Type.type_iseq t empty_t in
 			let ret = List.filter (fun cf -> match follow cf.cf_type with
-				| TFun([_,_,t],_) ->
+				| TFun([_,_,t],_,_) ->
 					replace_mono t; incr count; is_empty_call = (Type.type_iseq t empty_t)
 				| _ -> false) ctors
 			in
@@ -690,7 +690,7 @@ let change_rest tfun elist =
 			List.rev acc
 	in
 	let args,ret = get_fun tfun in
-	TFun(loop [] args elist, ret)
+	TFun(loop [] args elist, ret, false)
 
 let fastcast_if_needed gen expr real_to_t real_from_t =
 	if Common.defined gen.gcon Define.FastCast then begin
@@ -724,7 +724,7 @@ let handle_type_parameter gen e e1 ef ~clean_ef ~overloads_cast_to_base f elist
 				efield
 			| Some ecall ->
 				match follow efield.etype with
-					| TFun(_,ret) ->
+					| TFun(_,ret,_) ->
 						(* closures will be handled by the closure handler. So we will just hint what's the expected type *)
 						(* FIXME: should closures have also its arguments cast correctly? In the current implementation I think not. TO_REVIEW *)
 						handle_cast gen { ecall with eexpr = TCall(efield, elist) } (gen.greal_type ecall.etype) ret
@@ -741,7 +741,7 @@ let handle_type_parameter gen e e1 ef ~clean_ef ~overloads_cast_to_base f elist
 			let args_list args = (if not calls_parameters_explicitly then t_dynamic else snd args) :: (List.map (fun (n,o,t) -> t) (fst args)) in
 
 			let monos = List.map (fun _ -> mk_mono()) params in
-			let original = args_list (get_fun (apply_params params monos (TFun(fst original_args,snd original_args)))) in
+			let original = args_list (get_fun (apply_params params monos (TFun(fst original_args,snd original_args,false)))) in
 			let applied = args_list applied_args in
 
 			(try
@@ -865,7 +865,7 @@ let handle_type_parameter gen e e1 ef ~clean_ef ~overloads_cast_to_base f elist
 			else begin
 				(* infer arguments *)
 				(* let called_t = TFun(List.map (fun e -> "arg",false,e.etype) elist, ecall.etype) in *)
-				let called_t = match follow e1.etype with | TFun _ -> e1.etype | _ -> TFun(List.map (fun e -> "arg",false,e.etype) elist, ecall.etype)	in (* workaround for issue #1742 *)
+				let called_t = match follow e1.etype with | TFun _ -> e1.etype | _ -> TFun(List.map (fun e -> "arg",false,e.etype) elist, ecall.etype, false)	in (* workaround for issue #1742 *)
 				let called_t = change_rest called_t elist in
 				let original = (get_fun (apply_params cl.cl_params params actual_t)) in
 				let applied = (get_fun called_t) in
@@ -935,7 +935,7 @@ let handle_type_parameter gen e e1 ef ~clean_ef ~overloads_cast_to_base f elist
 				let pt = match e with | None -> real_type | Some _ -> snd (get_fun e1.etype) in
 				let _params = match follow pt with | TEnum(_, p) -> p | _ -> gen.gcon.warning (debug_expr e1) e1.epos; die "" __LOC__ in
 				let args, ret = get_fun efield.ef_type in
-				let actual_t = TFun(List.map (fun (n,o,t) -> (n,o,gen.greal_type t)) args, gen.greal_type ret) in
+				let actual_t = TFun(List.map (fun (n,o,t) -> (n,o,gen.greal_type t)) args, gen.greal_type ret, false) in
 				(*
 					because of differences on how <Dynamic> is handled on the platforms, this is a hack to be able to
 					correctly use class field type parameters with RealTypeParams
@@ -1158,14 +1158,14 @@ let configure gen ?(overloads_cast_to_base = false) maybe_empty_t calls_paramete
 					let args,rt = get_fun (apply_params sup.cl_params stl cf.cf_type) in
 					let eparams = List.map2 (fun e (_,_,t) ->
 						handle (run e) t e.etype
-					) (wrap_rest_args gen (TFun (args,rt)) eparams e.epos) args in
+					) (wrap_rest_args gen (TFun (args,rt,false)) eparams e.epos) args in
 					{ e with eexpr = TCall(ef, eparams) }
 				with | Not_found ->
 					gen.gcon.warning "No overload found for this constructor call" e.epos;
 					{ e with eexpr = TCall(ef, List.map run eparams) })
 			| TCall (ef, eparams) ->
 				(match ef.etype with
-					| TFun(p, ret) ->
+					| TFun(p, ret, _) ->
 						handle ({ e with eexpr = TCall(run ef, List.map2 (fun param (_,_,t) -> handle (run param) t param.etype) eparams p) }) e.etype ret
 					| _ -> Type.map_expr run e
 				)
@@ -1186,7 +1186,7 @@ let configure gen ?(overloads_cast_to_base = false) maybe_empty_t calls_paramete
 				let args,rt = get_fun (apply_params sup.cl_params stl cf.cf_type) in
 				let eparams = List.map2 (fun e (_,_,t) ->
 					handle (run e) t e.etype
-				) (wrap_rest_args gen (TFun (args,rt)) eparams e.epos) args in
+				) (wrap_rest_args gen (TFun (args,rt,false)) eparams e.epos) args in
 				{ e with eexpr = TNew(cl, tparams, eparams) }
 			with | Not_found ->
 				gen.gcon.warning "No overload found for this constructor call" e.epos;

+ 19 - 19
src/codegen/gencommon/closuresToClass.ml

@@ -106,7 +106,7 @@ let rec cleanup_delegate e = match e.eexpr with
 	| _ -> e
 
 let funct gen t = match follow (run_follow gen t) with
-	| TFun(args,ret) -> args,ret
+	| TFun(args,ret,_) -> args,ret
 	| _ -> raise Not_found
 
 let mk_conversion_fun gen e =
@@ -235,7 +235,7 @@ let traverse gen ?tparam_anon_decl ?tparam_anon_acc (handle_anon_func:texpr->tfu
 										dynamic_func_call { e with eexpr = TCall(run e1, List.map run params) }
 									| _ ->
 										let i = ref 0 in
-										let t = TFun(List.map (fun e -> incr i; "arg" ^ (string_of_int !i), false, e.etype) params, e.etype) in
+										let t = TFun(List.map (fun e -> incr i; "arg" ^ (string_of_int !i), false, e.etype) params, e.etype, false) in
 										dynamic_func_call { e with eexpr = TCall( mk_castfast t (run e1), List.map run params ) }
 						)
 					(* | FNotFound ->
@@ -247,7 +247,7 @@ let traverse gen ?tparam_anon_decl ?tparam_anon_acc (handle_anon_func:texpr->tfu
 								dynamic_func_call { e with eexpr = TCall(run e1, List.map run params) }
 							| _ ->
 								let i = ref 0 in
-								let t = TFun(List.map (fun e -> incr i; "arg" ^ (string_of_int !i), false, e.etype) params, e.etype) in
+								let t = TFun(List.map (fun e -> incr i; "arg" ^ (string_of_int !i), false, e.etype) params, e.etype, false) in
 								dynamic_func_call { e with eexpr = TCall( mk_castfast t (run e1), List.map run params ) }
 				)
 			| TFunction tf ->
@@ -264,7 +264,7 @@ let traverse gen ?tparam_anon_decl ?tparam_anon_acc (handle_anon_func:texpr->tfu
 						let t = TFun(List.map (fun e ->
 								incr i;
 								("p" ^ (string_of_int !i), false, e.etype)
-							) params, e.etype)
+							) params, e.etype, false)
 						in
 						fun e -> mk_castfast t e
 				in
@@ -281,7 +281,7 @@ let rec get_type_params acc t =
 		| TInst(( { cl_kind = KTypeParameter constraints } as cl), []) ->
 			let params = List.fold_left get_type_params acc constraints in
 			List.filter (fun t -> not (List.memq t acc)) (cl :: params) @ acc;
-		| TFun (params,tret) ->
+		| TFun (params,tret,_) ->
 			List.fold_left get_type_params acc ( tret :: List.map (fun (_,_,t) -> t) params )
 		| TDynamic t ->
 			(match t with | TDynamic _ -> acc | _ -> get_type_params acc t)
@@ -325,7 +325,7 @@ let get_captured expr =
 			| TFunction(tf) ->
 				List.iter (fun (v,_) -> Hashtbl.add ignored v.v_id v) tf.tf_args;
 				(match follow expr.etype with
-					| TFun(args,ret) ->
+					| TFun(args,ret,_) ->
 						List.iter (fun (_,_,t) ->
 							check_params t
 						) args;
@@ -466,7 +466,7 @@ let configure gen ft =
 				ifield,ifield,sa
 			| Some _ ->
 				let pos = cls.cl_pos in
-				let cf = mk_class_field "Delegate" (TFun(fun_args tfunc.tf_args, tfunc.tf_type)) true pos (Method MethNormal) [] in
+				let cf = mk_class_field "Delegate" (TFun(fun_args tfunc.tf_args, tfunc.tf_type, false)) true pos (Method MethNormal) [] in
 				cf.cf_expr <- Some { fexpr with eexpr = TFunction { tfunc with tf_expr = func_expr }; };
 				add_class_field_flag cf CfFinal;
 				cls.cl_ordered_fields <- cf :: cls.cl_ordered_fields;
@@ -506,7 +506,7 @@ let configure gen ft =
 			epos = pos;
 		} in
 
-		let ctor_type = (TFun(ctor_sig, gen.gcon.basic.tvoid)) in
+		let ctor_type = (TFun(ctor_sig, gen.gcon.basic.tvoid, false)) in
 		let ctor = mk_class_field "new" ctor_type true cls.cl_pos (Method(MethNormal)) [] in
 		ctor.cf_expr <- Some(
 		{
@@ -789,13 +789,13 @@ struct
 				UPDATE: the fix will be that Int64 won't be a typedef to Float/Int
 			*)
 			let changed_sig, arity, type_number, changed_sig_ret, is_void, is_dynamic_func = match follow old_sig with
-				| TFun(_sig, ret) ->
+				| TFun(_sig, ret, coro) ->
 					let type_n, ret_t = rettype_real_to_func ret in
 					let arity = List.length _sig in
 					let is_dynamic_func = arity >= max_arity in
 					let ret_t = if is_dynamic_func then t_dynamic else ret_t in
 
-					(TFun(args_real_to_func_sig _sig, ret_t), arity, type_n, ret_t, ExtType.is_void ret, is_dynamic_func)
+					(TFun(args_real_to_func_sig _sig, ret_t, coro), arity, type_n, ret_t, ExtType.is_void ret, is_dynamic_func)
 				| _ -> (print_endline (s_type (print_context()) (follow old_sig) )); die "" __LOC__
 			in
 
@@ -868,12 +868,12 @@ struct
 			let invoke_fun = if params_len >= max_arity then "invokeDynamic" else "invoke" ^ (string_of_int params_len) ^ postfix in
 			let invoke_fun = mk_internal_name "hx" invoke_fun in
 			let fun_t = match follow tc.etype with
-				| TFun(_sig, _) ->
-					TFun(args_real_to_func_sig _sig, ret_t)
+				| TFun(_sig, _, coro) ->
+					TFun(args_real_to_func_sig _sig, ret_t, coro)
 				| _ ->
 					let i = ref 0 in
 					let _sig = List.map (fun p -> let name = "arg" ^ (string_of_int !i) in incr i; (name,false,p.etype) ) params in
-					TFun(args_real_to_func_sig _sig, ret_t)
+					TFun(args_real_to_func_sig _sig, ret_t, false)
 			in
 
 			let may_cast = match follow call_expr.etype with
@@ -904,7 +904,7 @@ struct
 			let mk_this field t = { (mk_field_access gen this field pos) with etype = t } in
 
 			let mk_invoke_i i is_float =
-				let cf = mk_class_field (iname i is_float) (TFun(func_sig_i i, if is_float then basic.tfloat else t_dynamic)) false pos (Method MethNormal) [] in
+				let cf = mk_class_field (iname i is_float) (TFun(func_sig_i i, (if is_float then basic.tfloat else t_dynamic),false)) false pos (Method MethNormal) [] in
 				cf
 			in
 
@@ -963,7 +963,7 @@ struct
 
 				let fn_expr = map_fn i ret (List.map fst args) api in
 
-				let t = TFun(fun_args args, ret) in
+				let t = TFun(fun_args args, ret, false) in
 
 				let tfunction =
 					{
@@ -1010,7 +1010,7 @@ struct
 			in
 
 			let args = [dynamic_arg, None] in
-			let dyn_t = TFun(fun_args args, t_dynamic) in
+			let dyn_t = TFun(fun_args args, t_dynamic, false) in
 			let dyn_cf = mk_class_field (mk_internal_name "hx" "invokeDynamic") dyn_t false pos (Method MethNormal) [] in
 
 			dyn_cf.cf_expr <- Some {
@@ -1024,7 +1024,7 @@ struct
 			};
 
 			let additional_cfs = begin
-				let new_t = TFun(["arity", false, basic.tint; "type", false, basic.tint],basic.tvoid) in
+				let new_t = TFun(["arity", false, basic.tint; "type", false, basic.tint],basic.tvoid, false) in
 				let new_cf = mk_class_field "new" (new_t) true pos (Method MethNormal) [] in
 				let v_arity, v_type = alloc_var "arity" basic.tint, alloc_var "type" basic.tint in
 				let mk_assign v field = mk (TBinop (OpAssign, mk_this field v.v_type, mk_local v pos)) v.v_type pos in
@@ -1095,7 +1095,7 @@ struct
 			let mk_this field t = { (mk_field_access gen this field pos) with etype = t } in
 
 			let mk_invoke_switch i api =
-				let t = TFun (func_sig_i i, t_dynamic) in
+				let t = TFun (func_sig_i i, t_dynamic, false) in
 				(* case i: return this.invokeX_o(0, 0, 0, 0, 0, ... arg[0], args[1]....); *)
 				[make_int gen.gcon.basic i pos], mk_return (mk (TCall(mk_this (iname i false) t, mk_dyn_call i api)) t_dynamic pos)
 			in
@@ -1109,7 +1109,7 @@ struct
 			let type_name = mk_internal_name "fn" "type" in
 			let mk_expr i is_float vars =
 				let call_expr =
-					let call_t = TFun(List.map (fun v -> (v.v_name, false, v.v_type)) vars, if is_float then t_dynamic else basic.tfloat) in
+					let call_t = TFun(List.map (fun v -> (v.v_name, false, v.v_type)) vars, (if is_float then t_dynamic else basic.tfloat), false) in
 					{
 						eexpr = TCall(mk_this (iname i (not is_float)) call_t, List.map (fun v -> mk_local v pos) vars);
 						etype = if is_float then t_dynamic else basic.tfloat;

+ 1 - 1
src/codegen/gencommon/enumToClass.ml

@@ -118,7 +118,7 @@ struct
 			incr i;
 
 			let cf = match follow ef.ef_type with
-				| TFun(params,ret) ->
+				| TFun(params,ret,_) ->
 					let dup_types =
 						if handle_type_params then
 							List.map (fun (s,t) -> (s, TInst (map_param (get_cl_t t), []))) en.e_params

+ 7 - 7
src/codegen/gencommon/enumToClass2.ml

@@ -108,7 +108,7 @@ module EnumToClass2Modf = struct
 			let etag = make_string gen.gcon.basic name pos in
 			let efields = ref [] in
 			(match follow ef.ef_type with
-				| TFun(_, _) ->
+				| TFun(_, _, _) ->
 					(* erase type params *)
 					let ef_type =
 						let t = apply_params en.e_params (List.map (fun _ -> t_dynamic) en.e_params) ef.ef_type in
@@ -162,7 +162,7 @@ module EnumToClass2Modf = struct
 
 					ctor_block := (mk (TCall(esuper,[make_int gen.gcon.basic index pos])) basic.tvoid pos) :: !ctor_block;
 
-					let cf_ctor_t = TFun (params, basic.tvoid) in
+					let cf_ctor_t = TFun (params, basic.tvoid, false) in
 					let cf_ctor = mk_class_field "new" cf_ctor_t true pos (Method MethNormal) [] in
 					cf_ctor.cf_expr <- Some {
 						eexpr = TFunction {
@@ -175,7 +175,7 @@ module EnumToClass2Modf = struct
 					};
 					cl_ctor.cl_constructor <- Some cf_ctor;
 
-					let cf_toString_t = TFun ([],basic.tstring) in
+					let cf_toString_t = TFun ([],basic.tstring,false) in
 					let cf_toString = mk_class_field "toString" cf_toString_t true pos (Method MethNormal) [] in
 
 					let etoString_args = mk_array_decl t_dynamic !efields pos in
@@ -227,7 +227,7 @@ module EnumToClass2Modf = struct
 						equals_exprs := (List.rev !param_equal_checks) @ !equals_exprs;
 						equals_exprs := mk_return (make_bool gen.gcon.basic true pos) :: !equals_exprs;
 
-						let cf_Equals_t = TFun([("other",false,t_dynamic)],basic.tbool) in
+						let cf_Equals_t = TFun([("other",false,t_dynamic)],basic.tbool,false) in
 						let cf_Equals = mk_class_field "Equals" cf_Equals_t true pos (Method MethNormal) [] in
 						cf_Equals.cf_expr <- Some {
 							eexpr = TFunction {
@@ -243,7 +243,7 @@ module EnumToClass2Modf = struct
 
 					(* add GetHashCode field *)
 					begin
-						let cf_GetHashCode_t = TFun([],basic.tint) in
+						let cf_GetHashCode_t = TFun([],basic.tint,false) in
 						let cf_GetHashCode = mk_class_field "GetHashCode" cf_GetHashCode_t true pos (Method MethNormal) [] in
 						cf_GetHashCode.cf_expr <- Some {
 							eexpr = TFunction {
@@ -260,7 +260,7 @@ module EnumToClass2Modf = struct
 					end
 
 				| _ ->
-					let cf_ctor_t = TFun([], basic.tvoid) in
+					let cf_ctor_t = TFun([], basic.tvoid,false) in
 					let cf_ctor = mk_class_field "new" cf_ctor_t true pos (Method MethNormal) [] in
 					cf_ctor.cf_expr <- Some {
 						eexpr = TFunction {
@@ -376,7 +376,7 @@ module EnumToClass2Exprf = struct
 				let ecast = mk (TCall (mk (TIdent "__as__") t_dynamic f.epos, [f])) (TInst (cl_ctor, [])) f.epos in
 
 				(match ef.ef_type with
-				| TFun (params, _) ->
+				| TFun (params, _, _) ->
 					let fname, _, _ = List.nth params i in
 					field ecast fname e.etype e.epos
 				| _ -> Globals.die "" __LOC__)

+ 6 - 6
src/codegen/gencommon/fixOverrides.ml

@@ -94,7 +94,7 @@ let run ~explicit_fn_name ~get_vmtype gen =
 							if List.length f.cf_params <> List.length f2.cf_params then raise Not_found;
 							replace_mono t2;
 							match follow (apply_params f2.cf_params (List.map snd f.cf_params) t2), follow real_ftype with
-							| TFun(a1,r1), TFun(a2,r2) when not implement_explicitly && not (type_iseq r1 r2) && Overloads.same_overload_args ~get_vmtype real_ftype t2 f f2 ->
+							| TFun(a1,r1,coro1), TFun(a2,r2,coro2) when not implement_explicitly && not (type_iseq r1 r2) && Overloads.same_overload_args ~get_vmtype real_ftype t2 f f2 ->
 								(* different return types are the trickiest cases to deal with *)
 								(* check for covariant return type *)
 								let is_covariant = match follow r1, follow r2 with
@@ -108,16 +108,16 @@ let run ~explicit_fn_name ~get_vmtype gen =
 								if not is_covariant then begin
 									(* override return type and cast implemented function *)
 									let args, newr = match follow t2, follow (apply_params f.cf_params (List.map snd f2.cf_params) real_ftype) with
-										| TFun(a,_), TFun(_,r) -> a,r
+										| TFun(a,_,_), TFun(_,r,_) -> a,r
 										| _ -> Globals.die "" __LOC__
 									in
-									f2.cf_type <- TFun(args,newr);
+									f2.cf_type <- TFun(args,newr,coro1);
 									(match f2.cf_expr with
 									| Some ({ eexpr = TFunction tf } as e) ->
 											f2.cf_expr <- Some { e with eexpr = TFunction { tf with tf_type = newr } }
 									| _ -> ())
 								end
-							| TFun(a1,r1), TFun(a2,r2) ->
+							| TFun(a1,r1,coro1), TFun(a2,r2,coro2) ->
 								(* just implement a function that will call the main one *)
 								let name, is_explicit = match explicit_fn_name with
 									| Some fn when not (type_iseq r1 r2) && Overloads.same_overload_args ~get_vmtype real_ftype t2 f f2 ->
@@ -133,7 +133,7 @@ let run ~explicit_fn_name ~get_vmtype gen =
 								let vars = List.map (fun (n,_,t) -> alloc_var n t) a2 in
 
 								let args = List.map2 (fun v (_,_,t) -> mk_cast t (mk_local v f2.cf_pos)) vars a1 in
-								let field = { eexpr = TField(this, FInstance(c,List.map snd c.cl_params,f2)); etype = TFun(a1,r1); epos = p } in
+								let field = { eexpr = TField(this, FInstance(c,List.map snd c.cl_params,f2)); etype = TFun(a1,r1,coro1); epos = p } in
 								let call = { eexpr = TCall(field, args); etype = r1; epos = p } in
 								(* let call = gen.gparam_func_call call field (List.map snd f.cf_params) args in *)
 								let is_void = ExtType.is_void r2 in
@@ -192,7 +192,7 @@ let run ~explicit_fn_name ~get_vmtype gen =
 								epos = tf.tf_expr.epos
 							} in
 							let has_contravariant_args = match (get_real_fun gen f.cf_type, actual_t) with
-								| TFun(current_args,_), TFun(original_args,_) ->
+								| TFun(current_args,_,_), TFun(original_args,_,_) ->
 										List.exists2 (fun (_,_,cur_arg) (_,_,orig_arg) -> try
 											unify orig_arg cur_arg;
 											try

+ 5 - 5
src/codegen/gencommon/gencommon.ml

@@ -174,7 +174,7 @@ let get_abstract mt = match mt with TAbstractDecl a -> a | _ -> failwith (Printf
 
 let get_fun t =
 	match follow t with
-	| TFun (args, ret) -> args, ret
+	| TFun (args, ret, _) -> args, ret
 	| t -> (trace (debug_type t)); die "" __LOC__
 
 let mk_cast t e = Type.mk_cast e t e.epos
@@ -990,7 +990,7 @@ let mk_paren e =
 
 let get_real_fun gen t =
 	match follow t with
-	| TFun(args,t) -> TFun(List.map (fun (n,o,t) -> n,o,gen.greal_type t) args, gen.greal_type t)
+	| TFun(args,t,coro) -> TFun(List.map (fun (n,o,t) -> n,o,gen.greal_type t) args, gen.greal_type t,coro)
 	| _ -> t
 
 let mk_nativearray_decl gen t el pos =
@@ -1004,7 +1004,7 @@ let mk_nativearray_decl gen t el pos =
 *)
 let wrap_rest_args gen callee_type params p =
 	match follow callee_type with
-	| TFun(args, _) ->
+	| TFun(args, _, _) ->
 		let rec loop args params =
 			match args, params with
 			(* last argument expects rest parameters *)
@@ -1088,7 +1088,7 @@ let rec replace_mono t =
 		| Some _ -> ())
 	| TEnum (_,p) | TInst (_,p) | TType (_,p) | TAbstract (_,p) ->
 		List.iter replace_mono p
-	| TFun (args,ret) ->
+	| TFun (args,ret,_) ->
 		List.iter (fun (_,_,t) -> replace_mono t) args;
 		replace_mono ret
 	| TAnon _
@@ -1174,7 +1174,7 @@ let find_first_declared_field gen orig_cl ?get_vmtype ?exact_field field =
 		let declared_t = apply_params c.cl_params tl f.cf_type in
 		let params_t = apply_params c.cl_params tlch f.cf_type in
 		let actual_t = match follow params_t with
-		| TFun(args,ret) -> TFun(List.map (fun (n,o,t) -> (n,o,gen.greal_type t)) args, gen.greal_type ret)
+		| TFun(args,ret,coro) -> TFun(List.map (fun (n,o,t) -> (n,o,gen.greal_type t)) args, gen.greal_type ret,coro)
 		| _ -> gen.greal_type params_t in
 		Some(f,actual_t,declared_t,params_t,c,tl,tlch)
 

+ 1 - 1
src/codegen/gencommon/initFunction.ml

@@ -178,7 +178,7 @@ let handle_class com cl =
 					cl.cl_constructor <- Some ctor;
 					ctor
 				with Not_found ->
-					let ctor = mk_class_field "new" (TFun([], com.basic.tvoid)) false cl.cl_pos (Method MethNormal) [] in
+					let ctor = mk_class_field "new" (TFun([], com.basic.tvoid, false)) false cl.cl_pos (Method MethNormal) [] in
 					ctor.cf_expr <- Some
 					{
 						eexpr = TFunction {

+ 2 - 2
src/codegen/gencommon/interfaceVarsDeleteModf.ml

@@ -48,13 +48,13 @@ let configure gen =
 				| Var vkind when Type.is_physical_field cf || not (Meta.has Meta.Property cf.cf_meta) ->
 					(match vkind.v_read with
 						| AccCall ->
-							let newcf = mk_class_field ("get_" ^ cf.cf_name) (TFun([],cf.cf_type)) true cf.cf_pos (Method MethNormal) [] in
+							let newcf = mk_class_field ("get_" ^ cf.cf_name) (TFun([],cf.cf_type,false)) true cf.cf_pos (Method MethNormal) [] in
 							to_add := newcf :: !to_add;
 						| _ -> ()
 					);
 					(match vkind.v_write with
 						| AccCall ->
-							let newcf = mk_class_field ("set_" ^ cf.cf_name) (TFun(["val",false,cf.cf_type],cf.cf_type)) true cf.cf_pos (Method MethNormal) [] in
+							let newcf = mk_class_field ("set_" ^ cf.cf_name) (TFun(["val",false,cf.cf_type],cf.cf_type,false)) true cf.cf_pos (Method MethNormal) [] in
 							to_add := newcf :: !to_add;
 						| _ -> ()
 					);

+ 2 - 2
src/codegen/gencommon/normalize.ml

@@ -58,8 +58,8 @@ let rec filter_param (stack:t list) t =
 	| TAnon a ->
 		let fields = PMap.map (fun f -> { f with cf_type = filter_param stack f.cf_type }) a.a_fields in
 		mk_anon ~fields a.a_status
-	| TFun(args,ret) ->
-		TFun(List.map (fun (n,o,t) -> (n,o,filter_param stack t)) args, filter_param stack ret)
+	| TFun(args,ret,coro) ->
+		TFun(List.map (fun (n,o,t) -> (n,o,filter_param stack t)) args, filter_param stack ret, coro)
 	| TDynamic _ ->
 		t
 	| TLazy f ->

+ 3 - 3
src/codegen/gencommon/overloadingConstructor.ml

@@ -129,7 +129,7 @@ let create_static_ctor com ~empty_ctor_expr cl ctor follow_type =
 
 		let fn_args, _ = get_fun ctor.cf_type in
 		let ctor_params = List.map snd ctor_types in
-		let fn_type = TFun((me.v_name,false, me.v_type) :: List.map (fun (n,o,t) -> (n,o,apply_params cl.cl_params ctor_params t)) fn_args, com.basic.tvoid) in
+		let fn_type = TFun((me.v_name,false, me.v_type) :: List.map (fun (n,o,t) -> (n,o,apply_params cl.cl_params ctor_params t)) fn_args, com.basic.tvoid, false) in
 		let cur_tf_args = match ctor.cf_expr with
 		| Some { eexpr = TFunction(tf) } -> tf.tf_args
 		| _ -> Globals.die "" __LOC__
@@ -318,7 +318,7 @@ let init com (empty_ctor_type : t) (empty_ctor_expr : texpr) (follow_type : t ->
 							cl.cl_constructor <- Some ctor;
 							ctor
 						with Not_found -> (* create default constructor *)
-							let ctor = mk_class_field "new" (TFun ([], basic.tvoid)) false cl.cl_pos (Method MethNormal) [] in
+							let ctor = mk_class_field "new" (TFun ([], basic.tvoid, false)) false cl.cl_pos (Method MethNormal) [] in
 							ctor.cf_expr <- Some {
 								eexpr = TFunction {
 									tf_args = [];
@@ -359,7 +359,7 @@ let init com (empty_ctor_type : t) (empty_ctor_expr : texpr) (follow_type : t ->
 				if not (is_hxgen (TClassDecl cl)) then raise Exit;
 
 				(* get first *)
-				let empty_type = TFun (["empty",false,empty_ctor_type],basic.tvoid) in
+				let empty_type = TFun (["empty",false,empty_ctor_type],basic.tvoid,false) in
 				let super =
 					match cl.cl_super with
 					| None -> (* implement empty *)

+ 7 - 7
src/codegen/gencommon/realTypeParams.ml

@@ -87,7 +87,7 @@ let rec has_type_params t =
 		| TAbstract(_, params)
 		| TEnum(_, params)
 		| TInst(_, params) -> List.exists (fun t -> has_type_params t) params
-		| TFun(args,ret) ->
+		| TFun(args,ret,_) ->
 			List.exists (fun (n,o,t) -> has_type_params t) args || has_type_params ret
 		| _ -> false
 
@@ -251,7 +251,7 @@ let rec set_hxgeneric gen mds isfirst md =
 									| ef :: efs ->
 										let t = follow (gen.greal_type ef.ef_type) in
 										match t with
-											| TFun(args, _) ->
+											| TFun(args, _, _) ->
 												if List.exists (fun (n,o,t) ->
 													let t = follow t in
 													match t with
@@ -405,7 +405,7 @@ struct
 				let name = get_cast_name curcls in
 				if not (PMap.mem name cl.cl_fields) then begin
 					let reverse_params = List.map (apply_params curcls.cl_params params) reverse_params in
-					let cfield = mk_class_field name (TFun([], t_dynamic)) false cl.cl_pos (Method MethNormal) cparams in
+					let cfield = mk_class_field name (TFun([], t_dynamic, false)) false cl.cl_pos (Method MethNormal) cparams in
 					let field = { eexpr = TField(this, FInstance(cl,List.map snd cl.cl_params, cast_cfield)); etype = apply_params cast_cfield.cf_params reverse_params cast_cfield.cf_type; epos = p } in
 					let call =
 					{
@@ -461,7 +461,7 @@ struct
 		reset_temps();
 		let basic = gen.gcon.basic in
 		let cparams = List.map (fun (s,t) -> (s, TInst (map_param (get_cl_t t), []))) cl.cl_params in
-		let cfield = mk_class_field name (TFun([], t_dynamic)) false cl.cl_pos (Method MethNormal) cparams in
+		let cfield = mk_class_field name (TFun([], t_dynamic, false)) false cl.cl_pos (Method MethNormal) cparams in
 		let params = List.map snd cparams in
 
 		let fields = get_fields gen cl (List.map snd cl.cl_params) params [] in
@@ -589,7 +589,7 @@ struct
 		let basic = gen.gcon.basic in
 		let cparams = List.map (fun (s,t) -> ("To_" ^ s, TInst (map_param (get_cl_t t), []))) cf.cf_params in
 		let me_type = TInst(iface,[]) in
-		let cfield = mk_class_field ~static:true "__hx_cast" (TFun(["me",false,me_type], t_dynamic)) false iface.cl_pos (Method MethNormal) (cparams) in
+		let cfield = mk_class_field ~static:true "__hx_cast" (TFun(["me",false,me_type], t_dynamic, false)) false iface.cl_pos (Method MethNormal) (cparams) in
 		let params = List.map snd cparams in
 
 		let me = alloc_var "me" me_type in
@@ -635,10 +635,10 @@ struct
 			let name = get_cast_name iface in
 			if not (PMap.mem name cthis.cl_fields) then begin
 				let cparams = List.map (fun (s,t) -> ("To_" ^ s, TInst(map_param (get_cl_t t), []))) iface.cl_params in
-				let field = mk_class_field name (TFun([],t_dynamic)) false iface.cl_pos (Method MethNormal) cparams in
+				let field = mk_class_field name (TFun([],t_dynamic,false)) false iface.cl_pos (Method MethNormal) cparams in
 				let this = { eexpr = TConst TThis; etype = TInst(cthis, List.map snd cthis.cl_params); epos = cthis.cl_pos } in
 				field.cf_expr <- Some {
-					etype = TFun([],t_dynamic);
+					etype = TFun([],t_dynamic,false);
 					epos = this.epos;
 					eexpr = TFunction {
 						tf_type = t_dynamic;

+ 17 - 17
src/codegen/gencommon/reflectionCFs.ml

@@ -247,7 +247,7 @@ let call_super ctx fn_args ret_t cf cl this_t pos =
 	{
 		eexpr = TCall({
 			eexpr = TField({ eexpr = TConst(TSuper); etype = this_t; epos = pos }, FInstance(cl,List.map snd cl.cl_params,cf));
-			etype = TFun(fun_args fn_args, ret_t);
+			etype = TFun(fun_args fn_args, ret_t, false);
 			epos = pos;
 		}, List.map (fun (v,_) -> mk_local v pos) fn_args);
 		etype = ret_t;
@@ -473,7 +473,7 @@ let get_delete_field ctx cl is_dynamic =
 	let basic = gen.gcon.basic in
 	let tf_args, switch_var = field_type_args ctx pos in
 	let local_switch_var = mk_local switch_var pos in
-	let fun_type = TFun(fun_args tf_args,basic.tbool) in
+	let fun_type = TFun(fun_args tf_args,basic.tbool,false) in
 	let cf = mk_class_field (mk_internal_name "hx" "deleteField") fun_type false pos (Method MethNormal) [] in
 	let body = if is_dynamic then begin
 		let mk_this field t = { (mk_field_access gen this field pos) with etype = t } in
@@ -726,7 +726,7 @@ let implement_final_lookup ctx cl =
 					field_args @ [v,None], Some v
 			in
 
-			let fun_t = TFun(fun_args tf_args, ret_t) in
+			let fun_t = TFun(fun_args tf_args, ret_t, false) in
 			let cf = mk_class_field name fun_t false pos (Method MethNormal) [] in
 			let block = callback is_float field_args switch_var throw_errors_opt is_check_opt value_opt in
 			let block = if not is_set then let tl = begin
@@ -811,7 +811,7 @@ let implement_get_set ctx cl =
 			{ eexpr = TCall( { (mk_field_access gen this name pos) with etype = fun_t; }, params ); etype = snd (get_fun fun_t); epos = pos }
 		in
 
-		let fun_type = ref (TFun([], basic.tvoid)) in
+		let fun_type = ref (TFun([], basic.tvoid, false)) in
 		let fun_name = mk_internal_name "hx" ( (if is_set then "setField" else "getField") ^ (if is_float then "_f" else "") ) in
 		let cfield = mk_class_field fun_name !fun_type false pos (Method MethNormal) [] in
 
@@ -845,7 +845,7 @@ let implement_get_set ctx cl =
 
 			let do_default =
 					fun () ->
-						mk_return (mk_this_call_raw lookup_name (TFun(fun_args (field_args @ [value_var,None]),value_var.v_type)) ( List.map (fun (v,_) -> mk_local v pos) field_args @ [ value_local ] ))
+						mk_return (mk_this_call_raw lookup_name (TFun(fun_args (field_args @ [value_var,None]),value_var.v_type,false)) ( List.map (fun (v,_) -> mk_local v pos) field_args @ [ value_local ] ))
 			in
 
 			let do_field cf cf_type =
@@ -879,7 +879,7 @@ let implement_get_set ctx cl =
 					| Var { v_write = AccCall } ->
 						let bl =
 						[
-							mk_this_call_raw ("set_" ^ cf.cf_name) (TFun(["value",false,cf.cf_type], cf.cf_type)) [ value_local ];
+							mk_this_call_raw ("set_" ^ cf.cf_name) (TFun(["value",false,cf.cf_type], cf.cf_type, false)) [ value_local ];
 							mk_return value_local
 						] in
 						if not (Type.is_physical_field cf) then
@@ -911,7 +911,7 @@ let implement_get_set ctx cl =
 				let lookup_name = mk_internal_name "hx" "lookupField" in
 				let do_default =
 						fun () ->
-							mk_return (mk_this_call_raw lookup_name (TFun(fun_args (field_args @ [throw_errors,None;is_check,None; ]),t_dynamic)) ( List.map (fun (v,_) -> mk_local v pos) field_args @ [ throw_errors_local; is_check_local; ] ))
+							mk_return (mk_this_call_raw lookup_name (TFun(fun_args (field_args @ [throw_errors,None;is_check,None; ]),t_dynamic,false)) ( List.map (fun (v,_) -> mk_local v pos) field_args @ [ throw_errors_local; is_check_local; ] ))
 				in
 
 				(do_default, tf_args @ [ is_check,None; handle_prop,None; ])
@@ -921,7 +921,7 @@ let implement_get_set ctx cl =
 				let lookup_name = mk_internal_name "hx" "lookupField_f" in
 				let do_default =
 						fun () ->
-							mk_return (mk_this_call_raw lookup_name (TFun(fun_args (field_args @ [throw_errors,None; ]),basic.tfloat)) ( List.map (fun (v,_) -> mk_local v pos) field_args @ [ throw_errors_local; ] ))
+							mk_return (mk_this_call_raw lookup_name (TFun(fun_args (field_args @ [throw_errors,None; ]),basic.tfloat,false)) ( List.map (fun (v,_) -> mk_local v pos) field_args @ [ throw_errors_local; ] ))
 				in
 
 				(do_default, tf_args @ [ handle_prop,None; ])
@@ -930,12 +930,12 @@ let implement_get_set ctx cl =
 			let get_field cf cf_type ethis cl name =
 				match cf.cf_kind with
 					| Var { v_read = AccCall } when not (Type.is_physical_field cf) ->
-						mk_this_call_raw ("get_" ^ cf.cf_name) (TFun(["value",false,cf.cf_type], cf.cf_type)) []
+						mk_this_call_raw ("get_" ^ cf.cf_name) (TFun(["value",false,cf.cf_type], cf.cf_type, false)) []
 					| Var { v_read = AccCall } ->
 						{
 							eexpr = TIf(
 								handle_prop_local,
-								mk_this_call_raw ("get_" ^ cf.cf_name) (TFun(["value",false,cf.cf_type], cf.cf_type)) [],
+								mk_this_call_raw ("get_" ^ cf.cf_name) (TFun(["value",false,cf.cf_type], cf.cf_type, false)) [],
 								Some { eexpr = TField (ethis, FInstance(cl, List.map snd cl.cl_params, cf)); etype = cf_type; epos = pos }
 							);
 							etype = cf_type;
@@ -984,7 +984,7 @@ let implement_get_set ctx cl =
 
 		(* now we have do_default, do_field and tf_args *)
 		(* so create the switch expr *)
-		fun_type := TFun(List.map (fun (v,_) -> (v.v_name, false, v.v_type)) tf_args, if is_float then basic.tfloat else t_dynamic );
+		fun_type := TFun(List.map (fun (v,_) -> (v.v_name, false, v.v_type)) tf_args, (if is_float then basic.tfloat else t_dynamic), false);
 		let has_fields = ref false in
 
 		let content =
@@ -1054,7 +1054,7 @@ let implement_getFields ctx cl =
 	let base_arr = mk_local v_base_arr pos in
 
 	let tf_args = [(v_base_arr,None)] in
-	let t = TFun(fun_args tf_args, basic.tvoid) in
+	let t = TFun(fun_args tf_args, basic.tvoid, false) in
 	let cf = mk_class_field name t false pos (Method MethNormal) [] in
 
 	let e_pushfield = mk_field_access gen base_arr "push" pos in
@@ -1138,7 +1138,7 @@ let implement_invokeField ctx slow_invoke cl =
 
 	let dynamic_arg = alloc_var "dynargs" (gen.gclasses.nativearray t_dynamic) in
 	let all_args = field_args @ [ dynamic_arg, None ] in
-	let fun_t = TFun(fun_args all_args, t_dynamic) in
+	let fun_t = TFun(fun_args all_args, t_dynamic, false) in
 
 	let this_t = TInst(cl, List.map snd cl.cl_params) in
 	let this = { eexpr = TConst(TThis); etype = this_t; epos = pos } in
@@ -1218,7 +1218,7 @@ let implement_invokeField ctx slow_invoke cl =
 				let tf_args, args = tf_args @ ["isCheck", false, basic.tbool],          args @ [make_bool gen.gcon.basic false pos] in
 				let tf_args, args = tf_args @ ["handleProperties", false, basic.tbool], args @ [make_bool gen.gcon.basic false pos] in
 
-				mk (TCall ({ (mk_field_access gen this fun_name pos) with etype = TFun(tf_args, t_dynamic) }, args)) t_dynamic pos
+				mk (TCall ({ (mk_field_access gen this fun_name pos) with etype = TFun(tf_args, t_dynamic, false) }, args)) t_dynamic pos
 			end in
 			let field = mk_cast (TInst(ctx.rcf_ft.func_class,[])) field in
 			mk_return {
@@ -1261,7 +1261,7 @@ let implement_invokeField ctx slow_invoke cl =
 				tf_type = t_dynamic;
 				tf_expr = mk_block contents;
 			});
-			etype = TFun(fun_args all_args, t_dynamic);
+			etype = TFun(fun_args all_args, t_dynamic, false);
 			epos = pos;
 		};
 	if !is_override && not (!has_method) then () else begin
@@ -1279,7 +1279,7 @@ let implement_varargs_cl ctx cl =
 	let mk_this field t = { (mk_field_access gen this field pos) with etype = t } in
 
 	let invokedyn = mk_internal_name "hx" "invokeDynamic" in
-	let idyn_t = TFun([mk_internal_name "fn" "dynargs", false, gen.gclasses.nativearray t_dynamic], t_dynamic) in
+	let idyn_t = TFun([mk_internal_name "fn" "dynargs", false, gen.gclasses.nativearray t_dynamic], t_dynamic, false) in
 	let this_idyn = mk_this invokedyn idyn_t in
 
 	let map_fn arity ret vars api =
@@ -1389,7 +1389,7 @@ let implement_closure_cl ctx cl =
 		cl.cl_fields <- PMap.add cf.cf_name cf cl.cl_fields
 	) all_cfs;
 
-	let ctor_t = TFun(fun_args tf_args, basic.tvoid) in
+	let ctor_t = TFun(fun_args tf_args, basic.tvoid, false) in
 	let ctor_cf = mk_class_field "new" ctor_t true pos (Method MethNormal) [] in
 	ctor_cf.cf_expr <- Some {
 		eexpr = TFunction({

+ 2 - 2
src/codegen/genxml.ml

@@ -97,7 +97,7 @@ let rec gen_type ?(values=None) t =
 	| TInst (c,params) -> gen_type_decl "c" (TClassDecl c) params
 	| TAbstract (a,params) -> gen_type_decl "x" (TAbstractDecl a) params
 	| TType (t,params) -> gen_type_decl "t" (TTypeDecl t) params
-	| TFun (args,r) ->
+	| TFun (args,r,corotodo) ->
 		let names = String.concat ":" (List.map gen_arg_name args) in
 		let values = match values with
 			| None -> []
@@ -179,7 +179,7 @@ and gen_field att f =
 let gen_constr e =
 	let doc = gen_doc_opt e.ef_doc in
 	let args, t = (match follow e.ef_type with
-		| TFun (args,_) ->
+		| TFun (args,_,_) ->
 			["a",String.concat ":" (List.map gen_arg_name args)] ,
 			List.map (fun (_,opt,t) -> gen_type (if opt then follow_param t else t)) args @ doc
 		| _ ->

+ 3 - 3
src/codegen/overloads.ml

@@ -41,7 +41,7 @@ let same_overload_args ?(get_vmtype) t1 t2 f1 f2 =
 	let compare_types () =
 		let t1 = follow (apply_params f1.cf_params (List.map (fun (_,t) -> t) f2.cf_params) t1) in
 		match t1,follow t2 with
-		| TFun(tl1,_),TFun(tl2,_) ->
+		| TFun(tl1,_,coro1),TFun(tl2,_,coro2) when coro1 = coro2 ->
 			compare_arguments tl1 tl2
 		| _ ->
 			false
@@ -227,7 +227,7 @@ struct
 
 	let count_optionals t =
 		match follow t with
-		| TFun(args,_) ->
+		| TFun(args,_,_) ->
 			List.fold_left (fun acc (_,is_optional,_) -> if is_optional then acc + 1 else acc) 0 args
 		| _ ->
 			0
@@ -267,7 +267,7 @@ struct
 
 			let rated = ref [] in
 			List.iter (fun fcc -> match fcc.fc_type with
-				| TFun(args,ret) -> (try
+				| TFun(args,ret,_) -> (try
 					rated := ( fcc, mk_rate [] fcc.fc_args args ) :: !rated
 					with | Not_found -> ())
 				| _ -> die "" __LOC__

+ 3 - 3
src/compiler/displayOutput.ml

@@ -153,11 +153,11 @@ let print_type t p doc =
 
 let print_signatures tl =
 	let b = Buffer.create 0 in
-	List.iter (fun (((args,ret),_),doc) ->
+	List.iter (fun (((args,ret,coro),_),doc) ->
 		Buffer.add_string b "<type";
 		Option.may (fun d -> Buffer.add_string b (Printf.sprintf " d=\"%s\"" (htmlescape (gen_doc_text d)))) doc;
 		Buffer.add_string b ">\n";
-		Buffer.add_string b (htmlescape (s_type (print_context()) (TFun(args,ret))));
+		Buffer.add_string b (htmlescape (s_type (print_context()) (TFun(args,ret,coro))));
 		Buffer.add_string b "\n</type>\n";
 	) tl;
 	Buffer.contents b
@@ -183,7 +183,7 @@ let print_signature tl display_arg =
 	let st = s_type (print_context()) in
 	let s_arg (n,o,t) = Printf.sprintf "%s%s:%s" (if o then "?" else "") n (st t) in
 	let s_fun args ret = Printf.sprintf "(%s):%s" (String.concat ", " (List.map s_arg args)) (st ret) in
-	let siginf = List.map (fun (((args,ret),_),doc) ->
+	let siginf = List.map (fun (((args,ret,_),_),doc) ->
 		let label = s_fun args ret in
 		let parameters =
 			List.map (fun arg ->

+ 4 - 4
src/context/abstractCast.ml

@@ -130,7 +130,7 @@ let find_array_access_raise ctx a pl e1 e2o p =
 				else TAbstract(a,pl)
 			in
 			match follow (map cf.cf_type) with
-			| TFun([(_,_,tab);(_,_,ta1);(_,_,ta2)],r) as tf when is_set ->
+			| TFun([(_,_,tab);(_,_,ta1);(_,_,ta2)],r,_) as tf when is_set ->
 				begin try
 					Type.unify tab (get_ta());
 					let e1 = cast_or_unify_raise ctx ta1 e1 p in
@@ -140,7 +140,7 @@ let find_array_access_raise ctx a pl e1 e2o p =
 				with Unify_error _ | Error (Unify _,_) ->
 					loop cfl
 				end
-			| TFun([(_,_,tab);(_,_,ta1)],r) as tf when not is_set ->
+			| TFun([(_,_,tab);(_,_,ta1)],r,_) as tf when not is_set ->
 				begin try
 					Type.unify tab (get_ta());
 					let e1 = cast_or_unify_raise ctx ta1 e1 p in
@@ -258,7 +258,7 @@ let handle_abstract_casts ctx e =
 						begin try
 							let fa = quick_field m fname in
 							let get_fun_type t = match follow t with
-								| TFun(args,tr) as tf -> tf,args,tr
+								| TFun(args,tr,_) as tf -> tf,args,tr
 								| _ -> raise Not_found
 							in
 							let tf,args,tr = match fa with
@@ -288,7 +288,7 @@ let handle_abstract_casts ctx e =
 											maybe_cast e t e.epos :: add_casts orig_args args el
 									in
 									match follow e1.etype with
-									| TFun (orig_args,_) -> add_casts orig_args args el
+									| TFun (orig_args,_,_) -> add_casts orig_args args el
 									| _ -> el
 								else
 									el

+ 2 - 2
src/context/display/display.ml

@@ -294,7 +294,7 @@ let sort_fields l with_type tk =
 				(* For enum constructors, we consider the return type of the constructor function
 				   so it has the same priority as argument-less constructors. *)
 				let t' = match item.ci_kind,follow t' with
-					| ITEnumField _,TFun(_,r) -> r
+					| ITEnumField _,TFun(_,r,_) -> r
 					| _ -> t'
 				in
 				let t' = dynamify_type_params t' in
@@ -302,7 +302,7 @@ let sort_fields l with_type tk =
 				else if t' == t_dynamic then 5 (* dynamic isn't good, but better than incompatible *)
 				else try Type.unify t' t; 1 (* assignable - great *)
 				with Unify_error _ -> match follow t' with
-					| TFun(_,tr) ->
+					| TFun(_,tr,_) ->
 						if type_iseq tr t then 2 (* function returns our exact type - alright *)
 						else (try Type.unify tr t; 3 (* function returns compatible type - okay *)
 						with Unify_error _ -> 7) (* incompatible function - useless *)

+ 1 - 1
src/context/display/displayEmitter.ml

@@ -121,7 +121,7 @@ let display_field ctx origin scope cf p = match ctx.com.display.dms_kind with
 			cf
 		in
         let cf = match origin,scope,follow cf.cf_type with
-            | Self (TClassDecl c),CFSConstructor,TFun(tl,_) -> {cf with cf_type = TFun(tl,TInst(c,List.map snd c.cl_params))}
+            | Self (TClassDecl c),CFSConstructor,TFun(tl,_,_) -> {cf with cf_type = TFun(tl,TInst(c,List.map snd c.cl_params),false)}
             | _ -> cf
         in
 		let ct = CompletionType.from_type (get_import_status ctx) ~values:(get_value_meta cf.cf_meta) cf.cf_type in

+ 1 - 1
src/context/display/displayException.ml

@@ -145,7 +145,7 @@ let fields_to_json ctx fields kind subj =
 
 let arg_index signatures signature_index param_index =
 	try
-		let args,_ = fst (fst (List.nth signatures signature_index)) in
+		let args,_,_ = fst (fst (List.nth signatures signature_index)) in
 		let rec loop args index =
 			match args with
 			| [] -> param_index

+ 6 - 6
src/context/display/displayFields.ml

@@ -52,8 +52,8 @@ let collect_static_extensions ctx items e p =
 		let monos = List.map (fun _ -> spawn_monomorph ctx p) f.cf_params in
 		let map = apply_params f.cf_params monos in
 		match follow (map f.cf_type) with
-		| TFun((_,_,TType({t_path=["haxe";"macro"], "ExprOf"}, [t])) :: args, ret)
-		| TFun((_,_,t) :: args, ret) ->
+		| TFun((_,_,TType({t_path=["haxe";"macro"], "ExprOf"}, [t])) :: args, ret, coro)
+		| TFun((_,_,t) :: args, ret, coro) ->
 			begin try
 				let e = TyperBase.unify_static_extension ctx {e with etype = dup e.etype} t p in
 				List.iter2 (fun m (name,t) -> match follow t with
@@ -65,7 +65,7 @@ let collect_static_extensions ctx items e p =
 					acc
 				else begin
 					let f = prepare_using_field f in
-					let f = { f with cf_params = []; cf_flags = set_flag f.cf_flags (int_of_class_field_flag CfPublic); cf_type = TFun(args,ret) } in
+					let f = { f with cf_params = []; cf_flags = set_flag f.cf_flags (int_of_class_field_flag CfPublic); cf_type = TFun(args,ret,coro) } in
 					let decl = match c.cl_kind with
 						| KAbstractImpl a -> TAbstractDecl a
 						| _ -> TClassDecl c
@@ -108,7 +108,7 @@ let collect_static_extensions ctx items e p =
 		items
 
 let collect ctx e_ast e dk with_type p =
-	let opt_args args ret = TFun(List.map(fun (n,o,t) -> n,true,t) args,ret) in
+	let opt_args args ret = TFun(List.map(fun (n,o,t) -> n,true,t) args,ret,false) in
 	let should_access c cf stat =
 		if Meta.has Meta.NoCompletion cf.cf_meta then false
 		else if c != ctx.curclass && not (has_class_field_flag cf CfPublic) && String.length cf.cf_name > 4 then begin match String.sub cf.cf_name 0 4 with
@@ -286,7 +286,7 @@ let collect ctx e_ast e dk with_type p =
 				end else
 					acc
 			) an.a_fields items
-		| TFun (args,ret) ->
+		| TFun (args,ret,_) ->
 			(* A function has no field except the magic .bind one. *)
 			if is_new_item items "bind" then begin
 				let t = opt_args args ret in
@@ -352,7 +352,7 @@ let handle_missing_field_raise ctx tthis i mode with_type pfield =
 					let e = type_expr ctx e WithType.value in
 					(name,false,e.etype)
 				) el in
-				(TFun(tl,tret),Method MethNormal)
+				(TFun(tl,tret,false),Method MethNormal)
 			with _ ->
 				raise Exit
 			end

+ 2 - 2
src/context/display/displayToplevel.ml

@@ -31,7 +31,7 @@ let maybe_resolve_macro_field ctx t c cf =
 	try
 		if cf.cf_kind <> Method MethMacro then raise Exit;
 		let (tl,tr,c,cf) = ctx.g.do_load_macro ctx false c.cl_path cf.cf_name null_pos in
-		(TFun(tl,tr)),c,cf
+		(TFun(tl,tr,false)),c,cf
 	with _ ->
 		t,c,cf
 
@@ -425,7 +425,7 @@ let collect ctx tk with_type sort =
 			List.iter (fun kwd -> add(make_ci_keyword kwd) (Some (s_keyword kwd))) kwds;
 
 			(* builtins *)
-			add (make_ci_literal "trace" (tpair (TFun(["value",false,t_dynamic],ctx.com.basic.tvoid)))) (Some "trace")
+			add (make_ci_literal "trace" (tpair (TFun(["value",false,t_dynamic],ctx.com.basic.tvoid,false)))) (Some "trace")
 		end
 	end;
 

+ 4 - 4
src/context/typecore.ml

@@ -557,18 +557,18 @@ let check_field_access ctx c f stat p =
 
 (** removes the first argument of the class field's function type and all its overloads *)
 let prepare_using_field cf = match follow cf.cf_type with
-	| TFun((_,_,tf) :: args,ret) ->
+	| TFun((_,_,tf) :: args,ret,coro) ->
 		let rec loop acc overloads = match overloads with
-			| ({cf_type = TFun((_,_,tfo) :: args,ret)} as cfo) :: l ->
+			| ({cf_type = TFun((_,_,tfo) :: args,ret,coro)} as cfo) :: l ->
 				let tfo = apply_params cfo.cf_params (List.map snd cfo.cf_params) tfo in
 				(* ignore overloads which have a different first argument *)
-				if type_iseq tf tfo then loop ({cfo with cf_type = TFun(args,ret)} :: acc) l else loop acc l
+				if type_iseq tf tfo then loop ({cfo with cf_type = TFun(args,ret,coro)} :: acc) l else loop acc l
 			| _ :: l ->
 				loop acc l
 			| [] ->
 				acc
 		in
-		{cf with cf_overloads = loop [] cf.cf_overloads; cf_type = TFun(args,ret)}
+		{cf with cf_overloads = loop [] cf.cf_overloads; cf_type = TFun(args,ret,coro)}
 	| _ -> cf
 
 let merge_core_doc ctx mt =

+ 5 - 2
src/core/display/completionItem.ml

@@ -368,6 +368,7 @@ module CompletionType = struct
 	and ct_function = {
 		ct_args : ct_function_argument list;
 		ct_return : t;
+		ct_coro : bool;
 	}
 
 	and ct_anonymous_field = {
@@ -485,16 +486,18 @@ module CompletionType = struct
 				CTTypedef (ppath td.t_module.m_path td.t_path tl)
 			| TAbstract(a,tl) ->
 				CTAbstract (ppath a.a_module.m_path a.a_path tl)
-			| TFun(tl,t) when not (PMap.is_empty values) ->
+			| TFun(tl,t,coro) when not (PMap.is_empty values) ->
 				let get_arg n = try Some (PMap.find n values) with Not_found -> None in
 				CTFunction {
 					ct_args = List.map (fun (n,o,t) -> funarg (get_arg n) (n,o,t)) tl;
 					ct_return = from_type PMap.empty t;
+					ct_coro = coro;
 				}
-			| TFun(tl,t) ->
+			| TFun(tl,t,coro) ->
 				CTFunction {
 					ct_args = List.map (funarg None) tl;
 					ct_return = from_type PMap.empty t;
+					ct_coro = coro;
 				}
 			| TAnon an ->
 				let afield af = {

+ 2 - 2
src/core/error.ml

@@ -165,9 +165,9 @@ module BetterErrors = struct
 			s_type_path t.t_path ^ s_type_params ctx tl
 		| TAbstract (a,tl) ->
 			s_type_path a.a_path ^ s_type_params ctx tl
-		| TFun ([],_) ->
+		| TFun ([],_,corotodo) ->
 			"() -> ..."
-		| TFun (l,t) ->
+		| TFun (l,t,corotodo) ->
 			let args = match l with
 				| [] -> "()"
 				| ["",b,t] -> ("...")

+ 3 - 2
src/core/json/genjson.ml

@@ -224,7 +224,7 @@ let rec generate_type ctx t =
 		| TType(td,tl) -> "TType",Some (generate_type_path_with_params ctx td.t_module.m_path td.t_path tl td.t_meta)
 		| TAbstract(a,tl) -> "TAbstract",Some (generate_type_path_with_params ctx a.a_module.m_path a.a_path tl a.a_meta)
 		| TAnon an -> "TAnonymous", Some(generate_anon ctx an)
-		| TFun(tl,tr) -> "TFun", Some (jobject (generate_function_signature ctx tl tr))
+		| TFun(tl,tr,coro) -> "TFun", Some (jobject (generate_function_signature ctx tl tr coro))
 	in
 	let name,args = loop t in
 	generate_adt ctx None name args
@@ -257,10 +257,11 @@ and generate_function_argument ctx (name,opt,t) =
 		"t",generate_type ctx t;
 	]
 
-and generate_function_signature ctx tl tr =
+and generate_function_signature ctx tl tr coro =
 	[
 		"args",jlist (generate_function_argument ctx) tl;
 		"ret",generate_type ctx tr;
+		"coro",jbool coro;
 	]
 
 and generate_types ctx tl =

+ 8 - 8
src/core/tFunctions.ml

@@ -103,7 +103,7 @@ let mk_anon ?fields status =
    how we handle this. *)
 let t_dynamic_def = ref t_dynamic
 
-let tfun pl r = TFun (List.map (fun t -> "",false,t) pl,r)
+let tfun pl r = TFun (List.map (fun t -> "",false,t) pl,r,false)
 
 let fun_args l = List.map (fun (a,c,t) -> a, c <> None, t) l
 
@@ -265,8 +265,8 @@ let map loop t =
 		TType (t2,List.map loop tl)
 	| TAbstract (a,tl) ->
 		TAbstract (a,List.map loop tl)
-	| TFun (tl,r) ->
-		TFun (List.map (fun (s,o,t) -> s, o, loop t) tl,loop r)
+	| TFun (tl,r,coro) ->
+		TFun (List.map (fun (s,o,t) -> s, o, loop t) tl,loop r,coro)
 	| TAnon a ->
 		let fields = PMap.map (fun f -> { f with cf_type = loop f.cf_type }) a.a_fields in
 		mk_anon ~fields a.a_status
@@ -293,7 +293,7 @@ let iter loop t =
 		List.iter loop tl
 	| TAbstract (a,tl) ->
 		List.iter loop tl
-	| TFun (tl,r) ->
+	| TFun (tl,r,_) ->
 		List.iter (fun (_,_,t) -> loop t) tl;
 		loop r
 	| TAnon a ->
@@ -416,8 +416,8 @@ let apply_params ?stack cparams params t =
 				| _ -> TInst (c,List.map loop tl))
 			| _ ->
 				TInst (c,List.map loop tl))
-		| TFun (tl,r) ->
-			TFun (List.map (fun (s,o,t) -> s, o, loop t) tl,loop r)
+		| TFun (tl,r,coro) ->
+			TFun (List.map (fun (s,o,t) -> s, o, loop t) tl,loop r,coro)
 		| TAnon a ->
 			let fields = PMap.map (fun f -> { f with cf_type = loop f.cf_type }) a.a_fields in
 			mk_anon ~fields a.a_status
@@ -507,7 +507,7 @@ let rec follow_without_type t =
 
 let rec ambiguate_funs t =
 	match follow t with
-	| TFun _ -> TFun ([], t_dynamic)
+	| TFun(_,_,coro) -> TFun ([], t_dynamic,coro)
 	| _ -> map ambiguate_funs t
 
 let rec is_nullable ?(no_lazy=false) = function
@@ -577,7 +577,7 @@ let rec has_mono t = match t with
 		List.exists has_mono pl
 	| TDynamic _ ->
 		false
-	| TFun(args,r) ->
+	| TFun(args,r,_) ->
 		has_mono r || List.exists (fun (_,_,t) -> has_mono t) args
 	| TAnon a ->
 		PMap.fold (fun cf b -> has_mono cf.cf_type || b) a.a_fields false

+ 1 - 1
src/core/tOther.ml

@@ -34,7 +34,7 @@ module TExprToExpr = struct
 			if (snd t.t_path).[0] = '#' then convert_type (follow tf) else tpath t.t_path t.t_module.m_path (List.map tparam pl)
 		| TAbstract (a,pl) ->
 			tpath a.a_path a.a_module.m_path (List.map tparam pl)
-		| TFun (args,ret) ->
+		| TFun (args,ret,corotodo) ->
 			CTFunction (List.map (fun (_,_,t) -> convert_type' t) args, (convert_type' ret))
 		| TAnon a ->
 			begin match !(a.a_status) with

+ 3 - 3
src/core/tPrinting.ml

@@ -17,7 +17,7 @@ let rec s_type_kind t =
 	| TInst(c,tl) -> Printf.sprintf "TInst(%s, [%s])" (s_type_path c.cl_path) (map tl)
 	| TType(t,tl) -> Printf.sprintf "TType(%s, [%s])" (s_type_path t.t_path) (map tl)
 	| TAbstract(a,tl) -> Printf.sprintf "TAbstract(%s, [%s])" (s_type_path a.a_path) (map tl)
-	| TFun(tl,r) -> Printf.sprintf "TFun([%s], %s)" (String.concat ", " (List.map (fun (n,b,t) -> Printf.sprintf "%s%s:%s" (if b then "?" else "") n (s_type_kind t)) tl)) (s_type_kind r)
+	| TFun(tl,r,coro) -> Printf.sprintf "TFun([%s], %s, %b)" (String.concat ", " (List.map (fun (n,b,t) -> Printf.sprintf "%s%s:%s" (if b then "?" else "") n (s_type_kind t)) tl)) (s_type_kind r) coro
 	| TAnon an -> "TAnon"
 	| TDynamic t2 -> "TDynamic"
 	| TLazy _ -> "TLazy"
@@ -59,9 +59,9 @@ let rec s_type ctx t =
 		s_type_path t.t_path ^ s_type_params ctx tl
 	| TAbstract (a,tl) ->
 		s_type_path a.a_path ^ s_type_params ctx tl
-	| TFun ([],t) ->
+	| TFun ([],t,_) ->
 		"() -> " ^ s_fun ctx t false
-	| TFun (l,t) ->
+	| TFun (l,t,_) ->
 		let args = match l with
 			| [] -> "()"
 			| ["",b,t] -> Printf.sprintf "%s%s" (if b then "?" else "") (s_fun ctx t true)

+ 1 - 1
src/core/tType.ml

@@ -64,7 +64,7 @@ and tlazy =
 	| LProcessing of (unit -> t)
 	| LWait of (unit -> t)
 
-and tsignature = (string * bool * t) list * t
+and tsignature = (string * bool * t) list * t * bool (* true = coroutine *)
 
 and tparams = t list
 

+ 7 - 7
src/core/tUnification.ml

@@ -250,7 +250,7 @@ let rec link e a b =
 		| TMono t -> (match t.tm_type with None -> false | Some t -> loop t)
 		| TEnum (_,tl) -> List.exists loop tl
 		| TInst (_,tl) | TType (_,tl) | TAbstract (_,tl) -> List.exists loop tl
-		| TFun (tl,t) -> List.exists (fun (_,_,t) -> loop t) tl || loop t
+		| TFun (tl,t,_) -> List.exists (fun (_,_,t) -> loop t) tl || loop t
 		| TDynamic t2 ->
 			if t == t2 then
 				false
@@ -284,7 +284,7 @@ let fast_eq_check type_param_check a b =
 	if a == b then
 		true
 	else match a , b with
-	| TFun (l1,r1) , TFun (l2,r2) when List.length l1 = List.length l2 ->
+	| TFun (l1,r1,coro1) , TFun (l2,r2,coro2) when coro1 = coro2 && List.length l1 = List.length l2 ->
 		List.for_all2 (fun (_,_,t1) (_,_,t2) -> type_param_check t1 t2) l1 l2 && type_param_check r1 r2
 	| TType (t1,l1), TType (t2,l2) ->
 		t1 == t2 && List.for_all2 type_param_check l1 l2
@@ -491,7 +491,7 @@ let rec type_eq uctx a b =
 	| TInst (c1,tl1) , TInst (c2,tl2) ->
 		if c1 != c2 && not (param = EqCoreType && c1.cl_path = c2.cl_path) && (match c1.cl_kind, c2.cl_kind with KExpr _, KExpr _ -> false | _ -> true) then error [cannot_unify a b];
 		type_eq_params uctx a b tl1 tl2
-	| TFun (l1,r1) , TFun (l2,r2) when List.length l1 = List.length l2 ->
+	| TFun (l1,r1,coro1) , TFun (l2,r2,coro2) when coro1 = coro2 && List.length l1 = List.length l2 ->
 		let i = ref 0 in
 		(try
 			type_eq uctx r1 r2;
@@ -658,7 +658,7 @@ let rec unify (uctx : unification_context) a b =
 			| _ -> false)
 		in
 		if not (loop c1 tl1) then error [cannot_unify a b]
-	| TFun (l1,r1) , TFun (l2,r2) when List.length l1 = List.length l2 ->
+	| TFun (l1,r1,coro1) , TFun (l2,r2,coro2) when coro1 = coro2 && List.length l1 = List.length l2 ->
 		let uctx = get_nested_context uctx in
 		let i = ref 0 in
 		(try
@@ -946,7 +946,7 @@ and unifies_to_direct uctx a b ab tl t =
 and unifies_from_field uctx a b ab tl (t,cf) =
 	does_func_unify (fun() ->
 		match follow cf.cf_type with
-		| TFun(_,r) ->
+		| TFun(_,r,_) ->
 			let map = apply_params ab.a_params tl in
 			let monos = Monomorph.spawn_constrained_monos map cf.cf_params in
 			let map t = map (apply_params cf.cf_params monos t) in
@@ -959,7 +959,7 @@ and unifies_from_field uctx a b ab tl (t,cf) =
 and unifies_to_field uctx a b ab tl (t,cf) =
 	does_func_unify (fun() ->
 		match follow cf.cf_type with
-		| TFun((_,_,ta) :: _,_) ->
+		| TFun((_,_,ta) :: _,_,_) ->
 			let map = apply_params ab.a_params tl in
 			let monos = Monomorph.spawn_constrained_monos map cf.cf_params in
 			let map t = map (apply_params cf.cf_params monos t) in
@@ -1024,7 +1024,7 @@ and unify_with_variance uctx f t1 t2 =
 		compare_underlying();
 	| TAnon(a1),TAnon(a2) ->
 		unify_anons uctx t1 t2 a1 a2
-	| TFun(al1,r1),TFun(al2,r2) when List.length al1 = List.length al2 ->
+	| TFun(al1,r1,coro1),TFun(al2,r2,coro2) when coro1 = coro2 && List.length al1 = List.length al2 ->
 		List.iter2 (fun (_,_,t1) (_,_,t2) -> unify_nested t1 t2) al1 al2;
 		unify_nested r1 r2;
 	| _ ->

+ 1 - 1
src/filters/ES6Ctors.ml

@@ -61,7 +61,7 @@ let has_this_before_super e =
 
 let get_num_args cf =
 	match follow cf.cf_type with
-	| TFun (args, _) -> List.length args
+	| TFun (args, _, _) -> List.length args
 	| _ -> die "" __LOC__
 
 (*

+ 1 - 1
src/filters/capturedVars.ml

@@ -177,7 +177,7 @@ let captured_vars com e =
 						tf_args = List.map (fun (_,v) -> v, None) new_vars;
 						tf_type = e.etype;
 						tf_expr = mk_block (mk (TReturn (Some e)) e.etype e.epos);
-					}) (TFun (List.map (fun (_,v) -> v.v_name,false,v.v_type) new_vars,e.etype)) e.epos),
+					}) (TFun (List.map (fun (_,v) -> v.v_name,false,v.v_type) new_vars,e.etype,false)) e.epos),
 					List.map (fun v -> mk (TLocal v) v.v_type e.epos) vars)
 				) e.etype e.epos
 			else

+ 3 - 3
src/filters/defaultArguments.ml

@@ -63,7 +63,7 @@ let rec change_func com cl cf =
 	match cf.cf_kind, follow cf.cf_type with
 	| Var _, _ | Method MethDynamic, _ ->
 		()
-	| _, TFun(args, ret) ->
+	| _, TFun(args, ret, coro) ->
 		let is_ctor = cf.cf_name = "new" in
 		let basic = com.basic in
 
@@ -134,7 +134,7 @@ let rec change_func com cl cf =
 
 			args := List.map (fun (v,s) -> (v.v_name, (s <> None), v.v_type)) tf_args;
 
-			let cf_type = TFun (!args, ret) in
+			let cf_type = TFun (!args, ret, coro) in
 			cf.cf_expr <- Some { texpr with
 				eexpr = TFunction { tf with
 					tf_args = tf_args;
@@ -145,7 +145,7 @@ let rec change_func com cl cf =
 			cf.cf_type <- cf_type
 
 		| _ -> ());
-		(if !found then cf.cf_type <- TFun(!args, ret))
+		(if !found then cf.cf_type <- TFun(!args, ret, coro))
 	| _, _ -> Globals.die "" __LOC__
 
 let run com md =

+ 5 - 5
src/filters/exceptions.ml

@@ -35,7 +35,7 @@ let haxe_exception_static_call ctx method_name args p =
 	in
 	let return_type =
 		match follow method_field.cf_type with
-		| TFun(_,t) -> t
+		| TFun(_,t,_) -> t
 		| _ -> error ("haxe.Exception." ^ method_name ^ " is not a function and cannot be called") p
 	in
 	add_dependency ctx.typer.curclass.cl_module ctx.haxe_exception_class.cl_module;
@@ -50,7 +50,7 @@ let haxe_exception_instance_call ctx haxe_exception method_name args p =
 		let efield = { eexpr = TField(haxe_exception,faccess); etype = cf.cf_type; epos = p } in
 		let rt =
 			match follow cf.cf_type with
-			| TFun(_,t) -> t
+			| TFun(_,t,_) -> t
 			| _ ->
 				error ((s_type (print_context()) haxe_exception.etype) ^ "." ^ method_name ^ " is not a function and cannot be called") p
 		in
@@ -73,7 +73,7 @@ let std_is ctx e t p =
 	in
 	let return_type =
 		match follow isOfType_field.cf_type with
-		| TFun(_,t) -> t
+		| TFun(_,t,_) -> t
 		| _ -> error ("Std.isOfType is not a function and cannot be called") p
 	in
 	let type_expr = { eexpr = TTypeExpr(module_type_of_type t); etype = t; epos = null_pos } in
@@ -478,7 +478,7 @@ let insert_save_stacks tctx =
 				in
 				let return_type =
 					match follow method_field.cf_type with
-					| TFun(_,t) -> t
+					| TFun(_,t,_) -> t
 					| _ -> error ("haxe.NativeStackTrace." ^ method_field.cf_name ^ " is not a function and cannot be called") null_pos
 				in
 				let catch_local = mk (TLocal catch_var) catch_var.v_type null_pos in
@@ -540,7 +540,7 @@ let patch_constructors tctx =
 						let efield = { eexpr = TField(this,faccess); etype = cf.cf_type; epos = p } in
 						let rt =
 							match follow cf.cf_type with
-							| TFun(_,t) -> t
+							| TFun(_,t,_) -> t
 							| _ ->
 								error "haxe.Exception.__shiftStack is not a function and cannot be called" cf.cf_name_pos
 						in

+ 1 - 1
src/filters/filters.ml

@@ -489,7 +489,7 @@ let add_field_inits locals ctx t =
 			let el = if !need_this then (mk (TVar((v, Some ethis))) ethis.etype ethis.epos) :: el else el in
 			let cf = match c.cl_constructor with
 			| None ->
-				let ct = TFun([],ctx.com.basic.tvoid) in
+				let ct = TFun([],ctx.com.basic.tvoid,false) in
 				let ce = mk (TFunction {
 					tf_args = [];
 					tf_type = ctx.com.basic.tvoid;

+ 37 - 37
src/generators/gencpp.ml

@@ -806,7 +806,7 @@ and type_string_suff suffix haxe_type remap =
          "::cpp::Function< " ^ (cpp_function_signature_params params ) ^ " >"
       | _ ->  type_string_suff suffix (apply_params type_def.t_params params type_def.t_type) remap
       )
-   | TFun (args,haxe_type) -> "Dynamic" ^ suffix
+   | TFun (args,haxe_type,_) -> "Dynamic" ^ suffix
    | TAnon a -> "Dynamic"
       (*
       (match !(a.a_status) with
@@ -849,7 +849,7 @@ and is_dynamic_array_param haxe_type =
    )
 and cpp_function_signature tfun abi =
    match follow tfun with
-   | TFun(args,ret) -> (type_string ret) ^ " " ^ abi ^ "(" ^ (gen_tfun_interface_arg_list args) ^ ")"
+   | TFun(args,ret,_) -> (type_string ret) ^ " " ^ abi ^ "(" ^ (gen_tfun_interface_arg_list args) ^ ")"
    | _ -> "void *"
 
 and cpp_function_signature_params params = match params with
@@ -1157,7 +1157,7 @@ let is_super expression =
 
 
 let rec is_dynamic_in_cpp ctx expr =
-   let expr_type = type_string ( match follow expr.etype with TFun (args,ret) -> ret | _ -> expr.etype) in
+   let expr_type = type_string ( match follow expr.etype with TFun (args,ret,_) -> ret | _ -> expr.etype) in
    if ( expr_type="Dynamic" || expr_type="cpp::ArrayBase") then
       true
    else begin
@@ -1187,7 +1187,7 @@ let rec is_dynamic_in_cpp ctx expr =
             true
          else
             (match follow func.etype with
-            | TFun (args,ret) -> is_dynamic_in_cpp ctx func
+            | TFun (args,ret,_) -> is_dynamic_in_cpp ctx func
             | _ -> true
          );
       | TParenthesis(expr) | TMeta(_,expr) -> is_dynamic_in_cpp ctx expr
@@ -1265,7 +1265,7 @@ let is_matching_interface_type t0 t1 =
 
 let get_nth_type field index =
    match follow field.ef_type with
-      | TFun (args,_) ->
+      | TFun (args,_,_) ->
          let rec nth l index = match l with
          | [] -> raise Not_found
          | (_,_,t)::rest ->
@@ -1909,7 +1909,7 @@ let rec cpp_type_of stack ctx haxe_type =
 
    and cpp_function_type_of_args_ret stack ctx function_type =
       match follow function_type with
-      | TFun(args,ret) ->
+      | TFun(args,ret,_) ->
           (* Optional types are Dynamic if they norally could not be null *)
           let  cpp_arg_type_of = fun(_,optional,haxe_type) ->
              if optional then
@@ -1950,7 +1950,7 @@ and cpp_instance_type ctx = cpp_instance_type [] ctx
 
 let cpp_return_type ctx haxe_type =
   match haxe_type with
-  | TFun (_,ret) -> cpp_type_of ctx ret
+  | TFun (_,ret,_) -> cpp_type_of ctx ret
   | _ -> TCppDynamic
 ;;
 
@@ -2179,7 +2179,7 @@ let cpp_macro_var_type_of ctx var =
 
 let ctx_function_signature ctx include_names tfun abi =
    match follow tfun with
-   | TFun(args,ret) -> (ctx_type_string ctx ret) ^ " " ^ abi ^ "(" ^ (ctx_tfun_arg_list ctx include_names args) ^ ")"
+   | TFun(args,ret,_) -> (ctx_type_string ctx ret) ^ " " ^ abi ^ "(" ^ (ctx_tfun_arg_list ctx include_names args) ^ ")"
    | _ -> "void *"
 
 
@@ -2780,9 +2780,9 @@ let retype_expression ctx request_type function_args function_type expression_tr
                   *)
 
                (* Other functions ... *)
-               | CppFunction( FuncInstance(_,_,{cf_type=TFun(arg_types,_)} ) as func, returnType )
-               | CppFunction( FuncStatic(_,_,{cf_type=TFun(arg_types,_)} ) as func, returnType )
-               | CppFunction( FuncThis({cf_type=TFun(arg_types,_)},_ ) as func, returnType ) ->
+               | CppFunction( FuncInstance(_,_,{cf_type=TFun(arg_types,_,_)} ) as func, returnType )
+               | CppFunction( FuncStatic(_,_,{cf_type=TFun(arg_types,_,_)} ) as func, returnType )
+               | CppFunction( FuncThis({cf_type=TFun(arg_types,_,_)},_ ) as func, returnType ) ->
                   let arg_types = List.map (fun (_,opt,t) -> cpp_tfun_arg_type_of ctx opt t) arg_types in
                   (* retype args specifically (not just CppDynamic) *)
                   let retypedArgs = retype_function_args args arg_types in
@@ -4346,7 +4346,7 @@ let is_override field =
 let current_virtual_functions_rev clazz base_functions =
    List.fold_left (fun result elem -> match follow elem.cf_type, elem.cf_kind  with
       | _, Method MethDynamic -> result
-      | TFun (args,return_type), Method _  ->
+      | TFun (args,return_type,_), Method _  ->
           if (is_override elem ) then
              List.map (fun (e,a,r) ->  if e.cf_name<>elem.cf_name then (e,a,r) else  (elem,args,return_type) ) result
           else
@@ -4395,7 +4395,7 @@ let all_virtual_functions clazz override_types =
 let rec unreflective_type t =
     match follow t with
        | TInst (klass,_) ->  Meta.has Meta.Unreflective klass.cl_meta
-       | TFun (args,ret) ->
+       | TFun (args,ret,_) ->
            List.fold_left (fun result (_,_,t) -> result || (unreflective_type t)) (unreflective_type ret) args;
        | _ -> false
 ;;
@@ -4415,7 +4415,7 @@ let reflective class_def field = not (
 let field_arg_count field =
    match follow field.cf_type, field.cf_kind  with
       | _, Method MethDynamic -> -1
-      | TFun (args,return_type), Method _  -> List.length args
+      | TFun (args,return_type,_), Method _  -> List.length args
       | _,_ -> -1
 ;;
 
@@ -4570,7 +4570,7 @@ let gen_field ctx class_def class_name ptr_name dot_name is_static is_interface
          output ( " " ^ class_name ^ "::" ^ remap_name ^ ";\n\n");
       end else if has_class_field_flag field CfAbstract then begin
          let tl,tr = match follow field.cf_type with
-            | TFun(tl,tr) -> tl,tr
+            | TFun(tl,tr,_) -> tl,tr
             | _ -> die "" __LOC__
          in
          let nargs = string_of_int (List.length tl) in
@@ -4635,7 +4635,7 @@ let gen_member_def ctx class_def is_static is_interface field =
    if (is_interface) then begin
       match follow field.cf_type, field.cf_kind with
       | _, Method MethDynamic  -> ()
-      | TFun (args,return_type), Method _  ->
+      | TFun (args,return_type,_), Method _  ->
          let gen_args = ctx_tfun_arg_list ctx true in
          if is_static || nativeGen then begin
             output ( (if (not is_static) then "		virtual " else "		" ) ^ (ctx_type_string ctx return_type) );
@@ -4704,7 +4704,7 @@ let gen_member_def ctx class_def is_static is_interface field =
             String.concat "," (List.map (fun (n,o,t) -> (ctx_arg ctx n None t prefix) ) arg_list)
          in
          let tl,tr = match follow field.cf_type with
-            | TFun(tl,tr) -> tl,tr
+            | TFun(tl,tr,_) -> tl,tr
             | _ -> die "" __LOC__
          in
          let return_type = (ctx_type_string ctx tr) in
@@ -4735,7 +4735,7 @@ let gen_member_def ctx class_def is_static is_interface field =
          (* Add a "dyn" function for variable to unify variable/function access *)
          (match follow field.cf_type with
          | _ when nativeGen  -> ()
-         | TFun (_,_) ->
+         | TFun (_,_,_) ->
             output (if is_static then "\t\tstatic " else "\t\t");
             output ("Dynamic " ^ remap_name ^ "_dyn() { return " ^ remap_name ^ ";}\n" )
          | _ ->  (match field.cf_kind with
@@ -4828,7 +4828,7 @@ let find_referenced_types_flags ctx obj field_name super_deps constructor_deps h
             )
          | TAbstract (a,params) when is_scalar_abstract a ->
             add_extern_type (TAbstractDecl a)
-         | TFun (args,haxe_type) -> visit_type haxe_type;
+         | TFun (args,haxe_type,_) -> visit_type haxe_type;
             List.iter (fun (_,_,t) -> visit_type t; ) args;
          | _ -> ()
          end;
@@ -4919,7 +4919,7 @@ let find_referenced_types_flags ctx obj field_name super_deps constructor_deps h
       add_type enum_def.e_path;
       PMap.iter (fun _ constructor ->
          (match constructor.ef_type with
-         | TFun (args,_) ->
+         | TFun (args,_,_) ->
             List.iter (fun (_,_,t) -> visit_type t; ) args;
          | _ -> () );
          ) enum_def.e_constrs;
@@ -5175,7 +5175,7 @@ let generate_enum_files baseCtx enum_def super_deps meta =
    PMap.iter (fun _ constructor ->
       let name = keyword_remap constructor.ef_name in
       match constructor.ef_type with
-      | TFun (args,_) ->
+      | TFun (args,_,_) ->
          output_cpp (remap_class_name ^ " " ^ class_name ^ "::" ^ name ^ "(" ^
             (ctx_tfun_arg_list ctx true args) ^")\n");
 
@@ -5189,7 +5189,7 @@ let generate_enum_files baseCtx enum_def super_deps meta =
 
 
    let constructor_arg_count constructor =
-      (match constructor.ef_type with | TFun(args,_) -> List.length args | _ -> 0 )
+      (match constructor.ef_type with | TFun(args,_,_) -> List.length args | _ -> 0 )
    in
 
    output_cpp ("bool " ^ class_name ^ "::__GetStatic(const ::String &inName, ::Dynamic &outValue, ::hx::PropertyAccess inCallProp)\n{\n");
@@ -5279,7 +5279,7 @@ let generate_enum_files baseCtx enum_def super_deps meta =
    PMap.iter (fun _ constructor ->
       let name = constructor.ef_name in
       match constructor.ef_type with
-      | TFun (_,_) -> ()
+      | TFun (_,_,_) -> ()
       | _ ->
          output_cpp ( (keyword_remap name) ^ " = ::hx::CreateConstEnum< " ^ class_name ^ " >(" ^ (strq name) ^  "," ^
             (string_of_int constructor.ef_index) ^ ");\n" )
@@ -5326,7 +5326,7 @@ let generate_enum_files baseCtx enum_def super_deps meta =
       let name = keyword_remap constructor.ef_name in
       output_h ( "\t\tstatic " ^  remap_class_name ^ " " ^ name );
       match constructor.ef_type with
-      | TFun (args,_) ->
+      | TFun (args,_,_) ->
          output_h ( "(" ^ (ctx_tfun_arg_list ctx true args) ^");\n");
          output_h ( "\t\tstatic ::Dynamic " ^ name ^ "_dyn();\n");
       | _ ->
@@ -5483,7 +5483,7 @@ let find_class_implementation ctx class_def name interface =
    with FieldFound field ->
       match follow field.cf_type, field.cf_kind  with
       | _, Method MethDynamic -> ""
-      | TFun (args,return_type), Method _ ->
+      | TFun (args,return_type,_), Method _ ->
          cpp_tfun_signature ctx false args return_type
       | _,_ -> ""
 ;;
@@ -5558,7 +5558,7 @@ let constructor_arg_var_list class_def ctx =
                         function_def.tf_args;
                | _ ->
                   (match follow definition.cf_type with
-                     | TFun (args,_) -> List.map (fun (a,_,t) -> (a, (ctx_type_string ctx t, a)) )  args
+                     | TFun (args,_,_) -> List.map (fun (a,_,t) -> (a, (ctx_type_string ctx t, a)) )  args
                      | _ -> [])
             )
    | _ -> []
@@ -5623,7 +5623,7 @@ let generate_protocol_delegate ctx class_def output =
 
    let dump_delegate field =
       match field.cf_type with
-      |  TFun(args,ret) ->
+      |  TFun(args,ret,_) ->
          let retStr = ctx_type_string ctx ret in
          let nativeName = get_meta_string field.cf_meta Meta.ObjcProtocol in
          let fieldName,argNames = if nativeName<>"" then begin
@@ -5954,7 +5954,7 @@ let generate_class_files baseCtx super_deps constructor_deps class_def inScripta
                    let rec gen_interface_funcs interface =
                       let gen_field field = (match follow field.cf_type, field.cf_kind  with
                       | _, Method MethDynamic -> ()
-                      | TFun (args,return_type), Method _ ->
+                      | TFun (args,return_type,_), Method _ ->
                          let cast = cpp_tfun_signature ctx false args return_type in
                          let class_implementation = find_class_implementation ctx class_def field.cf_name interface in
                          let realName= cpp_member_name_of field in
@@ -6331,7 +6331,7 @@ let generate_class_files baseCtx super_deps constructor_deps class_def inScripta
 
    let generate_script_function isStatic field scriptName callName =
       match follow field.cf_type  with
-      | TFun (args,return_type) when not (is_data_member field) ->
+      | TFun (args,return_type,_) when not (is_data_member field) ->
          let isTemplated = not isStatic && not (has_class_flag class_def CInterface) in
          if isTemplated then output_cpp ("\ntemplate<bool _HX_SUPER=false>");
          output_cpp ("\nstatic void CPPIA_CALL " ^ scriptName ^ "(::hx::CppiaCtx *ctx) {\n");
@@ -6745,7 +6745,7 @@ let generate_class_files baseCtx super_deps constructor_deps class_def inScripta
          List.iter (fun field ->
             match follow field.cf_type, field.cf_kind with
             | _, Method MethDynamic  -> ()
-            | TFun (args,return_type), _  ->
+            | TFun (args,return_type,_), _  ->
                 let retVal = ctx_type_string ctx return_type in
                 let ret = if retVal="void" then "" else "return " in
                 let name = keyword_remap field.cf_name in
@@ -7734,7 +7734,7 @@ class script_writer ctx filename asciiOut =
                   this#gen_expression func;
          );
          let matched_args = match func.etype with
-            | TFun (args,_) ->
+            | TFun (args,_,_) ->
                ( try (
                   List.iter2 (fun (_,_,protoT) arg -> this#checkCast protoT arg false false)  args arg_list;
                   true; )
@@ -7818,7 +7818,7 @@ class script_writer ctx filename asciiOut =
       this#write ((this#op IaNew) ^ (this#typeText (TInst(clazz,params))) ^ (string_of_int (List.length arg_list)) ^ "\n");
       (try
          match OverloadResolution.maybe_resolve_constructor_overload clazz params arg_list with
-         | Some (_,{ cf_type = TFun(args,_) },_) ->
+         | Some (_,{ cf_type = TFun(args,_,_) },_) ->
             List.iter2 (fun (_,_,protoT) arg -> this#checkCast protoT arg false false) args arg_list;
          | _ ->
             raise (Invalid_argument "")
@@ -7856,7 +7856,7 @@ class script_writer ctx filename asciiOut =
          this#gen_expression loop;
    | TEnumParameter (expr,ef,i) ->
          let enum = match follow ef.ef_type with
-            | TEnum(en,_) | TFun(_,TEnum(en,_)) -> en
+            | TEnum(en,_) | TFun(_,TEnum(en,_),_) -> en
             | _ -> die "" __LOC__
          in
          this#write ( (this#op IaEnumI) ^ (this#typeText (TEnum(enum,[])) ) ^ (string_of_int i) ^ "\n");
@@ -8307,11 +8307,11 @@ let generate_script_class common_ctx script class_def =
          in
          let isExtern = not (is_physical_field field) in
          script#var (mode_code v.v_read) (mode_code v.v_write) isExtern isStatic field.cf_name field.cf_type field.cf_expr
-      | Method MethDynamic, TFun(args,ret) ->
+      | Method MethDynamic, TFun(args,ret,_) ->
          script#func isStatic true field.cf_name ret args (has_class_flag class_def CInterface) field.cf_expr field.cf_pos
-      | Method _, TFun(args,ret) when field.cf_name="new" ->
+      | Method _, TFun(args,ret,_) when field.cf_name="new" ->
          script#func true false "new" (TInst(class_def,[])) args false field.cf_expr field.cf_pos
-      | Method _, TFun (args,ret) ->
+      | Method _, TFun (args,ret,_) ->
          script#func isStatic false field.cf_name ret args (has_class_flag class_def CInterface) field.cf_expr field.cf_pos
       | Method _, _ -> print_endline ("Unknown method type " ^ (join_class_path class_def.cl_path "." )
                      ^ "." ^field.cf_name )
@@ -8336,7 +8336,7 @@ let generate_script_enum common_ctx script enum_def meta =
    List.iter (fun constructor ->
       let name = script#stringText constructor.ef_name in
       match constructor.ef_type with
-      | TFun (args,_) ->
+      | TFun (args,_,_) ->
          script#write ( name ^ " " ^ (string_of_int (List.length args)) );
          List.iter (fun (arg,_,t) -> script#write ( " " ^ (script#stringText arg) ^ " " ^ (script#typeText t) ) ) args;
          script#write "\n";

+ 16 - 16
src/generators/gencs.ml

@@ -157,7 +157,7 @@ let get_overloads_for_optional_args gen cl cf is_static =
 	match cf.cf_params,cf.cf_kind with
 	| [],Method (MethNormal | MethDynamic | MethInline) ->
 		(match cf.cf_expr, follow cf.cf_type with
-		| Some ({ eexpr = TFunction fn } as method_expr), TFun (args, return_type) ->
+		| Some ({ eexpr = TFunction fn } as method_expr), TFun (args, return_type, _) ->
 			let type_params = List.map snd cl.cl_params in
 			let rec collect_overloads tf_args_rev args_rev default_values_rev =
 				match tf_args_rev, args_rev with
@@ -194,7 +194,7 @@ let get_overloads_for_optional_args gen cl cf is_static =
 					in
 					{ cf with
 						cf_overloads = [];
-						cf_type = TFun (List.rev rest_args_rev, return_type);
+						cf_type = TFun (List.rev rest_args_rev, return_type, false);
 						cf_expr = Some { method_expr with eexpr = TFunction fn };
 					} :: collect_overloads rest_tf_args_rev rest_args_rev default_values_rev
 				| _ -> []
@@ -541,7 +541,7 @@ struct
 					mk_ret { e with
 						eexpr = TCall({
 							eexpr = TField(run e1, FDynamic "Equals");
-							etype = TFun(["obj1",false,t_dynamic;], basic.tbool);
+							etype = TFun(["obj1",false,t_dynamic;], basic.tbool, false);
 							epos = e1.epos
 						}, [ run e2 ])
 					}
@@ -731,10 +731,10 @@ let generate con =
 		let type_cl = get_cl ( get_type gen (["System"], "Type")) in
 		let basic_fns =
 		[
-			mk_class_field "Equals" (TFun(["obj",false,t_dynamic], basic.tbool)) true null_pos (Method MethNormal) [];
-			mk_class_field "ToString" (TFun([], basic.tstring)) true null_pos (Method MethNormal) [];
-			mk_class_field "GetHashCode" (TFun([], basic.tint)) true null_pos (Method MethNormal) [];
-			mk_class_field "GetType" (TFun([], TInst(type_cl, []))) true null_pos (Method MethNormal) [];
+			mk_class_field "Equals" (TFun(["obj",false,t_dynamic], basic.tbool, false)) true null_pos (Method MethNormal) [];
+			mk_class_field "ToString" (TFun([], basic.tstring, false)) true null_pos (Method MethNormal) [];
+			mk_class_field "GetHashCode" (TFun([], basic.tint, false)) true null_pos (Method MethNormal) [];
+			mk_class_field "GetType" (TFun([], TInst(type_cl, []), false)) true null_pos (Method MethNormal) [];
 		] in
 		List.iter (fun cf -> gen.gbase_class_fields <- PMap.add cf.cf_name cf gen.gbase_class_fields) basic_fns;
 
@@ -1875,7 +1875,7 @@ let generate con =
 				in
 				write w "(";
 				let ft = match follow e.etype with
-					| TFun(args,_) -> args
+					| TFun(args,_,_) -> args
 					| _ -> []
 				in
 
@@ -2045,7 +2045,7 @@ let generate con =
 														| "haxe", "Constructible" ->
 															(match params with
 																(* Only for parameterless constructors *)
-																| [TFun ([],TAbstract({a_path=[],"Void"},_))] ->
+																| [TFun ([],TAbstract({a_path=[],"Void"},_),_)] ->
 																	if (List.memq CsStruct acc) then combination_error CsConstructible CsStruct;
 																	if (List.memq CsUnmanaged acc) then combination_error CsUnmanaged CsConstructible;
 																	CsConstructible :: acc;
@@ -2309,11 +2309,11 @@ let generate con =
 					let is_virtual = if not is_virtual || (has_class_field_flag cf CfFinal) then false else is_virtual in
 					let is_override = has_class_field_flag cf CfOverride in
 					let is_override = is_override || match cf.cf_name, follow cf.cf_type with
-						| "Equals", TFun([_,_,targ], tret) ->
+						| "Equals", TFun([_,_,targ], tret, _) ->
 							(match follow targ, follow tret with
 								| TDynamic _, TAbstract({ a_path = ([], "Bool") }, []) -> true
 								| _ -> false)
-						| "GetHashCode", TFun([],_) -> true
+						| "GetHashCode", TFun([],_,_) -> true
 						| _ -> false
 					in
 					let is_override = if Meta.has (Meta.Custom "?prop_impl") cf.cf_meta then false else is_override in
@@ -2328,7 +2328,7 @@ let generate con =
 					let visibility, is_virtual = if is_explicit_iface then "",false else if visibility = "private" then "private",false else visibility, is_virtual in
 					let v_n = if is_static then "static" else if is_override && not is_interface then "override" else if is_virtual then "virtual" else "" in
 					let cf_type = if is_override && not is_overload && not (has_class_field_flag cf CfOverload) then match field_access gen (TInst(cl, List.map snd cl.cl_params)) cf.cf_name with | FClassField(_,_,_,_,_,actual_t,_) -> actual_t | _ -> die "" __LOC__ else cf.cf_type in
-					let ret_type, args = match follow cf_type with | TFun (strbtl, t) -> (t, strbtl) | _ -> die "" __LOC__ in
+					let ret_type, args = match follow cf_type with | TFun (strbtl, t, _) -> (t, strbtl) | _ -> die "" __LOC__ in
 					gen_nocompletion w cf.cf_meta;
 
 					(* public static void funcName *)
@@ -2475,7 +2475,7 @@ let generate con =
 			(if not (PMap.is_empty !pairs) then try
 				let get = PMap.find "__get" cl.cl_fields in
 				let idx_t, v_t = match follow get.cf_type with
-					| TFun([_,_,arg_t],ret_t) ->
+					| TFun([_,_,arg_t],ret_t,_) ->
 						t_s (run_follow gen arg_t), t_s (run_follow gen ret_t)
 					| _ -> gen.gcon.error "The __get function must be a function with one argument. " get.cf_pos; die "" __LOC__
 				in
@@ -2517,7 +2517,7 @@ let generate con =
 				let cf = PMap.find "toString" cl.cl_fields in
 				(if has_class_field_flag cf CfOverride then raise Not_found);
 				(match cf.cf_type with
-					| TFun([], ret) ->
+					| TFun([], ret, _) ->
 						(match real_type ret with
 							| TInst( { cl_path = ([], "String") }, []) ->
 								write w "public override string ToString()";
@@ -2537,7 +2537,7 @@ let generate con =
 				let cf = PMap.find "finalize" cl.cl_fields in
 				(if has_class_field_flag cf CfOverride then raise Not_found);
 				(match cf.cf_type with
-					| TFun([], ret) ->
+					| TFun([], ret, _) ->
 						(match real_type ret with
 							| TAbstract( { a_path = ([], "Void") }, []) ->
 								write w "~";
@@ -3014,7 +3014,7 @@ let generate con =
 			(fun e ->
 				{
 					eexpr = TCall(
-						{ (mk_field_access gen { (mk_paren e) with etype = real_type e.etype } "toDynamic" e.epos) with etype = TFun([], t_dynamic) },
+						{ (mk_field_access gen { (mk_paren e) with etype = real_type e.etype } "toDynamic" e.epos) with etype = TFun([], t_dynamic, false) },
 						[]);
 					etype = t_dynamic;
 					epos = e.epos

+ 9 - 9
src/generators/genhl.ml

@@ -138,7 +138,7 @@ type access =
 
 let is_to_string t =
 	match follow t with
-	| TFun([],r) -> (match follow r with TInst({ cl_path=[],"String" },[]) -> true | _ -> false)
+	| TFun([],r,_) -> (match follow r with TInst({ cl_path=[],"String" },[]) -> true | _ -> false)
 	| _ -> false
 
 let is_string = function
@@ -293,7 +293,7 @@ let array_class ctx t =
 
 let member_fun c t =
 	match follow t with
-	| TFun (args, ret) -> TFun (("this",false,TInst(c,[])) :: args, ret)
+	| TFun (args, ret, coro) -> TFun (("this",false,TInst(c,[])) :: args, ret, coro)
 	| _ -> die "" __LOC__
 
 let rec unsigned t =
@@ -387,7 +387,7 @@ let rec to_type ?tref ctx t =
 		| _ -> t)
 	| TLazy f ->
 		to_type ?tref ctx (lazy_type f)
-	| TFun (args, ret) ->
+	| TFun (args, ret, _) ->
 		HFun (List.map (fun (_,o,t) ->
 			let pt = to_type ctx t in
 			if o && not (is_nullable pt) then HRef pt else pt
@@ -515,7 +515,7 @@ and real_type ctx e =
 		| TField (_,f) ->
 			let ft = field_type ctx f e.epos in
 			(match ft, e.etype with
-			| TFun (args,ret), TFun (args2,_) ->
+			| TFun (args,ret,coro1), TFun (args2,_,coro2) ->
 				TFun (List.map2 (fun ((name,opt,t) as a) ((_,_,t2) as a2) ->
 					match t, t2 with
 					(*
@@ -532,7 +532,7 @@ and real_type ctx e =
 						(name, opt, TAbstract (fake_tnull,[t]))
 					| _ ->
 						a
-				) args args2, ret)
+				) args args2, ret, coro1)
 			| _ -> ft)
 		| TLocal v -> v.v_type
 		| TParenthesis e -> loop e
@@ -707,7 +707,7 @@ and enum_type ?(tref=None) ctx e =
 		et.efields <- Array.of_list (List.map (fun f ->
 			let f = PMap.find f e.e_constrs in
 			let args = (match f.ef_type with
-				| TFun (args,_) -> Array.of_list (List.map (fun (_,_,t) -> to_type ctx t) args)
+				| TFun (args,_,_) -> Array.of_list (List.map (fun (_,_,t) -> to_type ctx t) args)
 				| _ -> [||]
 			) in
 			(f.ef_name, alloc_string ctx f.ef_name, args)
@@ -2133,7 +2133,7 @@ and eval_expr ctx e =
 			let rt = to_type ctx e.etype in
 			let is_valid_method t =
 				match follow t with
-				| TFun (_,rt) ->
+				| TFun (_,rt,_) ->
 					(match follow rt with
 					| TInst({ cl_kind = KTypeParameter tl },_) ->
 						(* don't allow if we have a constraint virtual, see hxbit.Serializer.getRef *)
@@ -2189,7 +2189,7 @@ and eval_expr ctx e =
 			let fid = alloc_fun_path ctx en.e_path name in
 			if fid = cur_fid then begin
 				let ef = PMap.find name en.e_constrs in
-				let eargs, et = (match follow ef.ef_type with TFun (args,ret) -> args, ret | _ -> die "" __LOC__) in
+				let eargs, et = (match follow ef.ef_type with TFun (args,ret,_) -> args, ret | _ -> die "" __LOC__) in
 				let ct = ctx.com.basic in
 				let p = ef.ef_pos in
 				let eargs = List.map (fun (n,o,t) -> Type.alloc_var VGenerated n t en.e_pos, if o then Some (mk (TConst TNull) t_dynamic null_pos) else None) eargs in
@@ -3365,7 +3365,7 @@ let rec generate_member ctx c f =
 			| Some { eexpr = TFunction f } -> f
 			| None when has_class_field_flag f CfAbstract ->
 				let tl,tr = match follow f.cf_type with
-					| TFun(tl,tr) -> tl,tr
+					| TFun(tl,tr,_) -> tl,tr
 					| _ -> die "" __LOC__
 				in
 				let args = List.map (fun (n,_,t) ->

+ 4 - 4
src/generators/genhxold.ml

@@ -106,9 +106,9 @@ let generate_type com t =
 			stype (lazy_type f)
 		| TDynamic t2 ->
 			if t == t2 then "Dynamic" else "Dynamic<" ^ stype t2 ^ ">"
-		| TFun ([],ret) ->
+		| TFun ([],ret,_) ->
 			"() -> " ^ ftype ret
-		| TFun (args,ret) ->
+		| TFun (args,ret,_) ->
 			String.concat " -> " (List.map (fun (_,_,t) -> ftype t) args) ^ " -> " ^ ftype ret
 	and ftype t =
 		match t with
@@ -174,7 +174,7 @@ let generate_type com t =
 			p " : %s" (stype f.cf_type);
 		| Method m ->
 			let params, ret = (match follow f.cf_type with
-				| TFun (args,ret) ->
+				| TFun (args,ret,_) ->
 					List.map (fun (a,o,t) ->
 						let rec loop = function
 							| [] -> Ident "null"
@@ -254,7 +254,7 @@ let generate_type com t =
 			let c = PMap.find n e.e_constrs in
 			p "\t%s" c.ef_name;
 			(match follow c.ef_type with
-			| TFun (args,_) -> p "(%s)" (String.concat ", " (List.map sparam (List.map (fun (a,o,t) -> a,(if o then Some (Ident "null") else None),t) args)))
+			| TFun (args,_,_) -> p "(%s)" (String.concat ", " (List.map sparam (List.map (fun (a,o,t) -> a,(if o then Some (Ident "null") else None),t) args)))
 			| _ -> ());
 			p ";\n";
 		) e.e_names;

+ 17 - 17
src/generators/genjava.ml

@@ -109,7 +109,7 @@ let rec t_has_type_param t = match follow t with
 	| TEnum(_, params)
 	| TAbstract(_, params)
 	| TInst(_, params) -> List.exists t_has_type_param params
-	| TFun(f,ret) -> t_has_type_param ret || List.exists (fun (_,_,t) -> t_has_type_param t) f
+	| TFun(f,ret,_) -> t_has_type_param ret || List.exists (fun (_,_,t) -> t_has_type_param t) f
 	| _ -> false
 
 let is_dynamic gen t =
@@ -124,7 +124,7 @@ let rec t_has_type_param_shallow last t = match follow t with
 	| TEnum(_, params)
 	| TAbstract(_, params)
 	| TInst(_, params) when not last -> List.exists (t_has_type_param_shallow true) params
-	| TFun(f,ret) when not last -> t_has_type_param_shallow true ret	|| List.exists (fun (_,_,t) -> t_has_type_param_shallow true t) f
+	| TFun(f,ret,_) when not last -> t_has_type_param_shallow true ret	|| List.exists (fun (_,_,t) -> t_has_type_param_shallow true t) f
 	| _ -> false
 
 let rec replace_type_param t = match follow t with
@@ -459,7 +459,7 @@ struct
 		let local_hashcode = ref { local with
 			eexpr = TCall({ local with
 				eexpr = TField(local, FDynamic "hashCode");
-				etype = TFun([], basic.tint);
+				etype = TFun([], basic.tint,false);
 			}, []);
 			etype = basic.tint
 		} in
@@ -530,7 +530,7 @@ struct
 					| TConst(TString s) ->
 						let hashed = java_hash s in
 						let equals_test = {
-							eexpr = TCall({ e with eexpr = TField(local, FDynamic "equals"); etype = TFun(["obj",false,t_dynamic],basic.tbool) }, [ e ]);
+							eexpr = TCall({ e with eexpr = TField(local, FDynamic "equals"); etype = TFun(["obj",false,t_dynamic],basic.tbool,false) }, [ e ]);
 							etype = basic.tbool;
 							epos = e.epos
 						} in
@@ -637,7 +637,7 @@ struct
 
 		let mk_valueof_call boxed_t expr =
 			let box_cl, unboxed_t = get_unboxed_from_boxed boxed_t in
-			let fn = TFun(["param1",false,unboxed_t],boxed_t) in
+			let fn = TFun(["param1",false,unboxed_t],boxed_t,false) in
 			{
 				eexpr = TCall(mk_static_field_access box_cl "valueOf" fn expr.epos, [mk_cast_if_needed unboxed_t expr]);
 				etype = boxed_t;
@@ -907,7 +907,7 @@ let rec handle_throws gen cf =
 			let catch_var = alloc_var "typedException" (TInst(throwable,[])) in
 			let rethrow = mk_local catch_var e.epos in
 			let hx_exception = get_cl (get_type gen (["haxe"], "Exception")) in
-			let wrap_static = mk_static_field_access (hx_exception) "thrown" (TFun([("obj",false,t_dynamic)], t_dynamic)) rethrow.epos in
+			let wrap_static = mk_static_field_access (hx_exception) "thrown" (TFun([("obj",false,t_dynamic)], t_dynamic, false)) rethrow.epos in
 			let thrown_value = mk_cast (TInst(cast_cl,[])) { rethrow with eexpr = TCall(wrap_static, [rethrow]) } in
 			let wrapped = { rethrow with eexpr = TThrow thrown_value; } in
 			let map_throws cl =
@@ -979,13 +979,13 @@ let generate con =
 	let cl_cl = get_cl (get_type gen (["java";"lang"],"Class")) in
 	let basic_fns =
 	[
-		mk_class_field "equals" (TFun(["obj",false,t_dynamic], basic.tbool)) true null_pos (Method MethNormal) [];
-		mk_class_field "toString" (TFun([], basic.tstring)) true null_pos (Method MethNormal) [];
-		mk_class_field "hashCode" (TFun([], basic.tint)) true null_pos (Method MethNormal) [];
-		mk_class_field "getClass" (TFun([], (TInst(cl_cl,[t_dynamic])))) true null_pos (Method MethNormal) [];
-		mk_class_field "wait" (TFun([], basic.tvoid)) true null_pos (Method MethNormal) [];
-		mk_class_field "notify" (TFun([], basic.tvoid)) true null_pos (Method MethNormal) [];
-		mk_class_field "notifyAll" (TFun([], basic.tvoid)) true null_pos (Method MethNormal) [];
+		mk_class_field "equals" (TFun(["obj",false,t_dynamic], basic.tbool, false)) true null_pos (Method MethNormal) [];
+		mk_class_field "toString" (TFun([], basic.tstring, false)) true null_pos (Method MethNormal) [];
+		mk_class_field "hashCode" (TFun([], basic.tint, false)) true null_pos (Method MethNormal) [];
+		mk_class_field "getClass" (TFun([], (TInst(cl_cl,[t_dynamic])), false)) true null_pos (Method MethNormal) [];
+		mk_class_field "wait" (TFun([], basic.tvoid, false)) true null_pos (Method MethNormal) [];
+		mk_class_field "notify" (TFun([], basic.tvoid, false)) true null_pos (Method MethNormal) [];
+		mk_class_field "notifyAll" (TFun([], basic.tvoid, false)) true null_pos (Method MethNormal) [];
 	] in
 	List.iter (fun cf -> gen.gbase_class_fields <- PMap.add cf.cf_name cf gen.gbase_class_fields) basic_fns;
 
@@ -1957,7 +1957,7 @@ let generate con =
 				let is_override = match cf.cf_name with
 					| "equals" when not is_static ->
 						(match cf.cf_type with
-							| TFun([_,_,t], ret) ->
+							| TFun([_,_,t], ret, _) ->
 								(match (real_type t, real_type ret) with
 									| TDynamic _, TAbstract ({ a_path = ([], "Bool") },[])
 									| TAnon _, TAbstract ({ a_path = ([], "Bool") },[]) -> true
@@ -1966,7 +1966,7 @@ let generate con =
 							| _ -> has_class_field_flag cf CfOverride)
 					| "toString" when not is_static ->
 						(match cf.cf_type with
-							| TFun([], ret) ->
+							| TFun([], ret, _) ->
 								(match real_type ret with
 									| TInst( { cl_path = ([], "String") }, []) -> true
 									| _ -> gen.gcon.error "A toString() function should return a String!" cf.cf_pos; false
@@ -1975,7 +1975,7 @@ let generate con =
 						)
 					| "hashCode" when not is_static ->
 						(match cf.cf_type with
-							| TFun([], ret) ->
+							| TFun([], ret, _) ->
 								(match real_type ret with
 									| TAbstract ({ a_path = ([], "Int") },[]) ->
 										true
@@ -1996,7 +1996,7 @@ let generate con =
 
 				let params = List.map snd cl.cl_params in
 				let ret_type, args, has_rest_args = match follow cf_type, follow cf.cf_type with
-					| TFun (strbtl, t), TFun(rargs, _) ->
+					| TFun (strbtl, t, _), TFun(rargs, _, _) ->
 						let ret_type = apply_params cl.cl_params params (real_type t)
 						and args =
 							List.map2 (fun(_,_,t) (n,o,_) ->

+ 2 - 2
src/generators/genjs.ml

@@ -670,7 +670,7 @@ and gen_expr ctx e =
 	| TEnumParameter (x,f,i) ->
 		gen_value ctx x;
 		if not (Common.defined ctx.com Define.JsEnumsAsArrays) then
-			let fname = (match f.ef_type with TFun((args,_)) -> let fname,_,_ = List.nth args i in  fname | _ -> die "" __LOC__ ) in
+			let fname = (match f.ef_type with TFun((args,_,_)) -> let fname,_,_ = List.nth args i in  fname | _ -> die "" __LOC__ ) in
 			print ctx ".%s" (ident fname)
 		else
 			print ctx "[%i]" (i + 2)
@@ -1621,7 +1621,7 @@ let generate_enum ctx e =
 		end else
 			print ctx "%s%s = " p (field f.ef_name);
 		(match f.ef_type with
-		| TFun (args,_) ->
+		| TFun (args,_,_) ->
 			let sargs = String.concat "," (List.map (fun (n,_,_) -> ident n) args) in begin
 			if as_objects then begin
 				let sfields = String.concat "," (List.map (fun (n,_,_) -> (ident n) ^ ":" ^ (ident n) ) args) in

+ 8 - 8
src/generators/genjvm.ml

@@ -165,7 +165,7 @@ let rec jsignature_of_type gctx stack t =
 	| TEnum(en,tl) ->
 		Hashtbl.replace gctx.enum_paths en.e_path ();
 		TObject(en.e_path,List.map jtype_argument_of_type tl)
-	| TFun(tl,tr) -> method_sig (List.map (fun (_,o,t) ->
+	| TFun(tl,tr,_) -> method_sig (List.map (fun (_,o,t) ->
 		let jsig = jsignature_of_type t in
 		let jsig = if o then get_boxed_type jsig else jsig in
 		jsig
@@ -616,7 +616,7 @@ class texpr_to_jvm gctx (jc : JvmClass.builder) (jm : JvmMethod.builder) (return
 	method read cast e1 fa =
 		let read_static_closure path cf =
 			let args,ret = match follow cf.cf_type with
-				| TFun(tl,tr) -> List.map (fun (n,_,t) -> n,self#vtype t) tl,(return_of_type gctx tr)
+				| TFun(tl,tr,_) -> List.map (fun (n,_,t) -> n,self#vtype t) tl,(return_of_type gctx tr)
 				| _ -> die "" __LOC__
 			in
 			self#read_static_closure path cf.cf_name args ret
@@ -1382,7 +1382,7 @@ class texpr_to_jvm gctx (jc : JvmClass.builder) (jm : JvmMethod.builder) (return
 
 	method call_arguments ?(cast=true) t el =
 		let tl,tr = match follow t with
-			| TFun(tl,tr) ->
+			| TFun(tl,tr,_) ->
 				tl,return_of_type gctx tr
 			| _ ->
 				List.map (fun e -> ("",false,e.etype)) el,Some (object_sig)
@@ -1992,7 +1992,7 @@ class texpr_to_jvm gctx (jc : JvmClass.builder) (jm : JvmMethod.builder) (return
 		| TEnumParameter(e1,ef,i) ->
 			self#texpr rvalue_any e1;
 			let path,name,jsig_arg = match follow ef.ef_type with
-				| TFun(tl,TEnum(en,_)) ->
+				| TFun(tl,TEnum(en,_),_) ->
 					let n,_,t = List.nth tl i in
 					en.e_path,n,self#vtype t
 				| _ -> die "" __LOC__
@@ -2216,7 +2216,7 @@ class tclass_to_jvm gctx c = object(self)
 		in
 		let find_overload map_type c cf =
 			let tl = match follow (map_type cf.cf_type) with
-				| TFun(tl,_) -> tl
+				| TFun(tl,_,_) -> tl
 				| _ -> die "" __LOC__
 			in
 			OverloadResolution.resolve_instance_overload false map_type c cf.cf_name (List.map (fun (_,_,t) -> Texpr.Builder.make_null t null_pos) tl)
@@ -2312,7 +2312,7 @@ class tclass_to_jvm gctx c = object(self)
 				DynArray.iter (fun e ->
 					handler#texpr RVoid e;
 				) field_inits;
-				let tl = match follow cf.cf_type with TFun(tl,_) -> tl | _ -> die "" __LOC__ in
+				let tl = match follow cf.cf_type with TFun(tl,_,_) -> tl | _ -> die "" __LOC__ in
 				List.iter (fun (n,_,t) ->
 					let _,load,_ = jm#add_local n (jsignature_of_type gctx t) VarArgument in
 					load();
@@ -2617,7 +2617,7 @@ let generate_enum gctx en =
 	let names = List.map (fun name ->
 		let ef = PMap.find name en.e_constrs in
 		let args = match follow ef.ef_type with
-			| TFun(tl,_) -> List.map (fun (n,_,t) -> n,jsignature_of_type gctx t) tl
+			| TFun(tl,_,_) -> List.map (fun (n,_,t) -> n,jsignature_of_type gctx t) tl
 			| _ -> []
 		in
 		let jsigs = List.map snd args in
@@ -2757,7 +2757,7 @@ let generate_anons gctx =
 				let jsig_cf = jsignature_of_type gctx cf.cf_type in
 				let jm = jc#spawn_method cf.cf_name jsig_cf [MPublic] in
 				let tl,tr = match follow cf.cf_type with
-					| TFun(tl,tr) -> tl,tr
+					| TFun(tl,tr,_) -> tl,tr
 					| _ -> die "" __LOC__
 				in
 				let locals = List.map (fun (n,_,t) ->

+ 2 - 2
src/generators/genlua.ml

@@ -1716,7 +1716,7 @@ let generate_enum ctx e =
         let f = PMap.find n e.e_constrs in
         print ctx "%s%s = " p (field f.ef_name);
         (match f.ef_type with
-         | TFun (args,_) ->
+         | TFun (args,_,_) ->
              let count = List.length args in
              let sargs = String.concat "," (List.map (fun (n,_,_) -> ident n) args) in
              print ctx "function(%s) local _x = _hx_tab_array({[0]=\"%s\",%d,%s,__enum__=%s}, %i);" sargs f.ef_name f.ef_index sargs p (count + 2);
@@ -2124,7 +2124,7 @@ let generate com =
                     tf_expr = mk (TBlock [e]) com.basic.tvoid e.epos;
                 }
             in
-            gen_value ctx { e with eexpr = TFunction fn; etype = TFun ([],com.basic.tvoid) }
+            gen_value ctx { e with eexpr = TFunction fn; etype = TFun ([],com.basic.tvoid,false) }
         );
         spr ctx ", _hx_error)";
         newline ctx

+ 4 - 4
src/generators/genneko.ml

@@ -235,7 +235,7 @@ and gen_expr ctx e =
 		gen_binop ctx p op e1 e2
 	| TField (e2,FClosure (_,f)) ->
 		(match follow e.etype with
-		| TFun (args,_) ->
+		| TFun (args,_,_) ->
 			let n = List.length args in
 			if n > 5 then abort "Cannot create closure with more than 5 arguments" e.epos;
 			let tmp = ident p "@tmp" in
@@ -261,7 +261,7 @@ and gen_expr ctx e =
 		gen_expr ctx e
 	| TObjectDecl fl ->
 		let hasToString = ref false in
-		let fl = List.map (fun ((f,_,_),e) -> if f = "toString" then hasToString := (match follow e.etype with TFun ([],_) -> true | _ -> false); f , gen_expr ctx e) fl in
+		let fl = List.map (fun ((f,_,_),e) -> if f = "toString" then hasToString := (match follow e.etype with TFun ([],_,_) -> true | _ -> false); f , gen_expr ctx e) fl in
 		(EObject (if !hasToString then ("__string",ident p "@default__string") :: fl else fl),p)
 	| TArrayDecl el ->
 		call p (field p (ident p "Array") "new1") [array p (List.map (gen_expr ctx) el); int p (List.length el)]
@@ -442,7 +442,7 @@ let gen_class ctx c =
 	let fstring = (try
 		let f = PMap.find "toString" c.cl_fields in
 		match follow f.cf_type with
-		| TFun ([],_) -> ["__string",ident p "@default__string"]
+		| TFun ([],_,_) -> ["__string",ident p "@default__string"]
 		| _ -> []
 	with Not_found ->
 		[]
@@ -510,7 +510,7 @@ let gen_enum_constr ctx path c =
 	ctx.curmethod <- c.ef_name;
 	let p = pos ctx c.ef_pos in
 	(EBinop ("=",field p path c.ef_name, match follow c.ef_type with
-		| TFun (params,_) ->
+		| TFun (params,_,_) ->
 			let params = List.map (fun (n,_,_) -> n) params in
 			(EFunction (params,
 				(EBlock [

+ 8 - 8
src/generators/genphp7.ml

@@ -412,7 +412,7 @@ let rec needs_temp_var expr =
 *)
 let get_function_signature (field:tclass_field) : (string * bool * Type.t) list * Type.t =
 	match follow field.cf_type with
-		| TFun (args, return_type) -> (args, return_type)
+		| TFun (args, return_type, _) -> (args, return_type)
 		| _ -> fail field.cf_pos __LOC__
 
 (**
@@ -600,7 +600,7 @@ let fix_tsignature_args args =
 *)
 let fix_call_args callee_type exprs =
 	match follow callee_type with
-	| TFun (args,_) ->
+	| TFun (args,_,_) ->
 		(match List.rev args with
 		| (_,_,t) :: args_rev when is_rest_type t && List.length args_rev > List.length exprs ->
 			let rec loop args exprs =
@@ -1491,7 +1491,7 @@ class code_writer (ctx:php_generator_context) hx_type_path php_name =
 					match self#parent_expr with
 						| Some { eexpr = TCall (target, params) } when current != (reveal_expr target) ->
 							(match follow target.etype with
-								| TFun (args,_) ->
+								| TFun (args,_,_) ->
 									let rec check args params =
 										match args, params with
 										| (_, _, t) :: _, param :: _ when current == (reveal_expr param) ->
@@ -1518,7 +1518,7 @@ class code_writer (ctx:php_generator_context) hx_type_path php_name =
 					| { eexpr = TBinop(OpAssign, left_expr, _) } :: _
 					| { eexpr = TBinop(OpAssignOp _, left_expr, _) } :: _ -> left_expr == current
 					| { eexpr = TUnop(op, _, _) } :: _ -> is_modifying_unop op
-					| { eexpr = TCall({ etype = TFun(types,_) }, args) } :: _ when is_in_ref_arg current types args -> true
+					| { eexpr = TCall({ etype = TFun(types,_,_) }, args) } :: _ when is_in_ref_arg current types args -> true
 					| [] -> false
 					| parent :: rest -> traverse parent rest
 			in
@@ -3342,7 +3342,7 @@ class enum_builder ctx (enm:tenum) =
 		method private write_constructor name (field:tenum_field) =
 			let args =
 				match follow field.ef_type with
-					| TFun (args, _) -> args
+					| TFun (args, _, _) -> args
 					| TEnum _ -> []
 					| _ -> fail field.ef_pos __LOC__
 			in
@@ -3413,7 +3413,7 @@ class enum_builder ctx (enm:tenum) =
 			PMap.iter
 				(fun name field ->
 					let count = match follow field.ef_type with
-						| TFun (params, _) -> List.length params
+						| TFun (params, _, _) -> List.length params
 						| TEnum _ -> 0
 						| _ -> fail field.ef_pos __LOC__
 					in
@@ -3479,7 +3479,7 @@ class class_builder ctx (cls:tclass) =
 					let fields = if is_static then cls.cl_statics else cls.cl_fields in
 					try
 						match (PMap.find name fields).cf_type with
-							| TFun (args,_) ->
+							| TFun (args,_,_) ->
 								let rec count args mandatory total =
 									match args with
 										| [] ->
@@ -3585,7 +3585,7 @@ class class_builder ctx (cls:tclass) =
 						None
 					else
 						Some {
-							(mk_field "new" (TFun ([], ctx.pgc_common.basic.tvoid)) cls.cl_pos cls.cl_pos) with
+							(mk_field "new" (TFun ([], ctx.pgc_common.basic.tvoid, false)) cls.cl_pos cls.cl_pos) with
 							cf_kind = Method MethNormal;
 							cf_expr = Some {
 								eexpr = TFunction {

+ 5 - 5
src/generators/genpy.ml

@@ -46,7 +46,7 @@ module Utils = struct
 	let mk_static_call c cf el p =
 		let ef = mk_static_field c cf p in
 		let tr = match follow ef.etype with
-			| TFun(args,tr) -> tr
+			| TFun(args,tr,_) -> tr
 			| _ -> die "" __LOC__
 		in
 		mk (TCall(ef,el)) tr p
@@ -600,7 +600,7 @@ module Transformer = struct
 					| _ -> die "" __LOC__)
 				| _ -> die "" __LOC__
 			in
-			let f1 = { tf_args = []; tf_type = TFun([],ex.etype); tf_expr = ex} in
+			let f1 = { tf_args = []; tf_type = TFun([],ex.etype,false); tf_expr = ex} in
 			let fexpr = mk (TFunction f1) ex.etype ex.epos in
 			let fvar = to_tvar name fexpr.etype fexpr.epos in
 			let f = add_non_locals_to_func fexpr in
@@ -1466,7 +1466,7 @@ module Printer = struct
 				do_default ()
 			| FAnon cf when is_assign && call_override(name) ->
 				begin match follow cf.cf_type with
-					| TFun([],_) ->
+					| TFun([],_,_) ->
 						Printf.sprintf "_hx_partial(HxOverrides.%s, %s)" name obj
 					| _ ->
 						do_default()
@@ -2174,13 +2174,13 @@ module Generator = struct
 
 		let const_constructors,param_constructors = List.partition (fun ef ->
 			match follow ef.ef_type with
-			| TFun(_,_) -> false
+			| TFun(_,_,_) -> false
 			| _ -> true
 		) enum_constructs in
 
 		List.iter (fun ef ->
 			match follow ef.ef_type with
-			| TFun(args, _) ->
+			| TFun(args, _, _) ->
 				let arg_name hx_name =
 					let name = handle_keywords hx_name in
 					if name = p_name then p_name ^ "_" ^ name

+ 1 - 1
src/generators/genswf.ml

@@ -78,7 +78,7 @@ let build_dependencies t =
 			if a.a_path <> ([],"Null") && Meta.has Meta.CoreType a.a_meta then
 				add_path a.a_path DKType;
 			List.iter (add_type_rec (t::l)) pl;
-		| TFun (pl,t2) ->
+		| TFun (pl,t2,_) ->
 			List.iter (fun (_,_,t2) -> add_type_rec (t::l) t2) pl;
 			add_type_rec (t::l) t2;
 		| TAnon a ->

+ 4 - 4
src/generators/genswf9.ml

@@ -1442,7 +1442,7 @@ and gen_call ctx retval e el r =
 	| { eexpr = TUnop (Spread, Prefix, rest) } :: el_rev ->
 		let null = mk (TConst TNull) t_dynamic null_pos
 		and t_array_dyn = ctx.com.basic.tarray t_dynamic in
-		let t = TFun (["thisArg",false,t_dynamic; "argArray",false,t_array_dyn],r) in
+		let t = TFun (["thisArg",false,t_dynamic; "argArray",false,t_array_dyn],r,false) in
 		let apply = mk (TField (e,FDynamic "apply")) t e.epos in
 		gen_call ctx retval apply [null; args_as_array ctx (List.rev el_rev) rest] r
 	(* normal call without `...rest` *)
@@ -2140,7 +2140,7 @@ let generate_field_kind ctx f c stat =
 		);
 	| _ when (has_class_flag c CInterface || has_class_field_flag f CfAbstract) && not stat ->
 		(match follow f.cf_type, f.cf_kind with
-		| TFun (args,tret), Method (MethNormal | MethInline) ->
+		| TFun (args,tret,_), Method (MethNormal | MethInline) ->
 			let dparams = ref None in
 			List.iter (fun (_,o,t) ->
 				match !dparams with
@@ -2588,7 +2588,7 @@ let generate_class ctx c =
 	) c.cl_fields [] in
 	let fields = if c.cl_path <> ctx.boot then fields else begin
 		let cf = {
-			(mk_field "init" ~public:(ctx.swc && ctx.swf_protected) (TFun ([],t_dynamic)) c.cl_pos null_pos) with
+			(mk_field "init" ~public:(ctx.swc && ctx.swf_protected) (TFun ([],t_dynamic,false)) c.cl_pos null_pos) with
 			cf_kind = Method MethNormal;
 		} in
 		{
@@ -2704,7 +2704,7 @@ let generate_enum ctx e meta =
 			hlf_name = ident f.ef_name;
 			hlf_slot = !st_count;
 			hlf_kind = (match f.ef_type with
-				| TFun (args,_) ->
+				| TFun (args,_,_) ->
 					let fdata = begin_fun ctx (List.map (fun (a,opt,t) -> alloc_var VGenerated a t e.e_pos, (if opt then Some (mk (TConst TNull) t_dynamic null_pos) else None)) args) (TEnum (e,[])) [] true f.ef_pos in
 					write ctx (HFindPropStrict name_id);
 					write ctx (HString f.ef_name);

+ 1 - 1
src/macro/eval/evalMain.ml

@@ -555,7 +555,7 @@ let handle_decoding_error f v t =
 					begin match follow ef.ef_type,Array.to_list ev.eargs with
 						| _,[] ->
 							()
-						| TFun(tl,_),vl ->
+						| TFun(tl,_,_),vl ->
 							 f "(";
 							loop2 true tl vl;
 							f ")"

+ 2 - 2
src/macro/eval/evalPrototype.ml

@@ -220,7 +220,7 @@ let create_static_prototype ctx mt =
 		let names = List.map (fun name ->
 			let ef = PMap.find name en.e_constrs in
 			let args = match follow ef.ef_type with
-				| TFun(args,_) ->
+				| TFun(args,_,_) ->
 					List.map (fun (n,_,_) -> hash n) args
 				| _ ->
 					[]
@@ -229,7 +229,7 @@ let create_static_prototype ctx mt =
 		) en.e_names in
 		let pctx = PrototypeBuilder.create ctx key None (PEnum names) meta in
 		let enum_field_value ef = match follow ef.ef_type with
-			| TFun(args,_) ->
+			| TFun(args,_,_) ->
 				let f = (fun vl -> encode_enum_value key ef.ef_index (Array.of_list vl) (Some ef.ef_pos)) in
 				vstatic_function f
 			| _ -> encode_enum_value key ef.ef_index [||] (Some ef.ef_pos)

+ 4 - 4
src/macro/macroApi.ml

@@ -1074,7 +1074,7 @@ and encode_type t =
 			2 , [encode_clref c; encode_tparams pl]
 		| TType (t,pl) ->
 			3 , [encode_ref t encode_ttype (fun() -> s_type_path t.t_path); encode_tparams pl]
-		| TFun (pl,ret) ->
+		| TFun (pl,ret,coro) ->
 			let pl = List.map (fun (n,o,t) ->
 				encode_obj [
 					"name",encode_string n;
@@ -1082,7 +1082,7 @@ and encode_type t =
 					"t",encode_type t
 				]
 			) pl in
-			4 , [encode_array pl; encode_type ret]
+			4 , [encode_array pl; encode_type ret; vbool coro]
 		| TAnon a ->
 			5, [encode_ref a encode_tanon (fun() -> "<anonymous>")]
 		| TDynamic tsub as t ->
@@ -1131,7 +1131,7 @@ and decode_type t =
 	| 1, [e; pl] -> TEnum (decode_ref e, List.map decode_type (decode_array pl))
 	| 2, [c; pl] -> TInst (decode_ref c, List.map decode_type (decode_array pl))
 	| 3, [t; pl] -> TType (decode_ref t, List.map decode_type (decode_array pl))
-	| 4, [pl; r] -> TFun (List.map (fun p -> decode_string (field p "name"), decode_bool (field p "opt"), decode_type (field p "t")) (decode_array pl), decode_type r)
+	| 4, [pl; r; coro] -> TFun (List.map (fun p -> decode_string (field p "name"), decode_bool (field p "opt"), decode_type (field p "t")) (decode_array pl), decode_type r, decode_opt_bool coro)
 	| 5, [a] -> TAnon (decode_ref a)
 	| 6, [t] -> if t = vnull then t_dynamic else TDynamic (decode_type t)
 	| 7, [f] -> TLazy (decode_lazytype f)
@@ -1344,7 +1344,7 @@ let decode_efield v =
 	let rec get_enum t =
 		match follow t with
 		| TEnum (enm,_) -> enm
-		| TFun (_,t) -> get_enum t
+		| TFun (_,t,_) -> get_enum t
 		| _ -> raise Not_found
 	in
 	let name = decode_string (field v "name") in

+ 1 - 1
src/optimization/dce.ml

@@ -232,7 +232,7 @@ and mark_t dce p t =
 		| TInst(c,pl) ->
 			mark_class dce c;
 			List.iter (mark_t dce p) pl
-		| TFun(args,ret) ->
+		| TFun(args,ret,_) ->
 			List.iter (fun (_,_,t) -> mark_t dce p t) args;
 			mark_t dce p ret
 		| TEnum(e,pl) ->

+ 2 - 2
src/optimization/inline.ml

@@ -583,13 +583,13 @@ class inline_state ctx ethis params cf f p = object(self)
 		let e = Diagnostics.secure_generated_code ctx e in
 		if has_params then begin
 			let mt = map_type cf.cf_type in
-			let unify_func () = unify_raise ctx mt (TFun (tl,tret)) p in
+			let unify_func () = unify_raise ctx mt (TFun (tl,tret,false)) p in
 			(match follow ethis.etype with
 			| TAnon a -> (match !(a.a_status) with
 				| Statics {cl_kind = KAbstractImpl a } when has_class_field_flag cf CfImpl ->
 					if cf.cf_name <> "_new" then begin
 						(* the first argument must unify with a_this for abstract implementation functions *)
-						let tb = (TFun(("",false,map_type a.a_this) :: (List.tl tl),tret)) in
+						let tb = (TFun(("",false,map_type a.a_this) :: (List.tl tl),tret,false)) in
 						unify_raise ctx mt tb p
 					end
 				| _ -> unify_func())

+ 2 - 2
src/optimization/optimizer.ml

@@ -299,7 +299,7 @@ let rec reduce_loop ctx e =
 			| { eexpr = TFunction func } as ef ->
 				let cf = mk_field "" ef.etype e.epos null_pos in
 				let ethis = mk (TConst TThis) t_dynamic e.epos in
-				let rt = (match follow ef.etype with TFun (_,rt) -> rt | _ -> die "" __LOC__) in
+				let rt = (match follow ef.etype with TFun (_,rt,_) -> rt | _ -> die "" __LOC__) in
 				let inl = (try type_inline ctx cf func ethis el rt None e.epos ~self_calling_closure:true false with Error (Custom _,_) -> None) in
 				(match inl with
 				| None -> reduce_expr ctx e
@@ -308,7 +308,7 @@ let rec reduce_loop ctx e =
 				begin match cf.cf_expr with
 				| Some {eexpr = TFunction tf} ->
 					let config = inline_config (Some cl) cf el e.etype in
-					let rt = (match follow e1.etype with TFun (_,rt) -> rt | _ -> die "" __LOC__) in
+					let rt = (match follow e1.etype with TFun (_,rt,_) -> rt | _ -> die "" __LOC__) in
 					let inl = (try type_inline ctx cf tf ef el rt config e.epos false with Error (Custom _,_) -> None) in
 					(match inl with
 					| None -> reduce_expr ctx e

+ 6 - 6
src/typing/callUnification.ml

@@ -203,7 +203,7 @@ let rec unify_call_args ctx el args r callp inline force_inline in_overload =
 	in
 	let el = try loop el args with exc -> restore(); raise exc; in
 	restore();
-	el,TFun(args,r)
+	el,TFun(args,r,false (* corotodo *))
 
 type overload_kind =
 	| OverloadProper (* @:overload or overload *)
@@ -287,7 +287,7 @@ let unify_field_call ctx fa el_typed el p inline =
 		let monos = Monomorph.spawn_constrained_monos map cf.cf_params in
 		let t = map (apply_params cf.cf_params monos cf.cf_type) in
 		match follow t with
-		| TFun(args,ret) ->
+		| TFun(args,ret,coro) ->
 			let rec loop acc_el acc_args tmap args el_typed = match args,el_typed with
 				| ((_,opt,t0) as arg) :: args,e :: el_typed ->
 					begin try
@@ -312,7 +312,7 @@ let unify_field_call ctx fa el_typed el p inline =
 			in
 			(* here *)
 			let el = el_typed @ el in
-			let tf = TFun(args_typed @ args,ret) in
+			let tf = TFun(args_typed @ args,ret,coro) in
 			let mk_call () =
 				let ef = mk (TField(fa.fa_on,FieldAccess.apply_fa cf fa.fa_host)) t fa.fa_pos in
 				!make_call_ref ctx ef el ret ~force_inline:inline p
@@ -360,7 +360,7 @@ let unify_field_call ctx fa el_typed el p inline =
 		loop candidates
 	in
 	let fail_fun () =
-		let tf = TFun(List.map (fun _ -> ("",false,t_dynamic)) el,t_dynamic) in
+		let tf = TFun(List.map (fun _ -> ("",false,t_dynamic)) el,t_dynamic,false) in
 		let call () =
 			let ef = mk (TField(fa.fa_on,FieldAccess.apply_fa fa.fa_field fa.fa_host)) tf fa.fa_pos in
 			mk (TCall(ef,[])) t_dynamic p
@@ -521,9 +521,9 @@ object(self)
 			mk (TCall (e,el)) t p
 		in
 		let rec loop t = match follow t with
-		| TFun (args,r) ->
+		| TFun (args,r,corotodo) ->
 			let el, tfunc = unify_call_args ctx el args r p false false false in
-			let r = match tfunc with TFun(_,r) -> r | _ -> die "" __LOC__ in
+			let r = match tfunc with TFun(_,r,_) -> r | _ -> die "" __LOC__ in
 			mk (TCall (e,el)) r p
 		| TAbstract(a,tl) as t ->
 			let check_callable () =

+ 6 - 6
src/typing/calls.ml

@@ -193,7 +193,7 @@ let rec acc_get ctx g p =
 		(* TODO *)
 		(* let ec = {ec with eexpr = (TMeta((Meta.StaticExtension,[],null_pos),ec))} in *)
 		let t = match follow e_field.etype with
-			| TFun (_ :: args,ret) -> TFun(args,ret)
+			| TFun (_ :: args,ret,coro) -> TFun(args,ret,coro)
 			| t -> t
 		in
 		{e_field with etype = t}
@@ -220,11 +220,11 @@ let rec acc_get ctx g p =
 		let e_field = FieldAccess.get_field_expr sea.se_access FGet in
 		(* build a closure with first parameter applied *)
 		(match follow e_field.etype with
-		| TFun ((_,_,t0) :: args,ret) ->
+		| TFun ((_,_,t0) :: args,ret,coro) ->
 			let te = abstract_using_param_type sea in
 			unify ctx te t0 e.epos;
-			let tcallb = TFun (args,ret) in
-			let twrap = TFun ([("_e",false,e.etype)],tcallb) in
+			let tcallb = TFun (args,ret,false) in
+			let twrap = TFun ([("_e",false,e.etype)],tcallb,coro) in
 			(* arguments might not have names in case of variable fields of function types, so we generate one (issue #2495) *)
 			let args = List.map (fun (n,o,t) ->
 				let t = if o then ctx.t.tnull t else t in
@@ -303,7 +303,7 @@ let call_to_string ctx ?(resume=false) e =
 			mk (TIf (check_null, string_null, Some (gen_to_string e))) ctx.t.tstring e.epos
 	end
 
-let type_bind ctx (e : texpr) (args,ret) params p =
+let type_bind ctx (e : texpr) (args,ret,coro) params p =
 	let vexpr v = mk (TLocal v) v.v_type p in
 	let acount = ref 0 in
 	let alloc_name n =
@@ -367,7 +367,7 @@ let type_bind ctx (e : texpr) (args,ret) params p =
 		tf_type = ret;
 		tf_expr = body;
 	} in
-	let t = TFun(List.map (fun (v,o) -> v.v_name,o,v.v_type) missing_args,ret) in
+	let t = TFun(List.map (fun (v,o) -> v.v_name,o,v.v_type) missing_args,ret,false) in
 	{
 		eexpr = TBlock (var_decls @ [mk (TFunction fn) t p]);
 		etype = t;

+ 2 - 2
src/typing/fields.ml

@@ -413,7 +413,7 @@ let type_field cfg ctx e i p mode (with_type : WithType.t) =
 						let monos = Monomorph.spawn_constrained_monos (fun t -> t) cf.cf_params in
 						let cft = follow (apply_params cf.cf_params monos cf.cf_type) in
 						match cft with
-						| TFun ((_,_,(TType ({ t_path = ["haxe";"macro"],"ExprOf" },[t0]) | t0)) :: _,_) ->
+						| TFun ((_,_,(TType ({ t_path = ["haxe";"macro"],"ExprOf" },[t0]) | t0)) :: _,_,_) ->
 							if t == t_dynamic && follow t0 != t then
 								check()
 							else begin
@@ -572,7 +572,7 @@ let get_struct_init_anon_fields c tl =
 				| None -> None
 			in
 			(match follow cf.cf_type with
-			| TFun (args,_) ->
+			| TFun (args,_,_) ->
 				Some (match cf.cf_expr with
 					| Some { eexpr = TFunction fn } ->
 						List.map (fun (name,_,t) ->

+ 1 - 1
src/typing/finalization.ml

@@ -39,7 +39,7 @@ let get_main ctx types =
 		let ft = Type.field_type f in
 		let fmode, r =
 			match follow ft with
-			| TFun ([],r) -> FStatic (c,f), r
+			| TFun ([],r,_) -> FStatic (c,f), r
 			| _ -> error ("Invalid -main : " ^ s_type_path path ^ " has invalid main function") c.cl_pos
 		in
 		if not (ExtType.is_void (follow r)) then error (Printf.sprintf "Return type of main function should be Void (found %s)" (s_type (print_context()) r)) f.cf_name_pos;

+ 4 - 4
src/typing/forLoop.ml

@@ -21,7 +21,7 @@ let optimize_for_loop_iterator ctx v e1 e2 p =
 				| TCall ({ eexpr = TField (_, FInstance (c,pl,cf)) }, _) ->
 					let t = apply_params c.cl_params pl cf.cf_type in
 					(match follow t with
-					| TFun (_, t) ->
+					| TFun (_, t, _) ->
 						(match follow t with
 						| TInst (c,pl) -> c,pl
 						| _ -> raise Exit
@@ -37,7 +37,7 @@ let optimize_for_loop_iterator ctx v e1 e2 p =
 	let it_type = TInst(c,tl) in
 	let tmp = gen_local ctx it_type e1.epos in
 	let eit = mk (TLocal tmp) it_type p in
-	let ehasnext = make_call ctx (mk (TField (eit,FInstance (c, tl, fhasnext))) (TFun([],ctx.t.tbool)) p) [] ctx.t.tbool p in
+	let ehasnext = make_call ctx (mk (TField (eit,FInstance (c, tl, fhasnext))) (TFun([],ctx.t.tbool,false)) p) [] ctx.t.tbool p in
 	let fa_next =
 		try
 			match raw_class_field (fun cf -> apply_params c.cl_params tl cf.cf_type) c tl "next" with
@@ -45,7 +45,7 @@ let optimize_for_loop_iterator ctx v e1 e2 p =
 		with Not_found ->
 			quick_field_dynamic eit.etype "next"
 	in
-	let enext = mk (TVar (v,Some (make_call ctx (mk (TField (eit,fa_next)) (TFun ([],v.v_type)) p) [] v.v_type p))) ctx.t.tvoid p in
+	let enext = mk (TVar (v,Some (make_call ctx (mk (TField (eit,fa_next)) (TFun ([],v.v_type,false)) p) [] v.v_type p))) ctx.t.tvoid p in
 	let eblock = (match e2.eexpr with
 		| TBlock el -> { e2 with eexpr = TBlock (enext :: el) }
 		| _ -> mk (TBlock [enext;e2]) ctx.t.tvoid p
@@ -143,7 +143,7 @@ module IterationKind = struct
 				make_static_call ctx c cf_length (apply_params a.a_params tl) [e] ctx.com.basic.tint p
 			in
 			(match follow cf_length.cf_type with
-				| TFun(_,tr) ->
+				| TFun(_,tr,_) ->
 					(match follow tr with
 						| TAbstract({a_path = [],"Int"},_) -> ()
 						| _ -> raise Not_found

+ 2 - 2
src/typing/generic.ml

@@ -45,7 +45,7 @@ let make_generic ctx ps pt p =
 				| TType (td,tl) -> (s_type_path_underscore td.t_path) ^ (loop_tl top tl)
 				| TEnum(en,tl) -> (s_type_path_underscore en.e_path) ^ (loop_tl top tl)
 				| TAnon(a) -> "anon_" ^ String.concat "_" (PMap.foldi (fun s f acc -> (s ^ "_" ^ (loop false (follow f.cf_type))) :: acc) a.a_fields [])
-				| TFun(args, return_type) -> "func_" ^ (String.concat "_" (List.map (fun (_, _, t) -> loop false t) args)) ^ "_" ^ (loop false return_type)
+				| TFun(args, return_type, _) -> "func_" ^ (String.concat "_" (List.map (fun (_, _, t) -> loop false t) args)) ^ "_" ^ (loop false return_type)
 				| TAbstract(a,tl) -> (s_type_path_underscore a.a_path) ^ (loop_tl top tl)
 				| _ when not top ->
 					follow_or t top (fun() -> "_") (* allow unknown/incompatible types as type parameters to retain old behavior *)
@@ -237,7 +237,7 @@ let rec build_generic ctx c p tl =
 				if t == t2 then () else loop t2
 			| TAnon a ->
 				PMap.iter (fun _ f -> loop f.cf_type) a.a_fields
-			| TFun (args,ret) ->
+			| TFun (args,ret,_) ->
 				List.iter (fun (_,_,t) -> loop t) args;
 				loop ret
 			end

+ 1 - 1
src/typing/macroContext.ml

@@ -561,7 +561,7 @@ let load_macro' ctx display cpath f p =
 				| _ -> error "Macro should be called on a class" p
 		in
 		api.MacroApi.current_macro_module <- (fun() -> mloaded);
-		let meth = (match follow meth.cf_type with TFun (args,ret) -> (args,ret,cl,meth),mloaded | _ -> error "Macro call should be a method" p) in
+		let meth = (match follow meth.cf_type with TFun (args,ret,_) -> (args,ret,cl,meth),mloaded | _ -> error "Macro call should be a method" p) in
 		restore();
 		if not ctx.in_macro then flush_macro_context mint ctx;
 		Hashtbl.add mctx.com.cached_macros (cpath,f) meth;

+ 8 - 8
src/typing/matcher.ml

@@ -103,7 +103,7 @@ module Constructor = struct
 		| _ -> false
 
 	let arity con = match fst con with
-		| ConEnum (_,{ef_type = TFun(args,_)}) -> List.length args
+		| ConEnum (_,{ef_type = TFun(args,_,_)}) -> List.length args
 		| ConEnum _ -> 0
 		| ConConst _ -> 0
 		| ConFields fields -> List.length fields
@@ -330,7 +330,7 @@ module Pattern = struct
 				PatConstructor(con_const ct p,[])
 			| EConst (Ident i) ->
 				begin match follow t with
-					| TFun(ta,tr) when tr == fake_tuple_type ->
+					| TFun(ta,tr,_) when tr == fake_tuple_type ->
 						if i = "_" then PatTuple(List.map (fun (_,_,t) -> (PatAny,pos e)) ta)
 						else error "Cannot bind matched tuple to variable, use _ instead" p
 					| _ ->
@@ -343,13 +343,13 @@ module Pattern = struct
 			| ECall(e1,el) ->
 				let e1 = type_expr ctx e1 (WithType.with_type t) in
 				begin match e1.eexpr,follow e1.etype with
-					| TField(_, FEnum(en,ef)),TFun(_,TEnum(_,tl)) ->
+					| TField(_, FEnum(en,ef)),TFun(_,TEnum(_,tl),_) ->
 						let map = apply_params en.e_params tl in
 						let monos = Monomorph.spawn_constrained_monos map ef.ef_params in
 						let map t = map (apply_params ef.ef_params monos t) in
 						unify ctx (map ef.ef_type) e1.etype e1.epos;
 						let args = match follow e1.etype with
-							| TFun(args,r) ->
+							| TFun(args,r,_) ->
 								unify_expected r;
 								args
 							| _ -> die "" __LOC__
@@ -384,7 +384,7 @@ module Pattern = struct
 				end
 			| EArrayDecl el ->
 				let rec pattern seen t = match follow t with
-					| TFun(tl,tr) when tr == fake_tuple_type ->
+					| TFun(tl,tr,_) when tr == fake_tuple_type ->
 						let rec loop el tl = match el,tl with
 							| e :: el,(_,_,t) :: tl ->
 								let pat = make pctx false t e in
@@ -965,7 +965,7 @@ module Compile = struct
 			let t_en = TEnum(en,tl) in
 			let e = if not (type_iseq t_en e.etype) then mk (TCast(e,None)) t_en e.epos else e in
 			begin match follow ef.ef_type with
-				| TFun(args,_) ->
+				| TFun(args,_,_) ->
 					let rec combine args positions =
 						match (args, positions) with
 							| (a :: args, p :: positions) -> (a, p) :: combine args positions
@@ -1286,7 +1286,7 @@ module TexprConverter = struct
 				if top then loop false s e1
 				else loop false (Printf.sprintf "{ %s: %s }" (field_name fa) s) e1
 			| TEnumParameter(e1,ef,i) ->
-				let arity = match follow ef.ef_type with TFun(args,_) -> List.length args | _ -> die "" __LOC__ in
+				let arity = match follow ef.ef_type with TFun(args,_,_) -> List.length args | _ -> die "" __LOC__ in
 				let l = make_offset_list i (arity - i - 1) s "_" in
 				loop false (Printf.sprintf "%s(%s)" ef.ef_name (String.concat ", " l)) e1
 			| TLocal v ->
@@ -1308,7 +1308,7 @@ module TexprConverter = struct
 	let unify_constructor ctx params t con =
 		match fst con with
 		| ConEnum(en,ef) ->
-			let t_ef = match follow ef.ef_type with TFun(_,t) -> t | _ -> ef.ef_type in
+			let t_ef = match follow ef.ef_type with TFun(_,t,_) -> t | _ -> ef.ef_type in
 			let t_ef = apply_params ctx.type_params params (monomorphs en.e_params (monomorphs ef.ef_params t_ef)) in
 			let monos = List.map (fun t -> match follow t with
 				| TInst({cl_kind = KTypeParameter _},_) | TMono _ -> mk_mono()

+ 3 - 3
src/typing/nullSafety.ml

@@ -290,7 +290,7 @@ class unificator =
 				)
 				b.a_fields
 
-		method private unify_functions (a_args, a_result) (b_args, b_result) =
+		method private unify_functions (a_args, a_result, a_corotodo) (b_args, b_result, b_corotodo) =
 			(* check return type *)
 			(match b_result with
 				| TAbstract ({ a_path = ([], "Void") }, []) -> ()
@@ -1401,7 +1401,7 @@ class expr_checker mode immediate_execution report =
 						| Some cf ->
 							let rec traverse t =
 								match follow t with
-									| TFun (types, _) -> self#check_args e_new args types
+									| TFun (types, _, _) -> self#check_args e_new args types
 									| _ -> fail ~msg:"Unexpected constructor type." e_new.epos __POS__
 							in
 							let ctor_type = apply_params cls.cl_params params cf.cf_type in
@@ -1421,7 +1421,7 @@ class expr_checker mode immediate_execution report =
 					self#check_expr callee
 			);
 			(match follow callee.etype with
-				| TFun (types, _) ->
+				| TFun (types, _, _) ->
 					if is_trace callee then
 						let real_args =
 							match List.rev args with

+ 2 - 2
src/typing/operators.ml

@@ -204,7 +204,7 @@ let unify_int ctx e k =
 	in
 	let is_dynamic_return t =
 		match follow t with
-		| TFun (_,r) -> is_dynamic r
+		| TFun (_,r,_) -> is_dynamic r
 		| _ -> true
 	in
 	(*
@@ -492,7 +492,7 @@ let find_abstract_binop_overload ctx op e1 e2 a c tl left is_assign_op with_type
 		| (op_cf,cf) :: ol when op_cf = find_op ->
 			let is_impl = has_class_field_flag cf CfImpl in
 			begin match follow cf.cf_type with
-				| TFun([(_,_,t1);(_,_,t2)],tret) ->
+				| TFun([(_,_,t1);(_,_,t2)],tret,_) ->
 					let check e1 e2 swapped =
 						let map_arguments () =
 							let monos = Monomorph.spawn_constrained_monos (fun t -> t) cf.cf_params in

+ 2 - 2
src/typing/overloadResolution.ml

@@ -6,7 +6,7 @@ open TFunctions
 let unify_cf map_type c cf el =
 	let monos = List.map (fun _ -> mk_mono()) cf.cf_params in
 	match follow (apply_params cf.cf_params monos (map_type cf.cf_type)) with
-		| TFun(tl'',ret) as tf ->
+		| TFun(tl'',ret,_) as tf ->
 			let rec loop2 acc el tl = match el,tl with
 				| e :: el,(_,o,t) :: tl ->
 					begin try
@@ -57,7 +57,7 @@ let resolve_instance_overload is_ctor map_type c name el =
 	let candidates = ref [] in
 	let has_function t1 fcc2 =
 		begin match follow t1,fcc2.fc_type with
-		| TFun(tl1,_),TFun(tl2,_) -> type_iseq (TFun(tl1,t_dynamic)) (TFun(tl2,t_dynamic))
+		| TFun(tl1,_,coro1),TFun(tl2,_,coro2) -> type_iseq (TFun(tl1,t_dynamic,coro1)) (TFun(tl2,t_dynamic,coro2))
 		| _ -> false
 		end
 	in

+ 10 - 6
src/typing/typeload.ml

@@ -563,7 +563,7 @@ and load_complex_type' ctx allow_display (t,p) =
 					let old = ctx.type_params in
 					ctx.type_params <- !params @ old;
 					let args = List.map (fun ((name,_),o,_,t,e) -> no_expr e; name, o, topt t) fd.f_args in
-					let t = TFun (args,topt fd.f_type), Method (if !dyn then MethDynamic else MethNormal) in
+					let t = TFun (args,topt fd.f_type,false), Method (if !dyn then MethDynamic else MethNormal) in
 					ctx.type_params <- old;
 					t
 				| FProp (i1,i2,t,e) ->
@@ -611,13 +611,13 @@ and load_complex_type' ctx allow_display (t,p) =
 	| CTFunction (args,r) ->
 		match args with
 		| [CTPath { tpackage = []; tparams = []; tname = "Void" },_] ->
-			TFun ([],load_complex_type ctx allow_display r)
+			TFun ([],load_complex_type ctx allow_display r,false)
 		| _ ->
 			TFun (List.map (fun t ->
 				let t, opt = (match fst t with CTOptional t | CTParent((CTOptional t,_)) -> t, true | _ -> t,false) in
 				let n,t = (match fst t with CTNamed (n,t) -> (fst n), t | _ -> "", t) in
 				n,opt,load_complex_type ctx allow_display t
-			) args,load_complex_type ctx allow_display r)
+			) args,load_complex_type ctx allow_display r,false)
 
 and load_complex_type ctx allow_display (t,pn) =
 	try
@@ -662,7 +662,7 @@ and init_meta_overloads ctx co cf =
 					)
 					f.f_args
 			in
-			let cf = { cf with cf_type = TFun (args,topt f.f_type); cf_params = params; cf_meta = cf_meta} in
+			let cf = { cf with cf_type = TFun (args,topt f.f_type,false); cf_params = params; cf_meta = cf_meta} in
 			generate_args_meta ctx.com co (fun meta -> cf.cf_meta <- meta :: cf.cf_meta) f.f_args;
 			overloads := cf :: !overloads;
 			ctx.type_params <- old;
@@ -671,7 +671,7 @@ and init_meta_overloads ctx co cf =
 			add_class_field_flag cf CfOverload;
 			let topt (n,_,t) = match t with | TMono t when t.tm_type = None -> error ("Explicit type required for overload functions\n... For function argument '" ^ n ^ "'") cf.cf_pos | _ -> () in
 			(match follow cf.cf_type with
-			| TFun (args,_) -> List.iter topt args
+			| TFun (args,_,_) -> List.iter topt args
 			| _ -> () (* could be a variable *));
 			true
 		| (Meta.Overload,[],p) ->
@@ -894,7 +894,11 @@ let init_core_api ctx c =
 				error ("Field " ^ f.cf_name ^ " has different property access than core type") p;
 		end;
 		(match follow f.cf_type, follow f2.cf_type with
-		| TFun (pl1,_), TFun (pl2,_) ->
+		| TFun (pl1,_,coro1), TFun (pl2,_,coro2) ->
+			if coro1 then begin
+				if not coro2 then error "Method should be coroutine" p
+			end else if coro2 then
+				error "Method should not be coroutine" p;
 			if List.length pl1 != List.length pl2 then error "Argument count mismatch" p;
 			List.iter2 (fun (n1,_,_) (n2,_,_) ->
 				if n1 <> n2 then error ("Method parameter name '" ^ n2 ^ "' should be '" ^ n1 ^ "'") p;

+ 7 - 3
src/typing/typeloadCheck.ml

@@ -93,7 +93,11 @@ let valid_redefinition ctx f1 t1 f2 t2 = (* child, parent *)
 	match f1.cf_kind,f2.cf_kind with
 	| Method m1, Method m2 when not (m1 = MethDynamic) && not (m2 = MethDynamic) ->
 		begin match follow t1, follow t2 with
-		| TFun (args1,r1) , TFun (args2,r2) -> (
+		| TFun (args1,r1,coro1) , TFun (args2,r2,coro2) -> (
+			if coro1 then begin
+				if not coro2 then raise (Unify_error [Unify_custom "Method should be coroutine"])
+			end else if coro2 then
+				if not coro2 then raise (Unify_error [Unify_custom "Method should not be coroutine"]);
 			if not (List.length args1 = List.length args2) then raise (Unify_error [Unify_custom "Different number of function arguments"]);
 			let i = ref 0 in
 			try
@@ -400,7 +404,7 @@ module Inheritance = struct
 					else begin
 						let msg = if !is_overload then
 							let ctx = print_context() in
-							let args = match follow f.cf_type with | TFun(args,_) -> String.concat ", " (List.map (fun (n,o,t) -> (if o then "?" else "") ^ n ^ " : " ^ (s_type ctx t)) args) | _ -> die "" __LOC__ in
+							let args = match follow f.cf_type with | TFun(args,_,_) -> String.concat ", " (List.map (fun (n,o,t) -> (if o then "?" else "") ^ n ^ " : " ^ (s_type ctx t)) args) | _ -> die "" __LOC__ in
 							"No suitable overload for " ^ i ^ "( " ^ args ^ " ), as needed by " ^ s_type_path intf.cl_path ^ " was found"
 						else
 							("Field " ^ i ^ " needed by " ^ s_type_path intf.cl_path ^ " is missing")
@@ -477,7 +481,7 @@ module Inheritance = struct
 			let pctx = print_context() in
 			List.iter (fun (cf,_) ->
 				let s = match follow cf.cf_type with
-					| TFun(tl,tr) ->
+					| TFun(tl,tr,_) ->
 						String.concat ", " (List.map (fun (n,o,t) -> Printf.sprintf "%s:%s" n (s_type pctx t)) tl)
 					| t ->
 						s_type pctx t

+ 12 - 12
src/typing/typeloadFields.ml

@@ -223,7 +223,7 @@ let ensure_struct_init_constructor ctx c ast_fields p =
 			tf_type = ctx.t.tvoid;
 			tf_expr = mk (TBlock el) ctx.t.tvoid p
 		} in
-		let e = mk (TFunction tf) (TFun(tl @ super_tl,ctx.t.tvoid)) p in
+		let e = mk (TFunction tf) (TFun(tl @ super_tl,ctx.t.tvoid,false)) p in
 		let cf = mk_field "new" e.etype p null_pos in
 		cf.cf_doc <- doc_from_string (Buffer.contents doc_buf);
 		cf.cf_expr <- Some e;
@@ -736,7 +736,7 @@ module TypeBinding = struct
 		let c = cctx.tclass in
 		let rec is_full_type t =
 			match t with
-			| TFun (args,ret) -> is_full_type ret && List.for_all (fun (_,_,t) -> is_full_type t) args
+			| TFun (args,ret,_) -> is_full_type ret && List.for_all (fun (_,_,t) -> is_full_type t) args
 			| TMono r -> (match r.tm_type with None -> false | Some t -> is_full_type t)
 			| TAbstract _ | TInst _ | TEnum _ | TLazy _ | TDynamic _ | TAnon _ | TType _ -> true
 		in
@@ -1024,7 +1024,7 @@ let check_abstract (ctx,cctx,fctx) c cf fd t ret p =
 						(* the return type of a from-function must be the abstract, not the underlying type *)
 						if not fctx.is_macro then (try type_eq EqStrict ret ta with Unify_error l -> error (error_msg (Unify l)) p);
 						match t with
-							| TFun([_,_,t],_) -> t
+							| TFun([_,_,t],_,corotodo) -> t
 							| _ -> error (cf.cf_name ^ ": @:from cast functions must accept exactly one argument") p
 					) "@:from" in
 					a.a_from_field <- (TLazy r,cf) :: a.a_from_field;
@@ -1033,10 +1033,10 @@ let check_abstract (ctx,cctx,fctx) c cf fd t ret p =
 					(match cf.cf_kind, cf.cf_type with
 					| Var _, _ ->
 						error "@:to meta should be used on methods" p
-					| Method _, TFun(args, _) when not fctx.is_abstract_member && List.length args <> 1 ->
+					| Method _, TFun(args, _, corotodo) when not fctx.is_abstract_member && List.length args <> 1 ->
 						if not (Meta.has Meta.MultiType a.a_meta) then (* TODO: get rid of this check once multitype is removed *)
 						error ("static @:to method should have one argument") p
-					| Method _, TFun(args, _) when fctx.is_abstract_member && List.length args <> 1 ->
+					| Method _, TFun(args, _, corotodo) when fctx.is_abstract_member && List.length args <> 1 ->
 						if not (Meta.has Meta.MultiType a.a_meta) then (* TODO: get rid of this check once multitype is removed *)
 						error "@:to method should have no arguments" p
 					| _ -> ()
@@ -1046,7 +1046,7 @@ let check_abstract (ctx,cctx,fctx) c cf fd t ret p =
 					let resolve_m args =
 						(try unify_raise ctx t (tfun (tthis :: args) m) cf.cf_pos with Error (Unify l,p) -> error (error_msg (Unify l)) p);
 						match follow m with
-							| TMono _ when (match t with TFun(_,r) -> r == t_dynamic | _ -> false) -> t_dynamic
+							| TMono _ when (match t with TFun(_,r,_) -> r == t_dynamic | _ -> false) -> t_dynamic
 							| m -> m
 					in
 					let r = exc_protect ctx (fun r ->
@@ -1059,7 +1059,7 @@ let check_abstract (ctx,cctx,fctx) c cf fd t ret p =
 							in
 							(* delay ctx PFinal (fun () -> unify ctx m tthis f.cff_pos); *)
 							let args = match follow (monomorphs a.a_params ctor.cf_type) with
-								| TFun(args,_) -> List.map (fun (_,_,t) -> t) args
+								| TFun(args,_,_) -> List.map (fun (_,_,t) -> t) args
 								| _ -> die "" __LOC__
 							in
 							args
@@ -1082,7 +1082,7 @@ let check_abstract (ctx,cctx,fctx) c cf fd t ret p =
 					if fctx.is_macro then error (cf.cf_name ^ ": Macro operator functions are not supported") p;
 					let targ = if fctx.is_abstract_member then tthis else ta in
 					let left_eq,right_eq = match follow t with
-						| TFun([(_,_,t1);(_,_,t2)],_) ->
+						| TFun([(_,_,t1);(_,_,t2)],_,corotodo) ->
 							type_iseq targ t1,type_iseq targ t2
 						| _ ->
 							if fctx.is_abstract_member then
@@ -1117,11 +1117,11 @@ let check_abstract (ctx,cctx,fctx) c cf fd t ret p =
 						end
 					in
 					begin match follow t with
-						| TFun([(_,_,t1);(_,_,t2)],_) ->
+						| TFun([(_,_,t1);(_,_,t2)],_,corotodo) ->
 							if a.a_read <> None then error "Multiple resolve-read methods are not supported" cf.cf_pos;
 							check_fun t1 t2;
 							a.a_read <- Some cf;
-						| TFun([(_,_,t1);(_,_,t2);(_,_,t3)],_) ->
+						| TFun([(_,_,t1);(_,_,t2);(_,_,t3)],_,corotodo) ->
 							if a.a_write <> None then error "Multiple resolve-write methods are not supported" cf.cf_pos;
 							check_fun t1 t2;
 							a.a_write <- Some cf;
@@ -1229,7 +1229,7 @@ let create_method (ctx,cctx,fctx) c f fd p =
 	let is_extern = fctx.is_extern || has_class_flag ctx.curclass CExtern in
 	let type_arg opt t p = FunctionArguments.type_opt ctx cctx.is_core_api fctx.is_abstract p t in
 	let args = new FunctionArguments.function_arguments ctx type_arg is_extern fctx.is_display_field abstract_this fd.f_args in
-	let t = TFun (args#for_type,ret) in
+	let t = TFun (args#for_type,ret,false) in
 	let cf = {
 		(mk_field (fst f.cff_name) ~public:(is_public (ctx,cctx) f.cff_access parent) t f.cff_pos (pos f.cff_name)) with
 		cf_doc = f.cff_doc;
@@ -1303,7 +1303,7 @@ let create_property (ctx,cctx,fctx) c f (get,set,t,eo) p =
 			if Meta.has Meta.IsVar f.cff_meta then error (name ^ ": Abstract properties cannot be real variables") f.cff_pos;
 			let ta = apply_params a.a_params (List.map snd a.a_params) a.a_this in
 			tfun [ta] ret, tfun [ta;ret] ret
-		| _ -> tfun [] ret, TFun(["value",false,ret],ret)
+		| _ -> tfun [] ret, TFun(["value",false,ret],ret,false)
 	in
 	let find_accessor m =
 		if fctx.is_static then begin

+ 2 - 2
src/typing/typeloadFunction.ml

@@ -221,7 +221,7 @@ let add_constructor ctx c force_constructor p =
 				| _ ->
 					let values = get_value_meta cfsup.cf_meta in
 					match follow cfsup.cf_type with
-					| TFun (args,_) ->
+					| TFun (args,_,_) ->
 						List.map (fun (n,o,t) ->
 							let def = try
 								type_function_arg_value ctx t (Some (PMap.find n values)) false
@@ -239,7 +239,7 @@ let add_constructor ctx c force_constructor p =
 				tf_args = vars;
 				tf_type = ctx.t.tvoid;
 				tf_expr = super_call;
-			}) (TFun (List.map (fun (v,c) -> v.v_name, c <> None, v.v_type) vars,ctx.t.tvoid)) p in
+			}) (TFun (List.map (fun (v,c) -> v.v_name, c <> None, v.v_type) vars,ctx.t.tvoid,false)) p in
 			cf.cf_expr <- Some constr;
 			cf.cf_type <- t;
 			unify ctx t constr.etype p;

+ 1 - 1
src/typing/typeloadModule.ml

@@ -438,7 +438,7 @@ let load_enum_field ctx e et is_flat index c =
 				if PMap.mem s (!pnames) then error ("Duplicate argument `" ^ s ^ "` in enum constructor " ^ fst c.ec_name) p;
 				pnames := PMap.add s () (!pnames);
 				s, opt, load_type_hint ~opt ctx p (Some (t,tp))
-			) l, rt)
+			) l, rt, false)
 	) in
 	let f = {
 		ef_name = fst c.ec_name;

+ 1 - 1
src/typing/typeloadParse.ml

@@ -175,7 +175,7 @@ module ConditionDisplay = struct
 		let check_expr (e,p) =
 			match e with
 				| ECall ((EConst (Ident "version"),p),_)  ->
-					let t = TFun ([("s",false,com.basic.tstring)],t_semver) in
+					let t = TFun ([("s",false,com.basic.tstring)],t_semver,false) in
 					if check_position p then
 						DisplayException.raise_hover (CompletionItem.make_ci_class_field {
 							field = {

+ 11 - 11
src/typing/typer.ml

@@ -41,7 +41,7 @@ let get_iterator_param t =
 	| TAnon a ->
 		if !(a.a_status) <> Closed then raise Not_found;
 		(match follow (PMap.find "hasNext" a.a_fields).cf_type, follow (PMap.find "next" a.a_fields).cf_type with
-		| TFun ([],tb), TFun([],t) when (match follow tb with TAbstract ({ a_path = [],"Bool" },[]) -> true | _ -> false) ->
+		| TFun ([],tb,_), TFun([],t,_) when (match follow tb with TAbstract ({ a_path = [],"Bool" },[]) -> true | _ -> false) ->
 			if PMap.fold (fun _ acc -> acc + 1) a.a_fields 0 <> 2 then raise Not_found;
 			t
 		| _ ->
@@ -54,7 +54,7 @@ let get_iterable_param t =
 	| TAnon a ->
 		if !(a.a_status) <> Closed then raise Not_found;
 		(match follow (PMap.find "iterator" a.a_fields).cf_type with
-		| TFun ([],it) ->
+		| TFun ([],it,_) ->
 			let t = get_iterator_param it in
 			if PMap.fold (fun _ acc -> acc + 1) a.a_fields 0 <> 1 then raise Not_found;
 			t
@@ -103,7 +103,7 @@ let maybe_type_against_enum ctx f with_type iscall p =
 			begin match e with
 				| AKExpr e ->
 					begin match follow e.etype with
-						| TFun(_,t') when is_enum ->
+						| TFun(_,t',_) when is_enum ->
 							(* TODO: this is a dodge for #7603 *)
 							(try Type.unify t' t with Unify_error _ -> ());
 							AKExpr e
@@ -197,14 +197,14 @@ let rec unify_min_raise ctx (el:texpr list) : t =
 				| _ -> raise Exit
 			in
 			let args,tr0 = match follow e0.etype with
-				| TFun(tl,tr) ->
+				| TFun(tl,tr,_) ->
 					Array.of_list tl,tr
 				| _ ->
 					raise Exit
 			in
 			let arity = Array.length args in
 			let rets = List.map (fun e -> match follow e.etype with
-				| TFun(tl,tr) ->
+				| TFun(tl,tr,_) ->
 					let ta = Array.of_list tl in
 					if Array.length ta <> arity then raise Exit;
 					for i = 0 to arity - 1 do
@@ -226,7 +226,7 @@ let rec unify_min_raise ctx (el:texpr list) : t =
 			| UnifyMinError(l,index) ->
 				raise Exit
 			in
-			TFun(Array.to_list args,tr)
+			TFun(Array.to_list args,tr,false (* corotodo *))
 		with Exit ->
 			(* Second pass: Get all base types (interfaces, super classes and their interfaces) of most general type.
 			   Then for each additional type filter all types that do not unify. *)
@@ -563,7 +563,7 @@ and type_access ctx e p mode with_type =
 				let cf = fa.fa_field in
 				no_abstract_constructor c p;
 				check_constructor_access ctx c cf p;
-				let args = match follow (FieldAccess.get_map_function fa cf.cf_type) with TFun(args,ret) -> args | _ -> die "" __LOC__ in
+				let args = match follow (FieldAccess.get_map_function fa cf.cf_type) with TFun(args,ret,_) -> args | _ -> die "" __LOC__ in
 				let vl = List.map (fun (n,_,t) -> alloc_var VGenerated n t c.cl_pos) args in
 				let vexpr v = mk (TLocal v) v.v_type p in
 				let el = List.map vexpr vl in
@@ -583,7 +583,7 @@ and type_access ctx e p mode with_type =
 					tf_args = List.map (fun v -> v,None) vl;
 					tf_type = t;
 					tf_expr = mk (TReturn (Some ec)) t p;
-				}) (TFun ((List.map (fun v -> v.v_name,false,v.v_type) vl),t)) p)
+				}) (TFun ((List.map (fun v -> v.v_name,false,v.v_type) vl),t,false)) p)
 			| _ -> error "Binding new is only allowed on class types" p
 		end;
 	| EField _ ->
@@ -864,7 +864,7 @@ and type_object_decl ctx fl with_type p =
 		let fa = FieldAccess.get_constructor_access c tl p in
 		let ctor = fa.fa_field in
 		let args = match follow (FieldAccess.get_map_function fa ctor.cf_type) with
-			| TFun(args,_) -> args
+			| TFun(args,_,_) -> args
 			| _ -> die "" __LOC__
 		in
 		let fields = List.fold_left (fun acc (n,opt,t) ->
@@ -1189,7 +1189,7 @@ and type_local_function ctx kind f with_type p =
 	| WithType.WithType(t,_) ->
 		let rec loop t =
 			(match follow t with
-			| TFun (args2,tr) when List.length args2 = List.length targs ->
+			| TFun (args2,tr,corotodo) when List.length args2 = List.length targs ->
 				List.iter2 (fun (_,_,t1) (_,_,t2) ->
 					match follow t1 with
 					| TMono _ -> unify ctx t2 t1 p
@@ -1211,7 +1211,7 @@ and type_local_function ctx kind f with_type p =
 		if name = None then display_error ctx "Unnamed lvalue functions are not supported" p
 	| _ ->
 		());
-	let ft = TFun (targs,rt) in
+	let ft = TFun (targs,rt,false (* corotodo*)) in
 	let v = (match v with
 		| None -> None
 		| Some v ->

+ 2 - 2
src/typing/typerBase.ml

@@ -150,7 +150,7 @@ let s_access_kind acc =
 
 let get_constructible_constraint ctx tl p =
 	let extract_function t = match follow t with
-		| TFun(tl,tr) -> tl,tr
+		| TFun(tl,tr,_) -> tl,tr
 		| _ -> error "Constructible type parameter should be function" p
 	in
 	let rec loop tl = match tl with
@@ -195,7 +195,7 @@ let get_abstract_froms a pl =
 	let l = List.map (apply_params a.a_params pl) a.a_from in
 	List.fold_left (fun acc (t,f) ->
 		match follow (Type.field_type f) with
-		| TFun ([_,_,v],t) ->
+		| TFun ([_,_,v],t,_) ->
 			(try
 				ignore(type_eq EqStrict t (TAbstract(a,List.map duplicate pl))); (* unify fields monomorphs *)
 				v :: acc

+ 12 - 12
src/typing/typerDisplay.ml

@@ -20,8 +20,8 @@ open Calls
 open Error
 open FieldAccess
 
-let convert_function_signature ctx values (args,ret) = match CompletionType.from_type (get_import_status ctx) ~values (TFun(args,ret)) with
-	| CompletionType.CTFunction ctf -> ((args,ret),ctf)
+let convert_function_signature ctx values (args,ret,coro) = match CompletionType.from_type (get_import_status ctx) ~values (TFun(args,ret,coro)) with
+	| CompletionType.CTFunction ctf -> ((args,ret,coro),ctf)
 	| _ -> die "" __LOC__
 
 let completion_item_of_expr ctx e =
@@ -125,7 +125,7 @@ let completion_item_of_expr ctx e =
 				let fcc = unify_field_call ctx fa el [] e.epos false in
 				let cf = fcc.fc_field in
 				let t = match follow (FieldAccess.get_map_function fa cf.cf_type) with
-					| TFun(args,_) -> TFun(args,TInst(c,tl))
+					| TFun(args,_,coro) -> TFun(args,TInst(c,tl),coro)
 					| t -> t
 				in
 				make_ci_class_field (CompletionClassField.make cf CFSConstructor (Self (decl_of_class c)) true) (tpair ~values:(get_value_meta cf.cf_meta) t)
@@ -172,9 +172,9 @@ let display_dollar_type ctx p make_type =
 	let arg = ["expression",false,mono] in
 	begin match ctx.com.display.dms_kind with
 	| DMSignature ->
-		raise_signatures [(convert_function_signature ctx PMap.empty (arg,mono),doc)] 0 0 SKCall
+		raise_signatures [(convert_function_signature ctx PMap.empty (arg,mono,false),doc)] 0 0 SKCall
 	| DMHover ->
-		let t = TFun(arg,mono) in
+		let t = TFun(arg,mono,false) in
 		raise_hover (make_ci_expr (mk (TIdent "trace") t p) (make_type t)) (Some (WithType.named_argument "expression")) p
 	| DMDefinition | DMTypeDefinition ->
 		raise_positions []
@@ -188,7 +188,7 @@ let rec handle_signature_display ctx e_ast with_type =
 	let handle_call tl el p0 =
 		let rec follow_with_callable (t,doc,values) = match follow t with
 			| TAbstract(a,tl) when Meta.has Meta.Callable a.a_meta -> follow_with_callable (Abstract.get_underlying_type a tl,doc,values)
-			| TFun(args,ret) -> ((args,ret),doc,values)
+			| TFun(args,ret,coro) -> ((args,ret,coro),doc,values)
 			| _ -> error ("Not a callable type: " ^ (s_type (print_context()) t)) p
 		in
 		let tl = List.map follow_with_callable tl in
@@ -207,7 +207,7 @@ let rec handle_signature_display ctx e_ast with_type =
 		let el = if el <> [] && display_arg >= List.length el then el @ [EConst (Ident "null"),null_pos] else el in
 		let rec loop acc tl = match tl with
 			| (t,doc,values) :: tl ->
-				let keep (args,r) =
+				let keep (args,r,coro) =
 					begin try
 						let _ = unify_call_args ctx el args r p false false false in
 						true
@@ -291,19 +291,19 @@ let rec handle_signature_display ctx e_ast with_type =
 			let e1 = type_expr ctx e1 WithType.value in
 			begin match follow e1.etype with
 			| TInst({cl_path=([],"Array")},[t]) ->
-				let res = convert_function_signature ctx PMap.empty (["index",false,ctx.t.tint],t) in
+				let res = convert_function_signature ctx PMap.empty (["index",false,ctx.t.tint],t,false) in
 				raise_signatures [res,doc_from_string "The array index"] 0 0 SKCall
 			| TAbstract(a,tl) ->
 				(match a.a_impl with Some c -> ignore(c.cl_build()) | _ -> ());
 				let sigs = ExtList.List.filter_map (fun cf -> match follow cf.cf_type with
-					| TFun(_ :: args,r) ->
+					| TFun(_ :: args,r,coro) ->
 						if ExtType.is_void (follow r) && (match with_type with WithType.NoValue -> false | _ -> true) then
 							None
 						else begin
 							let map = apply_params a.a_params tl in
 							let tl = List.map (fun (n,o,t) -> n,o,map t) args in
 							let r = map r in
-							Some (convert_function_signature ctx PMap.empty (tl,r),cf.cf_doc)
+							Some (convert_function_signature ctx PMap.empty (tl,r,coro),cf.cf_doc)
 						end
 					| _ ->
 						None
@@ -550,9 +550,9 @@ let handle_display ctx e_ast dk mode with_type =
 		let p = pos e_ast in
 		begin match ctx.com.display.dms_kind with
 		| DMSignature ->
-			raise_signatures [(convert_function_signature ctx PMap.empty (arg,ret),doc)] 0 0 SKCall
+			raise_signatures [(convert_function_signature ctx PMap.empty (arg,ret,false),doc)] 0 0 SKCall
 		| DMHover ->
-			let t = TFun(arg,ret) in
+			let t = TFun(arg,ret,false) in
 			raise_hover (make_ci_expr (mk (TIdent "trace") t p) (tpair t)) (Some (WithType.named_argument "value")) p
 		| DMDefinition | DMTypeDefinition ->
 			raise_positions []

+ 1 - 1
std/haxe/macro/Type.hx

@@ -75,7 +75,7 @@ enum Type {
 
 		@see https://haxe.org/manual/types-function.html
 	**/
-	TFun(args:Array<{name:String, opt:Bool, t:Type}>, ret:Type);
+	TFun(args:Array<{name:String, opt:Bool, t:Type}>, ret:Type, ?coroutine:Bool);
 
 	/**
 		Represents an anonymous structure type.