Skip to content

Commit

Permalink
fixed typedefs recursion in an optional argument of an @:overload sig…
Browse files Browse the repository at this point in the history
…nature (closes #9455)
  • Loading branch information
RealyUniqueName committed May 21, 2020
1 parent 02d7bda commit 27c263e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/core/tFunctions.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
(*
Expand All @@ -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

Expand Down
10 changes: 10 additions & 0 deletions tests/misc/projects/Issue9455/Main.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
typedef Intersection = VueConstructor & {};

typedef VueConstructor = {
@:overload(function(?options:Intersection):Void { })
function extend():Void;
};

class Main {
static function main() {}
}
1 change: 1 addition & 0 deletions tests/misc/projects/Issue9455/compile.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-main Main

0 comments on commit 27c263e

Please sign in to comment.