瀏覽代碼

Revert "[nullsafety] not all optional args are nullable (fixes #7925)"

This reverts commit caced379f687be0c47301478df5d15fa8cf20eb5.
Aleksandr Kuzmenko 6 年之前
父節點
當前提交
bfeafa5609
共有 2 個文件被更改,包括 1 次插入7 次删除
  1. 1 1
      src/typing/nullSafety.ml
  2. 0 6
      tests/nullsafety/src/cases/TestStrict.hx

+ 1 - 1
src/typing/nullSafety.ml

@@ -1284,7 +1284,7 @@ class expr_checker mode immediate_execution report =
 		method private check_args ?(arg_num=0) callee args types =
 			match (args, types) with
 				| (arg :: args, (arg_name, optional, t) :: types) ->
-					if not (self#can_pass_expr arg t arg.epos) then begin
+					if not optional && not (self#can_pass_expr arg t arg.epos) then begin
 						let fn_str = match symbol_name callee with "" -> "" | name -> " of function \"" ^ name ^ "\""
 						and arg_str = if arg_name = "" then "" else " \"" ^ arg_name ^ "\"" in
 						self#error ("Cannot pass nullable value to not-nullable argument" ^ arg_str ^ fn_str ^ ".") [arg.epos; callee.epos]

+ 0 - 6
tests/nullsafety/src/cases/TestStrict.hx

@@ -206,12 +206,6 @@ class TestStrict {
 		fn(v);
 	}
 
-	static function call_nullableValueToOptionalNonNullableArgument_shouldFail() {
-		var fn = function(s:String = "") {}
-		var v:Null<String> = null;
-		shouldFail(fn(v));
-	}
-
 	static public function new_nullableValueToNotNullableArgument_shouldFail(?v:String) {
 		shouldFail(new TestStrict(v));
 	}