Procházet zdrojové kódy

[jvm] consider haxe.extern.Rest when finding overloads

closes #9220
Simon Krajewski před 5 roky
rodič
revize
235d1b99df

+ 11 - 2
src/generators/genshared.ml

@@ -20,12 +20,21 @@ let unify_cf map_type c cf el =
 	match follow (apply_params cf.cf_params monos (map_type cf.cf_type)) with
 		| TFun(tl'',_) as tf ->
 			let rec loop2 acc el tl = match el,tl with
-				| e :: el,(n,o,t) :: tl ->
+				| e :: el,(_,o,t) :: tl ->
 					begin try
 						Type.unify e.etype t;
 						loop2 ((e,o) :: acc) el tl
 					with _ ->
-						None
+						match t,tl with
+						| TAbstract({a_path=["haxe";"extern"],"Rest"},[t]),[] ->
+							begin try
+								let el = List.map (fun e -> unify t e.etype; e,o) el in
+								Some ((List.rev acc) @ el,tf,(c,cf,monos))
+							with _ ->
+								None
+							end
+						| _ ->
+							None
 					end
 				| [],[] ->
 					Some ((List.rev acc),tf,(c,cf,monos))

+ 11 - 0
tests/unit/src/unit/issues/Issue9220.hx

@@ -0,0 +1,11 @@
+package unit.issues;
+
+import unit.Test;
+
+class Issue9220 extends Test {
+	#if java
+	public function test() {
+		eq("12.200", java.NativeString.format(java.util.Locale.US, '%.3f', 12.2));
+	}
+	#end
+}