jsx / JSX

JSX - a faster, safer, easier JavaScript
http://jsx.github.io/
MIT License
1.46k stars 102 forks source link

map/array literal type widening #264

Closed nyuichi closed 11 years ago

nyuichi commented 11 years ago

related: #261

Allows type covariance only when raw map/array literals are given to a call

class A {
}

class B extends A {
}

class _Main {
    static function foo (v : Map.<variant>) : void {}
    static function bar (a : Array.<variant>) : void {}
    static function baz (a : Array.<A>) : void {}
    static function main (args : string[]) : void {
        _Main.foo({a : 1, b : 2}); // Map.<number> -> Map.<variant>
        _Main.bar([1, 2]);     // Array.<number> -> Map.<variant>
        _Main.baz([ new B ]);      // Array.<B> -> Array.<A>
    }
}
gfx commented 11 years ago

LGTM

shibukawa commented 11 years ago

Awesome!

kazuho commented 11 years ago

:+1: