Sfoglia il codice sorgente

[java/cs] Reflect.field shouldn't call _f counterparts on dynamic/anonymous types. Closes #3466

Cauê Waneck 11 anni fa
parent
commit
3af311ba98
2 ha cambiato i file con 12 aggiunte e 1 eliminazioni
  1. 5 1
      gencommon.ml
  2. 7 0
      tests/unit/src/unit/issues/Issue3466.hx

+ 5 - 1
gencommon.ml

@@ -2496,7 +2496,11 @@ struct
 					{ eexpr = TField(_, FStatic({ cl_path = ([], "Reflect") }, { cf_name = "field" })) } ,
 						[obj; { eexpr = TConst(TString(field)) }]
 					) ->
-					change_expr (mk_field_access gen obj field obj.epos) (run obj) field None false
+					let t = match gen.greal_type obj.etype with
+						| TDynamic _ | TAnon _ | TMono _ -> t_dynamic
+						| t -> t
+					in
+					change_expr (mk_field_access gen { obj with etype = t } field obj.epos) (run obj) field None false
 				| TCall(
 					{ eexpr = TField(_, FStatic({ cl_path = ([], "Reflect") }, { cf_name = "setField" } )) },
 						[obj; { eexpr = TConst(TString(field)) }; evalue]

+ 7 - 0
tests/unit/src/unit/issues/Issue3466.hx

@@ -0,0 +1,7 @@
+package unit.issues;
+
+class Issue3466 extends Test {
+function test() {
+	var d:Dynamic<Int> = {};
+	eq(null, Reflect.field(d,'someField'));
+}