Browse Source

don't error on shadowing @:generic function
#8393

Aleksandr Kuzmenko 6 years ago
parent
commit
f1f8805a48

+ 7 - 2
src/typing/calls.ml

@@ -378,10 +378,15 @@ let type_generic_function ctx (e,fa) el ?(using_param=None) with_type p =
 				unify_existing_field cf2.cf_type cf2.cf_pos;
 				cf2
 			in
-			if cf.cf_name_pos = cf2.cf_name_pos then
+			cf2
+			(*
+				java.Lib.array() relies on the ability to shadow @:generic function for certain types
+				see https://github.com/HaxeFoundation/haxe/issues/8393#issuecomment-508685760
+			*)
+			(* if cf.cf_name_pos = cf2.cf_name_pos then
 				cf2
 			else
-				error ("Cannot specialize @:generic because the generated function name is already used: " ^ name) p
+				error ("Cannot specialize @:generic because the generated function name is already used: " ^ name) p *)
 		with Not_found ->
 			let cf2 = mk_field name (map_monos cf.cf_type) cf.cf_pos cf.cf_name_pos in
 			if stat then begin

+ 0 - 1
tests/misc/projects/Issue8393/compile2-fail.hxml

@@ -1 +0,0 @@
--main Main2

+ 2 - 0
tests/misc/projects/Issue8393/compile2-fail.hxml.disabled

@@ -0,0 +1,2 @@
+# Disabled because of https://github.com/HaxeFoundation/haxe/issues/8393#issuecomment-508685760
+-main Main2