浏览代码

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

Cauê Waneck 11 年之前
父节点
当前提交
c560a9e81b
共有 2 个文件被更改,包括 17 次插入3 次删除
  1. 5 3
      gencommon.ml
  2. 12 0
      tests/unit/issues/Issue2048.hx

+ 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() );
+	}
+}