1

Closed

Develop: BiMap-like generics not working

description

Please check out the attached repro files. I have a BiMap<K, V> class that looks like this:
class BiMap<K, V> {

    private forwardMap: LinkedMap<K, V>;
    private inverseMap: LinkedMap<V, K>;

    private inverseBiMap: BiMap<V, K>;

    constructor(forwardMap = new LinkedMap<K, V>(), inverseMap = new LinkedMap<V, K>()) {
        this.forwardMap = forwardMap;
        this.inverseMap = inverseMap;
    }

    public inverse(): BiMap<V, K> {
        if (this.inverseBiMap == null) {
            this.inverseBiMap = new BiMap<V, K>(this.inverseMap, this.forwardMap);
        }

        return this.inverseBiMap;
    }
...
And a test that looks like this:
        var biMap = new BiMap<string, number>();
        var key = "key";
        var value = 100;

        // set a value
        biMap.set(key, value);
        assert.equal(biMap.get(key), value);
        assert.equal(biMap.inverse().get(value), key);
        assert.isTrue(biMap.has(key));
        assert.isTrue(biMap.inverse().has(value));
But I get these errors:
Multiple markers at this line
- Could not select overload for 'call' expression.
- Supplied parameters do not match any signature of call target:
    Could not apply type 'string' to argument 1 which is of type 'number'.
It seems like something is going wrong with the generics for the inverse() method.

file attachments

Closed Nov 15, 2013 at 7:17 PM by danquirk
Yep, all taken care of in develop now.

comments

danquirk wrote Nov 7, 2013 at 9:19 PM

Thanks for the easy repro. Definitely something very wrong going on here, marked as active.

derekcicerone wrote Nov 8, 2013 at 12:12 AM

Looks like you just pushed the fix 10 mins ago - thanks for the quick fix!