With haxe 4 preview 5
typedef A = Int;
typedef B = A;
typedef C = B;
typedef D = C;
typedef E = D;
abstract F(E) {}
var t = ComplexTypeTools.toType( TPath( { pack: [], name: 'F' } ) );
for ( i in 0 ... 7 ) {
trace( t );
t = Context.followWithAbstracts( t, true );
}
output:
TAbstract(F,[])
TAbstract(Int,[])
TAbstract(Int,[])
TAbstract(Int,[])
TAbstract(Int,[])
TAbstract(Int,[])
TAbstract(Int,[])
Also it would have been nice if follow/followWith… returned Option or something, to know when type was fully reduced and you should stop iterating. Because now it makes new instance of Type and you can’t just == them.