1/* 2* Copyright (c) Microsoft Corporation. All rights reserved. 3* Copyright (c) 2023 Huawei Device Co., Ltd. 4* Licensed under the Apache License, Version 2.0 (the "License"); 5* you may not use this file except in compliance with the License. 6* You may obtain a copy of the License at 7* 8* http://www.apache.org/licenses/LICENSE-2.0 9* 10* Unless required by applicable law or agreed to in writing, software 11* distributed under the License is distributed on an "AS IS" BASIS, 12* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13* See the License for the specific language governing permissions and 14* limitations under the License. 15* 16* This file has been modified by Huawei to verify type inference by adding verification statements. 17*/ 18 19// === tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterUsedAsConstraint.ts === 20declare function AssertType(value:any, type:string):void; 21class C<T, U extends T> { } 22class C2<T extends U, U> { } 23class C3<T extends Date, U extends T> { } 24class C4<T extends U, U extends Date> { } 25class C5<T extends U, U extends V, V> { } 26class C6<T, U extends T, V extends U> { } 27 28interface I<T, U extends T> { } 29interface I2<T extends U, U> { } 30interface I3<T extends Date, U extends T> { } 31interface I4<T extends U, U extends Date> { } 32interface I5<T extends U, U extends V, V> { } 33interface I6<T, U extends T, V extends U> { } 34 35function f<T, U extends T>() { } 36function f2<T extends U, U>() { } 37function f3<T extends Date, U extends T>() { } 38function f4<T extends U, U extends Date>() { } 39function f5<T extends U, U extends V, V>() { } 40function f6<T, U extends T, V extends U>() { } 41 42let e = <T, U extends T>() => { 43AssertType(e, "<T, U extends T>() => void"); 44 45AssertType(<T, U extends T>() => { }, "<T, U extends T>() => void"); 46} 47 48let e2 = <T extends U, U>() => { 49AssertType(e2, "<T extends U, U>() => void"); 50 51AssertType(<T extends U, U>() => { }, "<T extends U, U>() => void"); 52} 53 54let e3 = <T extends Date, U extends T>() => { 55AssertType(e3, "<T extends Date, U extends T>() => void"); 56 57AssertType(<T extends Date, U extends T>() => { }, "<T extends Date, U extends T>() => void"); 58} 59 60let e4 = <T extends U, U extends Date>() => { 61AssertType(e4, "<T extends U, U extends Date>() => void"); 62 63AssertType(<T extends U, U extends Date>() => { }, "<T extends U, U extends Date>() => void"); 64} 65 66let e5 = <T extends U, U extends V, V>() => { 67AssertType(e5, "<T extends U, U extends V, V>() => void"); 68 69AssertType(<T extends U, U extends V, V>() => { }, "<T extends U, U extends V, V>() => void"); 70} 71 72let e6 = <T, U extends T, V extends U>() => { 73AssertType(e6, "<T, U extends T, V extends U>() => void"); 74 75AssertType(<T, U extends T, V extends U>() => { }, "<T, U extends T, V extends U>() => void"); 76} 77 78let a: { <T, U extends T>(): void 79AssertType(a, "<T, U extends T>() => void"); 80} 81 82let a2: { <T extends U, U>(): void 83AssertType(a2, "<T extends U, U>() => void"); 84} 85 86let a3: { <T extends Date, U extends T>(): void 87AssertType(a3, "<T extends Date, U extends T>() => void"); 88} 89 90let a4: { <T extends U, U extends Date>(): void 91AssertType(a4, "<T extends U, U extends Date>() => void"); 92} 93 94let a5: { <T extends U, U extends V, V>(): void 95AssertType(a5, "<T extends U, U extends V, V>() => void"); 96} 97 98let a6: { <T, U extends T, V extends U>(): void 99AssertType(a6, "<T, U extends T, V extends U>() => void"); 100} 101 102 103