==== tests/cases/compiler/promiseChaining.ts (3 errors) ====
    // This exhibits the bug that you see with Promise typings having generic signatures in a generic type
    
    class Chain<T> {
        constructor(public value: T) { }
        then<S>(cb: (x: T) => S): Chain<S> {
            var result = cb(this.value);
            // BUG 858876
            // should get a fresh type parameter which each then call
            var z = this.then(x => result).then(x => "abc").then(x => x.length); 
                                                                        ~~~~~~
!!! promiseChaining.ts(9,69): error TS2094: The property 'length' does not exist on value of type '{}'.
            return new Chain(result);
        }
    }
    
    // same example but with constraints on each type parameter
    class Chain2<T extends { length: number }> {
        constructor(public value: T) { }
        then<S extends Function>(cb: (x: T) => S): Chain2<S> {
            var result = cb(this.value);
            // BUG 858876
            // should get a fresh type parameter which each then call
            var z = this.then(x => result).then(x => "abc").then(x => x.length);
                                           ~~~~
!!! promiseChaining.ts(21,40): error TS2082: Supplied parameters do not match any signature of call target:
!!! 	Call signatures of types '(x: Function) => string' and '(x: Function) => Function' are incompatible:
!!! 		Type 'String' is missing property 'apply' from type 'Function'.
                                           ~~~~
!!! promiseChaining.ts(21,40): error TS2087: Could not select overload for 'call' expression.
            return new Chain2(result);
        }
    }
    