Simn / genjvm

13 stars 1 forks source link

StringBuf.add vs. Int #31

Closed Simn closed 5 years ago

Simn commented 5 years ago

This broke in my overload changes:

class Main {
    static public function main() {
        var buf = new StringBuf();
        buf.add(12);
        trace(buf.toString());
    }
}

I really want to blame the StringBuf.add implementation for that though:

    public function add<T>( x : T ) : Void {
        if (Std.is(x, Int))
        {
            var x:Int = cast x;
            var xd:Dynamic = x;
            b.append(xd);
        } else {
            b.append(x);
        }
    }
Simn commented 5 years ago

The story here is that if an argument is Dynamic, it is supposed to only unify with Dynamic and java.lang.Object for the sake of overload resolution...

Simn commented 5 years ago

I fixed this in https://github.com/Simn/genjvm/commit/71ed9e270def69457a66e2b83556b0d74eb0c2ff

There's still a problem with Dynamic in overloads, but that's for another day/isssue.