Browse Source

fixed typedefs recursion in an optional argument of an @:overload signature (closes #9455)

Aleksandr Kuzmenko 5 years ago
parent
commit
27c263ebaf

+ 16 - 8
src/core/tFunctions.ml

@@ -478,15 +478,19 @@ let rec ambiguate_funs t =
 				ambiguate_funs af.cf_type }) a.a_fields }
 	| TLazy _ -> die "" __LOC__
 
-let rec is_nullable = function
+let rec is_nullable ?(no_lazy=false) = function
 	| TMono r ->
-		(match r.tm_type with None -> false | Some t -> is_nullable t)
+		(match r.tm_type with None -> false | Some t -> is_nullable ~no_lazy t)
 	| TAbstract ({ a_path = ([],"Null") },[_]) ->
 		true
 	| TLazy f ->
-		is_nullable (lazy_type f)
+		(match !f with
+		| LAvailable t -> is_nullable ~no_lazy t
+		| _ when no_lazy -> raise Exit
+		| _ -> is_nullable (lazy_type f)
+		)
 	| TType (t,tl) ->
-		is_nullable (apply_params t.t_params tl t.t_type)
+		is_nullable ~no_lazy (apply_params t.t_params tl t.t_type)
 	| TFun _ ->
 		false
 (*
@@ -507,13 +511,17 @@ let rec is_nullable = function
 
 let rec is_null ?(no_lazy=false) = function
 	| TMono r ->
-		(match r.tm_type with None -> false | Some t -> is_null t)
+		(match r.tm_type with None -> false | Some t -> is_null ~no_lazy t)
 	| TAbstract ({ a_path = ([],"Null") },[t]) ->
-		not (is_nullable (follow t))
+		not (is_nullable ~no_lazy (follow t))
 	| TLazy f ->
-		if no_lazy then raise Exit else is_null (lazy_type f)
+		(match !f with
+		| LAvailable t -> is_null ~no_lazy t
+		| _ when no_lazy -> raise Exit
+		| _ -> is_null (lazy_type f)
+		)
 	| TType (t,tl) ->
-		is_null (apply_params t.t_params tl t.t_type)
+		is_null ~no_lazy (apply_params t.t_params tl t.t_type)
 	| _ ->
 		false
 

+ 10 - 0
tests/misc/projects/Issue9455/Main.hx

@@ -0,0 +1,10 @@
+typedef Intersection = VueConstructor & {};
+
+typedef VueConstructor = {
+	@:overload(function(?options:Intersection):Void { })
+	function extend():Void;
+};
+
+class Main {
+    static function main() {}
+}

+ 1 - 0
tests/misc/projects/Issue9455/compile.hxml

@@ -0,0 +1 @@
+-main Main