Work around macro context cache issue.
This commit is contained in:
@@ -3,6 +3,7 @@ package tink;
|
||||
import haxe.macro.Expr.TypeDefinition;
|
||||
|
||||
using tink.CoreApi;
|
||||
using tink.macro.Positions;
|
||||
|
||||
typedef Positions = tink.macro.Positions;
|
||||
typedef ExprTools = haxe.macro.ExprTools;
|
||||
@@ -41,7 +42,13 @@ class MacroApi {
|
||||
static function get_typeNotFound() {
|
||||
if (typeNotFound == null) {
|
||||
var trigger = Signal.trigger();
|
||||
haxe.macro.Context.onMacroContextReused(function () return false);
|
||||
|
||||
var listening = false;
|
||||
|
||||
function register() {
|
||||
if (listening) return;
|
||||
listening = true;
|
||||
|
||||
haxe.macro.Context.onTypeNotFound(function (name:String) {
|
||||
@:privateAccess Positions.errorFunc = @:privateAccess Positions.abortTypeBuild;
|
||||
|
||||
@@ -66,8 +73,20 @@ class MacroApi {
|
||||
default: null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
typeNotFound = trigger.asSignal();
|
||||
register();
|
||||
|
||||
haxe.macro.Context.onMacroContextReused(function () {
|
||||
listening = false;
|
||||
return true;
|
||||
});
|
||||
|
||||
var ret = trigger.asSignal();
|
||||
typeNotFound = new Signal(function (cb) {
|
||||
register();
|
||||
return ret.handle(cb);
|
||||
});
|
||||
}
|
||||
return typeNotFound;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user