Browse Source

[cs] [java] try to get CI green

whatever it takes
Simon Krajewski 2 years ago
parent
commit
5405d4b098

+ 1 - 7
src/codegen/gencommon/normalize.ml

@@ -50,13 +50,7 @@ let rec filter_param (stack:t list) t =
 	| TAbstract({ a_path = (["haxe"],"Rest") } as a,tl) ->
 		TAbstract(a, List.map (filter_param stack) tl)
 	| TAbstract({a_path = [],"Null"} as a,[t]) ->
-		(* Null<TypeParameter> is the same as TypeParameter *)
-		begin match follow t with
-		| TInst({cl_kind = KTypeParameter _},_) ->
-			filter_param stack t
-		| _ ->
-			TAbstract(a,[filter_param stack t])
-		end
+		TAbstract(a,[filter_param stack t])
 	| TAbstract(a,tl) when (Meta.has Meta.MultiType a.a_meta) ->
 		filter_param stack (Abstract.get_underlying_type a tl)
 	| TAbstract(a,tl) ->

+ 2 - 5
src/generators/genjava.ml

@@ -1142,11 +1142,8 @@ let generate con =
 				| TAbstract( { a_path = (["java"], "Int64") }, [] )
 				| TAbstract( { a_path = (["haxe"], "Int64") }, [] ) ->
 					TInst(cl_long, [])
-				| _ -> (match follow t with
-					| TInst( { cl_kind = KTypeParameter _ }, []) ->
-							t_dynamic
-					| _ -> real_type t
-				)
+				| _ ->
+					real_type t
 			)
 			| TAbstract (a, pl) when not (Meta.has Meta.CoreType a.a_meta) ->
 				real_type (Abstract.get_underlying_type a pl)

+ 21 - 16
src/typing/typer.ml

@@ -312,23 +312,28 @@ let rec type_ident_raise ctx i p mode with_type =
 		AKExpr (mk (TConst TSuper) t p)
 	| "null" ->
 		if mode = MGet then begin
-			let tnull () = ctx.t.tnull (spawn_monomorph ctx p) in
-			let t = match with_type with
-				| WithType.WithType(t,_) ->
-					begin match follow t with
-					| TMono r ->
-						(* If our expected type is a monomorph, bind it to Null<?>. *)
-						Monomorph.do_bind r (tnull())
+			(* Hack for #10787 *)
+			if ctx.com.platform = Cs then
+				AKExpr (null (spawn_monomorph ctx p) p)
+			else begin
+				let tnull () = ctx.t.tnull (spawn_monomorph ctx p) in
+				let t = match with_type with
+					| WithType.WithType(t,_) ->
+						begin match follow t with
+						| TMono r ->
+							(* If our expected type is a monomorph, bind it to Null<?>. *)
+							Monomorph.do_bind r (tnull())
+						| _ ->
+							(* Otherwise there's no need to create a monomorph, we can just type the null literal
+							the way we expect it. *)
+							()
+						end;
+						t
 					| _ ->
-						(* Otherwise there's no need to create a monomorph, we can just type the null literal
-						   the way we expect it. *)
-						()
-					end;
-					t
-				| _ ->
-					tnull()
-			in
-			AKExpr (null t p)
+						tnull()
+				in
+				AKExpr (null t p)
+			end
 		end else
 			AKNo i
 	| _ ->

+ 2 - 2
tests/unit/src/unit/issues/Issue2776.hx

@@ -25,11 +25,11 @@ class Issue2776 extends Test {
 		}));
 	}
 
-	static function getClassT<T>():Null<Class<T>> {
+	static function getClassT<T>():#if cs Class<T> #else Null<Class<T>> #end {
 		return (null : Class<T>);
 	}
 
-	static function getEnumT<T>():Null<Enum<T>> {
+	static function getEnumT<T>():#if cs Enum<T> #else Null<Enum<T>> #end {
 		return (null : Enum<T>);
 	}
 }

+ 4 - 0
tests/unit/src/unit/issues/Issue3396.hx

@@ -8,7 +8,11 @@ class Issue3396 extends Test {
 		Reflect.makeVarArgs(f);
 		Reflect.makeVarArgs(f2);
 		var s:String = f([]);
+		#if cs
+		unit.HelperMacros.typedAs(r, (r : String));
+		#else
 		unit.HelperMacros.typedAs(r, (r : Null<String>));
+		#end
 		unit.HelperMacros.typedAs(f2([]), (null : Void));
 	}
 }

+ 2 - 0
tests/unit/src/unit/issues/Issue7736.hx

@@ -1,6 +1,7 @@
 package unit.issues;
 
 class Issue7736 extends Test {
+	#if !cs
 	@:nullSafety
 	function test() {
 		var found = null;
@@ -16,4 +17,5 @@ class Issue7736 extends Test {
 			eq(5, x);
 		}
 	}
+	#end
 }