Browse Source

run it on eval too

Simon Krajewski 1 year ago
parent
commit
0ff8e299dd
4 changed files with 12 additions and 7 deletions
  1. 5 5
      src/codegen/codegen.ml
  2. 1 2
      std/StdTypes.hx
  3. 2 0
      tests/misc/coroutines/build-eval.hxml
  4. 4 0
      tests/runci/targets/Macro.hx

+ 5 - 5
src/codegen/codegen.ml

@@ -101,10 +101,9 @@ let rec find_field com c f =
 		f
 
 let fix_override com c f fd =
-	let f2 = (try Some (find_field com c f) with Not_found -> None) 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 f2 = find_field com c f in
+	match follow f2.cf_type,fd with
+		| TFun(targs,tret), Some(fd) ->
 			let changed_args = ref [] in
 			let prefix = "_tmp_" in
 			let nargs = List.map2 (fun ((v,ct) as cur) (_,_,t2) ->
@@ -148,13 +147,14 @@ let fix_override com c f fd =
 			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);
-		| Some(f2), None when (has_class_flag c CInterface) ->
+		| _, 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 fix_overrides com t =
+	let fix_override com c f fd = try fix_override com c f fd with Not_found -> () in
 	match t with
 	| TClassDecl c ->
 		(* overrides can be removed from interfaces *)

+ 1 - 2
std/StdTypes.hx

@@ -181,10 +181,9 @@ abstract Coroutine<T:haxe.Constraints.Function> {
 		for resuming coroutine execution.
 	**/
 	@:coroutine
-	#if jvm overload #end
 	public static extern function suspend<T>(f:(cont:(T, Null<Dynamic>) -> Void)->Void):T;
 
-	#if jvm
+	#if (jvm || eval)
 	@:native("suspend")
 	@:ifFeature("_StdTypes.Coroutine_Impl_.suspend")
 	static function nativeSuspend<T>(f, cont:(T, Null<Dynamic>) -> Void) {

+ 2 - 0
tests/misc/coroutines/build-eval.hxml

@@ -0,0 +1,2 @@
+build-base.hxml
+--interp

+ 4 - 0
tests/runci/targets/Macro.hx

@@ -8,6 +8,10 @@ class Macro {
 		runCommand("haxe", ["compile-macro.hxml", "--hxb", "bin/hxb/eval.zip"].concat(args));
 		runCommand("haxe", ["compile-macro.hxml", "--hxb-lib", "bin/hxb/eval.zip"].concat(args));
 
+		infoMsg("Test coroutines:");
+		changeDirectory(getMiscSubDir("coroutines"));
+		runCommand("haxe", ["build-eval.hxml"]);
+
 		changeDirectory(displayDir);
 		haxelibInstallGit("Simn", "haxeserver");
 		runCommand("haxe", ["build.hxml", "-D", "display.protocol=xml"]);