initialization macro to suppress the unused case warning

This commit is contained in:
2022-02-23 14:17:35 -07:00
parent 84da50b807
commit ae756065a6
2 changed files with 19 additions and 1 deletions

View File

@@ -4,4 +4,5 @@
-lib tink_json
-cp kiss/src
-cp cloner/src
-D analyzer-optimize
-D analyzer-optimize
--macro kiss.Kiss.setup()

View File

@@ -161,6 +161,23 @@ class Kiss {
#end
}
/**
* Initializer macro: suppress some compiler warnings that Kiss code commonly generates
* Source: https://try.haxe.org/#10F18962 by @kLabz
*/
public static macro function setup() {
haxe.macro.Context.onAfterTyping(function(_) {
haxe.macro.Context.filterMessages(function(msg) {
return switch (msg) {
case Warning("This case is unused", _): false;
case _: true;
};
});
});
return macro {};
}
/**
Build macro: add fields to a class from a corresponding .kiss file
**/