Ver Fonte

Avoid wrapping Null<T> as Null<Null<T>> (#6907)

Ben Morris há 7 anos atrás
pai
commit
3988422201
2 ficheiros alterados com 16 adições e 2 exclusões
  1. 2 2
      src/typing/typer.ml
  2. 14 0
      tests/unit/src/unit/issues/Issue6896.hx

+ 2 - 2
src/typing/typer.ml

@@ -4324,7 +4324,7 @@ let rec create com =
 			| "Null" ->
 				let mk_null t =
 					try
-						if not (is_null ~no_lazy:true t) then TAbstract (a,[t]) else t
+						if not (is_null ~no_lazy:true t || is_explicit_null t) then TAbstract (a,[t]) else t
 					with Exit ->
 						(* don't force lazy evaluation *)
 						let r = ref (lazy_available t_dynamic) in
@@ -4375,4 +4375,4 @@ type_module_type_ref := type_module_type;
 find_array_access_raise_ref := AbstractCast.find_array_access_raise;
 build_call_ref := build_call;
 merge_core_doc_ref := merge_core_doc;
-MacroContext.unify_call_args_ref := unify_call_args
+MacroContext.unify_call_args_ref := unify_call_args

+ 14 - 0
tests/unit/src/unit/issues/Issue6896.hx

@@ -0,0 +1,14 @@
+package unit.issues;
+
+import unit.HelperMacros.typeString;
+
+private typedef A = {
+    @:optional var value:Null<String>;
+}
+
+class Issue6896 extends Test {
+	function test() {
+		var a:A = {};
+		eq(typeString(a.value), "Null<String>");
+	}
+}