Explorar el Código

[java/cs] Delay duplicate overloaded constructor check. See #2687

Cauê Waneck hace 10 años
padre
commit
4f16854cbb
Se han modificado 2 ficheros con 16 adiciones y 15 borrados
  1. 7 8
      std/cs/_std/Array.hx
  2. 9 7
      typeload.ml

+ 7 - 8
std/cs/_std/Array.hx

@@ -21,13 +21,6 @@
  */
 import cs.NativeArray;
 
-@:classCode('
-	public Array(T[] native)
-	{
-		this.__a = native;
-		this.length = native.Length;
-	}
-')
 #if core_api_serialize
 @:meta(System.Serializable)
 #end
@@ -53,12 +46,18 @@ import cs.NativeArray;
 		return null;
 	}
 
-	public function new() : Void
+	@:overload public function new() : Void
 	{
 		this.length = 0;
 		this.__a = new NativeArray(0);
 	}
 
+	@:overload private function new(native:NativeArray<T>)
+	{
+		this.length = native.Length;
+		this.__a = native;
+	}
+
 	public function concat( a : Array<T> ) : Array<T>
 	{
 		var len = length + a.length;

+ 9 - 7
typeload.ml

@@ -2437,13 +2437,15 @@ let init_class ctx c p context_init herits fields =
 	(* check overloaded constructors *)
 	(if ctx.com.config.pf_overload then match c.cl_constructor with
 	| Some ctor ->
-		List.iter (fun f ->
-			try
-				(* TODO: consider making a broader check, and treat some types, like TAnon and type parameters as Dynamic *)
-				ignore(List.find (fun f2 -> f != f2 && same_overload_args f.cf_type f2.cf_type f f2) (ctor :: ctor.cf_overloads));
-				display_error ctx ("Another overloaded field of same signature was already declared : " ^ f.cf_name) f.cf_pos;
-			with Not_found -> ()
-		) (ctor :: ctor.cf_overloads)
+		delay ctx PTypeField (fun() ->
+			List.iter (fun f ->
+				try
+					(* TODO: consider making a broader check, and treat some types, like TAnon and type parameters as Dynamic *)
+					ignore(List.find (fun f2 -> f != f2 && same_overload_args f.cf_type f2.cf_type f f2) (ctor :: ctor.cf_overloads));
+					display_error ctx ("Another overloaded field of same signature was already declared : " ^ f.cf_name) f.cf_pos;
+				with Not_found -> ()
+			) (ctor :: ctor.cf_overloads)
+		)
 	| _ -> ());
 	(* push delays in reverse order so they will be run in correct order *)
 	List.iter (fun (ctx,r) ->