فهرست منبع

Revert "[inliner] don't inline TFunction multiple times"

This reverts commit 11186ef2381c7671a6db4ff9c8126f3e6c259bb2.
Dan Korostelev 7 سال پیش
والد
کامیت
fbbbf217fb
2فایلهای تغییر یافته به همراه7 افزوده شده و 7 حذف شده
  1. 1 1
      src/optimization/optimizer.ml
  2. 6 6
      tests/optimization/src/TestJs.hx

+ 1 - 1
src/optimization/optimizer.ml

@@ -547,7 +547,7 @@ let rec type_inline ctx cf f ethis params tret config p ?(self_calling_closure=f
 		let flag = not i.i_force_temp && (match e.eexpr with
 			| TLocal _ when i.i_abstract_this -> true
 			| TLocal _ | TConst _ -> not i.i_write
-			| TFunction _ -> if i.i_write then error "Cannot modify a closure parameter inside inline method" p; i.i_read <= 1
+			| TFunction _ -> if i.i_write then error "Cannot modify a closure parameter inside inline method" p; true
 			| _ -> not i.i_write && i.i_read <= 1
 		) in
 		let flag = flag && (not i.i_captured || is_constant e) in

+ 6 - 6
tests/optimization/src/TestJs.hx

@@ -84,12 +84,12 @@ class TestJs {
 		}) {}
 	}
 
-	// @:js('var a = [1,2,3];var _g = 0;while(_g < a.length) {var v = a[_g];++_g;TestJs.use(v + 2);}')
-	// static function testInlineFunctionWithAnonymousCallback() {
-	// 	var a = [1,2,3];
-	// 	inline function forEach(f) for (v in a) f(v);
-	// 	forEach(function(x) use(x + 2));
-	// }
+	@:js('var a = [1,2,3];var _g = 0;while(_g < a.length) {var v = a[_g];++_g;TestJs.use(v + 2);}')
+	static function testInlineFunctionWithAnonymousCallback() {
+		var a = [1,2,3];
+		inline function forEach(f) for (v in a) f(v);
+		forEach(function(x) use(x + 2));
+	}
 
 	@:js('var a = "";var e;var _hx_tmp = a.toLowerCase();if(_hx_tmp == "e") {e = 0;} else {throw new Error();}')
 	@:analyzer(no_const_propagation, no_local_dce, no_copy_propagation)