tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(3,13): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(4,13): error TS2367: No best common type exists between 'T' and 'U'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(5,13): error TS2367: No best common type exists between 'U' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(9,13): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(9,26): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(10,13): error TS2367: No best common type exists between 'T' and 'U'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(11,13): error TS2367: No best common type exists between 'U' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(14,14): error TS2367: No best common type exists between 'V' and 'U'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(15,14): error TS2367: No best common type exists between 'U' and 'V'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(18,14): error TS2367: No best common type exists between 'V' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(19,14): error TS2367: No best common type exists between 'T' and 'V'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(23,13): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(24,13): error TS2367: No best common type exists between 'T' and 'U'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(25,13): error TS2367: No best common type exists between 'U' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(28,14): error TS2367: No best common type exists between 'T' and 'Date'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(29,14): error TS2367: No best common type exists between 'Date' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(60,14): error TS2367: No best common type exists between 'number' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(61,14): error TS2367: No best common type exists between 'T' and 'number'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(65,14): error TS2367: No best common type exists between 'string' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(66,14): error TS2367: No best common type exists between 'T' and 'string'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(70,14): error TS2367: No best common type exists between 'boolean' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(71,14): error TS2367: No best common type exists between 'T' and 'boolean'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(118,15): error TS2367: No best common type exists between 'typeof E' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(119,15): error TS2367: No best common type exists between 'T' and 'typeof E'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(121,15): error TS2367: No best common type exists between 'E' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(122,15): error TS2367: No best common type exists between 'T' and 'E'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(143,18): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(144,19): error TS2367: No best common type exists between 'T' and 'V'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(145,19): error TS2367: No best common type exists between 'V' and 'T'.


==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts (29 errors) ====
    // checking whether other types are subtypes of type parameters with constraints
    
    function f1<T extends U, U>(x: T, y: U) {
                ~~~~~~~~~~~
!!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
        var r = true ? x : y;
                ~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'U'.
        var r = true ? y : x;
                ~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'U' and 'T'.
    }
    
    // V > U > T
    function f2<T extends U, U extends V, V>(x: T, y: U, z: V) {
                ~~~~~~~~~~~
!!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
                             ~~~~~~~~~~~
!!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
        var r = true ? x : y;
                ~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'U'.
        var r = true ? y : x;
                ~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'U' and 'T'.
    
        // ok
        var r2 = true ? z : y;
                 ~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'V' and 'U'.
        var r2 = true ? y : z;
                 ~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'U' and 'V'.
    
        // ok
        var r2 = true ? z : x;
                 ~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'V' and 'T'.
        var r2 = true ? x : z;
                 ~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'V'.
    }
    
    // Date > U > T
    function f3<T extends U, U extends Date>(x: T, y: U) {
                ~~~~~~~~~~~
!!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
        var r = true ? x : y;
                ~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'U'.
        var r = true ? y : x;
                ~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'U' and 'T'.
    
        // ok
        var r2 = true ? x : new Date(); 
                 ~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'Date'.
        var r2 = true ? new Date() : x;
                 ~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'Date' and 'T'.
    
        // ok
        var r3 = true ? y : new Date(); 
        var r3 = true ? new Date() : y;
    }
    
    
    interface I1 { foo: number; }
    class C1 { foo: number; }
    class C2<T> { foo: T; }
    enum E { A }
    function f() { }
    module f {
        export var bar = 1;
    }
    class c { baz: string }
    module c {
        export var bar = 1;
    }
    
    function f4<T extends Number>(x: T) {
        var r0 = true ? x : null; // ok
        var r0 = true ? null : x; // ok
    
        var u: typeof undefined;
        var r0b = true ? u : x; // ok
        var r0b = true ? x : u; // ok
    }
    
    function f5<T extends Number>(x: T) {
        var r1 = true ? 1 : x; // error
                 ~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'number' and 'T'.
        var r1 = true ? x : 1; // error
                 ~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'number'.
    }
    
    function f6<T extends String>(x: T) {
        var r2 = true ? '' : x; // error
                 ~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'string' and 'T'.
        var r2 = true ? x : ''; // error
                 ~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'string'.
    }
    
    function f7<T extends Boolean>(x: T) {
        var r3 = true ? true : x; // error
                 ~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'boolean' and 'T'.
        var r3 = true ? x : true; // error
                 ~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'boolean'.
    }
    
    function f8<T extends Date>(x: T) {
        var r4 = true ? new Date() : x; // ok
        var r4 = true ? x : new Date(); // ok
    }
    
    function f9<T extends RegExp>(x: T) {
        var r5 = true ? /1/ : x; // ok
        var r5 = true ? x : /1/; // ok
    }
    
    function f10<T extends { foo: number }>(x: T) {
        var r6 = true ? { foo: 1 } : x; // ok
        var r6 = true ? x : { foo: 1 }; // ok
    }
    
    function f11<T extends () => void>(x: T) {
        var r7 = true ? () => { } : x; // ok
        var r7 = true ? x : () => { }; // ok
    }
    
    function f12<T extends <U>(x: U) => U>(x: T) {
        var r8 = true ? <T>(x: T) => { return x } : x; // ok
        var r8b = true ? x : <T>(x: T) => { return x }; // ok, type parameters not identical across declarations
    }
    
    function f13<T extends I1>(x: T) {
        var i1: I1;
        var r9 = true ? i1 : x; // ok
        var r9 = true ? x : i1; // ok
    }
    
    function f14<T extends C1>(x: T) {
        var c1: C1;
        var r10 = true ? c1 : x; // ok
        var r10 = true ? x : c1; // ok
    }
    
    function f15<T extends C2<number>>(x: T) {
        var c2: C2<number>;
        var r12 = true ? c2 : x; // ok
        var r12 = true ? x : c2; // ok
    }
    
    function f16<T extends E>(x: T) {
        var r13 = true ? E : x; // BUG 831833
                  ~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'typeof E' and 'T'.
        var r13 = true ? x : E; // BUG 831833
                  ~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'typeof E'.
    
        var r14 = true ? E.A : x; // BUG 831833
                  ~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'E' and 'T'.
        var r14 = true ? x : E.A; // BUG 831833
                  ~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'E'.
    }
    
    function f17<T extends typeof f>(x: T) {
        var af: typeof f;
        var r15 = true ? af : x; // ok
        var r15 = true ? x : af; // ok
    }
    
    function f18<T extends typeof c>(x: T) {
        var ac: typeof c;
        var r16 = true ? ac : x; // ok
        var r16 = true ? x : ac; // ok
    }
    
    function f19<T>(x: T) {
        function f17<U extends T>(a: U) {
            var r17 = true ? x : a; // ok
            var r17 = true ? a : x; // ok
        }
    
        function f18<V extends U, U extends T>(a: V) {
                     ~~~~~~~~~~~
!!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
            var r18 = true ? x : a; // ok
                      ~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'V'.
            var r18 = true ? a : x; // ok
                      ~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'V' and 'T'.
        }
    }
    
    function f20<T extends Number>(x: T) {
        var r19 = true ? new Object() : x; // ok
        var r19 = true ? x : new Object(); // ok
    }
    
    function f21<T extends Number>(x: T) {
        var r20 = true ? {} : x; // ok
        var r20 = true ? x : {}; // ok
    }