Selaa lähdekoodia

[python] generate AnonObject when metadata exists (closes #4422)

Simon Krajewski 9 vuotta sitten
vanhempi
commit
407e62ce7d
2 muutettua tiedostoa jossa 3 lisäystä ja 2 poistoa
  1. 1 0
      filters.ml
  2. 2 2
      genpy.ml

+ 1 - 0
filters.ml

@@ -1067,6 +1067,7 @@ let add_meta_field ctx t = match t with
 		(match Codegen.build_metadata ctx.com t with
 		| None -> ()
 		| Some e ->
+			add_feature ctx.com "has_metadata";
 			let f = mk_field "__meta__" t_dynamic c.cl_pos in
 			f.cf_expr <- Some e;
 			let can_deal_with_interface_metadata () = match ctx.com.platform with

+ 2 - 2
genpy.ml

@@ -2378,8 +2378,8 @@ module Generator = struct
 			Utils.find_type ctx.com path
 		in
 		let need_anon_for_trace = (has_feature ctx "has_anon_trace") && (has_feature ctx "haxe.Log.trace") in
-		if (has_feature ctx "has_anon") || (has_feature ctx "_hx_AnonObject") || need_anon_for_trace then begin
-			let with_body = (has_feature ctx "has_anon") || need_anon_for_trace in
+		if (has_feature ctx "has_anon") || (has_feature ctx "_hx_AnonObject") || (has_feature ctx "has_metadata") || need_anon_for_trace then begin
+			let with_body = (has_feature ctx "has_anon") || (has_feature ctx "has_metadata") || need_anon_for_trace in
 			newline ctx;
 			newline ctx;
 			newline ctx;