diff --git a/src/tink/macro/TypeMap.hx b/src/tink/macro/TypeMap.hx index dfdd1cd..67e6996 100644 --- a/src/tink/macro/TypeMap.hx +++ b/src/tink/macro/TypeMap.hx @@ -5,7 +5,6 @@ import haxe.ds.BalancedTree; import haxe.macro.Context; import haxe.macro.Type; -using haxe.macro.Tools; using tink.MacroApi; class TypeMap extends BalancedTree implements IMap { @@ -16,18 +15,7 @@ class TypeMap extends BalancedTree implements IMap { super(); } - override function compare(k1:Type, k2:Type):Int { - - if (follow) { - k1 = k1.reduce(); - k2 = k2.reduce(); - } - - return switch k1.getIndex() - k2.getIndex() { - case 0: - Reflect.compare(k1.toString(), k2.toString());//much to my surprise, this actually seems to work (at least with 3.4) - case v: v; - } - } + override function compare(k1:Type, k2:Type):Int + return k1.compare(k2, follow); } \ No newline at end of file diff --git a/src/tink/macro/Types.hx b/src/tink/macro/Types.hx index c932d20..17e28df 100644 --- a/src/tink/macro/Types.hx +++ b/src/tink/macro/Types.hx @@ -1,12 +1,12 @@ package tink.macro; import haxe.macro.Printer; -import Type in Enums; import haxe.macro.Context; import haxe.macro.Expr; import haxe.macro.Type; +using haxe.macro.Tools; using tink.MacroApi; using tink.CoreApi; @@ -226,4 +226,17 @@ class Types { throw 'assert'; } + static public function compare(t1:Type, t2:Type, ?follow:Bool = true) { + if (follow) { + t1 = t1.reduce(); + t2 = t2.reduce(); + } + + return switch t1.getIndex() - t2.getIndex() { + case 0: + Reflect.compare(t1.toString(), t2.toString());//much to my surprise, this actually seems to work (at least with 3.4) + case v: v; + } + } + }