back2dos / tinkerbell

MIT License
83 stars 8 forks source link

fix for pretty tink.macro.tools.TypeTools.toComplex with Type paramater <T> #35

Closed misprintt closed 11 years ago

misprintt commented 11 years ago

Hi,

When using TypeTools.toComplex with pretty == true, references to abstract types are incorrectly qualified to the source type's module (they should remain unqualified, otherwise they cause compilation errors)

This can be fixed by checking if the ClassType.kind == KTypeParamater, and not including the module in the TPath path.

E.g.

/**
Override baseToComplex to prevent qualified paths on generic <T> types 
*/
static function classToComplex(t:ClassType, params:Array<Type>)
{
    switch(t.kind)
    {
        case KTypeParameter:
            return asComplexType(t.name, paramsToComplex(params));
        default:
            return baseToComplex(t, params);
        }
}
static public function toComplex(type:Type, ?pretty = false):ComplexType {
    return 
        if (pretty) {
            switch (type) {
                ...
                case TInst(t, params):  
                    classToComplex(t.get(), params);
                ...
            }
back2dos commented 11 years ago

Thanks for reporting. In fact, it's already fixed for a while, I just didn't have the time to push it to haxelib in fact there's a huge number of peding updates, so I have quite a bit of documentation to update.

Will try to get the haxelib updates done by monday ;)

back2dos commented 11 years ago

It's up on haxelib.