summaryrefslogtreecommitdiffstats
path: root/tests/diagnostics/generic-constraint-forward-reference.slang
blob: 08a6c3478b7cee7e3798a50f3d398379806be6e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//DIAGNOSTIC_TEST:SIMPLE:
// Test forward references in generic constraints

interface IFloat {}
interface IFoo<T : IFloat> {}
interface IBar<T, U> {}

// Test case 1: Simple forward reference in interface constraint
void test1<Foo : IFoo<T>, T : IFloat>() {}

// Test case 2: Multiple forward references in a single constraint
void test2<A : IBar<B, C>, B : IFloat, C : IFloat>() {}

// Valid case that should NOT produce our error:
// Test case 3: Correct order - type parameter declared before use
void test3<T : IFloat, Foo : IFoo<T>>() {}