Преглед на файлове

take off Const flag when inlining (closes #4086)

Simon Krajewski преди 10 години
родител
ревизия
830e34496b
променени са 2 файла, в които са добавени 24 реда и са изтрити 13 реда
  1. 7 13
      optimizer.ml
  2. 17 0
      tests/unit/src/unit/issues/Issue4086.hx

+ 7 - 13
optimizer.ml

@@ -462,20 +462,14 @@ let rec type_inline ctx cf f ethis params tret config p ?(self_calling_closure=f
 			l.i_write <- true;
 			let e2 = map false e2 in
 			{e with eexpr = TBinop(op,{e1 with eexpr = TLocal l.i_subst},e2)}
-(* 		| TCall({eexpr = TLocal v} as e1,el) ->
-			let el = List.map (map false) el in
-			let l = read_local v in
-			let edef() = {e with eexpr = TCall({e1 with eexpr = TLocal l.i_subst},el)} in
-			begin try
-				begin match List.assq l inlined_vars with
-				| {eexpr = TField(_, (FStatic(_,cf) | FInstance(_,_,cf)))} as e' when cf.cf_kind = Method MethInline ->
-					make_call ctx e' el e.etype e.epos
+		| TObjectDecl fl ->
+			let fl = List.map (fun (s,e) -> s,map false e) fl in
+			begin match follow e.etype with
+				| TAnon an when (match !(an.a_status) with Const -> true | _ -> false) ->
+					{e with eexpr = TObjectDecl fl; etype = TAnon { an with a_status = ref Closed}}
 				| _ ->
-					edef()
-				end
-			with Not_found ->
-				edef()
-			end *)
+					{e with eexpr = TObjectDecl fl}
+			end
 		| TFunction f ->
 			(match f.tf_args with [] -> () | _ -> has_vars := true);
 			let old = save_locals ctx and old_fun = !in_local_fun in

+ 17 - 0
tests/unit/src/unit/issues/Issue4086.hx

@@ -0,0 +1,17 @@
+package unit.issues;
+
+private typedef GroceryItem = { name: String }
+private typedef FruitItem = { name: String, count: Int };
+
+class Issue4086 extends Test {
+	function test() {
+		check(apply3("apple", 5));
+	}
+
+	static function check(item:GroceryItem) { }
+
+	static inline function apply3(name: String, count: Int): FruitItem {
+		return { name: name, count: count };
+	}
+
+}