Преглед изворни кода

[cs] Check if field is not hxgen before transforming it into an operator

* Ref: #5110
Cauê Waneck пре 9 година
родитељ
комит
2ada31eb2a
2 измењених фајлова са 26 додато и 2 уклоњено
  1. 8 2
      src/generators/gencs.ml
  2. 18 0
      tests/unit/src/unit/issues/Issue5110.hx.disabled

+ 8 - 2
src/generators/gencs.ml

@@ -1236,6 +1236,12 @@ let configure gen =
 		List.rev !ret
 		List.rev !ret
 	in
 	in
 
 
+	let field_hxgen f = match f with
+		| FInstance(c,_,_) | FStatic(c,_) ->
+			is_hxgen (TClassDecl c)
+		| _ -> true (* dynamic, etc will be considered hxgen *)
+	in
+
 	let expr_s w e =
 	let expr_s w e =
 		last_line := -1;
 		last_line := -1;
 		in_value := false;
 		in_value := false;
@@ -1243,7 +1249,7 @@ let configure gen =
 			let was_in_value = !in_value in
 			let was_in_value = !in_value in
 			in_value := true;
 			in_value := true;
 			(match e.eexpr with
 			(match e.eexpr with
-				| TCall({ eexpr = TField(ef,f) }, (_ :: _ as args) ) when (field_name f) = "get_Item" ->
+				| TCall({ eexpr = TField(ef,f) }, (_ :: _ as args) ) when field_hxgen f && (field_name f) = "get_Item" ->
 					expr_s w ef;
 					expr_s w ef;
 					write w "[";
 					write w "[";
 					let first = ref true in
 					let first = ref true in
@@ -1252,7 +1258,7 @@ let configure gen =
 						expr_s w f
 						expr_s w f
 					) args;
 					) args;
 					write w "]"
 					write w "]"
-				| TCall({ eexpr = TField(ef,f) }, (_ :: _ :: _ as args) ) when (field_name f) = "set_Item" ->
+				| TCall({ eexpr = TField(ef,f) }, (_ :: _ :: _ as args) ) when field_hxgen f && (field_name f) = "set_Item" ->
 					expr_s w ef;
 					expr_s w ef;
 					write w "[";
 					write w "[";
 					let args, value = match List.rev args with
 					let args, value = match List.rev args with

+ 18 - 0
tests/unit/src/unit/issues/Issue5110.hx.disabled

@@ -0,0 +1,18 @@
+package unit.issues;
+
+class Issue5110 extends Test {
+	public function test() {
+#if cs
+		var lst:List<Int> = cast new cs.system.collections.generic.List_1<Int>();
+		eq(lst.get_Item(0), 0);
+#end
+	}
+}
+
+#if cs
+private abstract List<T>(cs.system.collections.generic.List_1<T>) {
+    public function get_Item(n:Int):T {
+        return this.get_Item(n);
+    }
+}
+#end