2
0
Эх сурвалжийг харах

[java/cs] Do not infer Null<ValueType> to ValueType on anonymous functions. Closes #2048

Cauê Waneck 11 жил өмнө
parent
commit
c560a9e81b

+ 5 - 3
gencommon.ml

@@ -3297,10 +3297,12 @@ struct
 
       in
 
-      let rettype_real_to_func t =
-        if like_float t then
+      let rettype_real_to_func t = match run_follow gen t with
+        | TType({ t_path = [],"Null" }, _) ->
+          0,t_dynamic
+        | _ when like_float t ->
           (1, basic.tfloat)
-        else
+        | _ ->
           (0, t_dynamic)
       in
 

+ 12 - 0
tests/unit/issues/Issue2048.hx

@@ -0,0 +1,12 @@
+package unit.issues;
+
+class Issue2048 extends unit.Test
+{
+	public function testNullableInt()
+	{
+		var x = function ():Null<Int> {
+			return null;
+		}
+		eq( null, x() );
+	}
+}