فهرست منبع

[macro] Add Context.followLazy

Rudy Ges 1 سال پیش
والد
کامیت
a5d3e4b552
3فایلهای تغییر یافته به همراه24 افزوده شده و 0 حذف شده
  1. 4 0
      src/macro/macroApi.ml
  2. 14 0
      std/haxe/macro/Context.hx
  3. 6 0
      std/haxe/macro/TypeTools.hx

+ 4 - 0
src/macro/macroApi.ml

@@ -2141,6 +2141,10 @@ let macro_api ccom get_api =
 			let t = decode_type v in
 			let t = decode_type v in
 			encode_type (if decode_opt_bool once then follow_once t else follow t)
 			encode_type (if decode_opt_bool once then follow_once t else follow t)
 		);
 		);
+		"follow_lazy", vfun1 (fun v ->
+			let t = decode_type v in
+			encode_type (follow_lazy t)
+		);
 		"get_build_fields", vfun0 (fun() ->
 		"get_build_fields", vfun0 (fun() ->
 			(get_api()).get_build_fields()
 			(get_api()).get_build_fields()
 		);
 		);

+ 14 - 0
std/haxe/macro/Context.hx

@@ -601,6 +601,20 @@ class Context {
 		return load("follow_with_abstracts", 2)(t, once);
 		return load("follow_with_abstracts", 2)(t, once);
 	}
 	}
 
 
+	/**
+		TODO documentation
+
+		See `haxe.macro.TypeTools.followLazy` for details.
+
+		Usage of this function from initialization macros is deprecated and may
+		cause compilation server issues. Use `Context.onAfterInitMacros` to
+		run your code once typer is ready to be used.
+	**/
+	public static function followLazy(t:Type):Type {
+		assertInitMacrosDone();
+		return load("follow_lazy", 1)(t);
+	}
+
 	/**
 	/**
 		Returns the information stored in `Position` `p`.
 		Returns the information stored in `Position` `p`.
 	**/
 	**/

+ 6 - 0
std/haxe/macro/TypeTools.hx

@@ -205,6 +205,12 @@ class TypeTools {
 	static public inline function followWithAbstracts(t:Type, once:Bool = false):Type
 	static public inline function followWithAbstracts(t:Type, once:Bool = false):Type
 		return Context.followWithAbstracts(t, once);
 		return Context.followWithAbstracts(t, once);
 
 
+	/**
+		TODO documentation
+	**/
+	static public inline function followLazy(t:Type):Type
+		return Context.followLazy(t);
+
 	/**
 	/**
 		Returns true if `t1` and `t2` unify, false otherwise.
 		Returns true if `t1` and `t2` unify, false otherwise.
 	**/
 	**/