summaryrefslogtreecommitdiffstats
path: root/tests/language-feature/generics/where-optional-5.slang
blob: 3ce8041adc1c31ac4d5afa6971cb3a36bc8c8bb3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK):
interface IThing
{
    void thing();
}

void f<T, U>(T t, U u)
    where optional T: IThing
    where optional U: IThing
{
    // Error: cannot upgrade optional to non-optional witness in unchecked context.
    if (U is IThing)
    {
        // U being IThing doesn't justify using T as such!
        t.thing(); // CHECK: error 30403
    }
}