浏览代码

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

Aleksandr Kuzmenko 5 年之前
父节点
当前提交
4c170dd811
共有 4 个文件被更改,包括 28 次插入8 次删除
  1. 1 0
      extra/CHANGES.txt
  2. 16 8
      src/core/tFunctions.ml
  3. 10 0
      tests/misc/projects/Issue9455/Main.hx
  4. 1 0
      tests/misc/projects/Issue9455/compile.hxml

+ 1 - 0
extra/CHANGES.txt

@@ -7,6 +7,7 @@
 	all : fixed "Module not found" error reporting during macro execution in display requests (#9449)
 	all : fixed module name completion for target-specific modules like `Mod.js.hx` (#9423)
 	all : fixed completion for packages named "function" (#7697)
+	all : fixed recursive typedefs with optional arguments in `@:overload` functions (#9455)
 	cpp : fixed StringTools.endsWith() for unicode characters (#8980)
 	js/cpp : fixed catch var naming collision (#9413)
 	interp : fixed throwing `haxe.macro.Error` outside of a macro context (#9390)

+ 16 - 8
src/core/tFunctions.ml

@@ -477,15 +477,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
 (*
@@ -506,13 +510,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