summaryrefslogtreecommitdiffstats
path: root/tests/language-feature/extensions/extension-override-2.slang
blob: bd40e8ba925becb2c4fd11ad1c9eb2b7232ccaca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//TEST:INTERPRET(filecheck=CHECK):
interface IBar
{}

interface IFoo : IBar
{
    void execute();
}

struct Impl : IFoo
{
    void execute()
    {
        printf("Impl::execute();\n");
    }
}

extension<T:IBar> T : IFoo
{
    void execute()
    {
        printf("Extension::execute();\n");
    }
}

struct Base : IBar{}

void test<T:IFoo>(T t)
{
    t.execute();
}

void main()
{
    // CHECK: Impl::execute();
    Impl f;
    test(f);
    // CHECK: Extension::execute();
    Base b;
    test(b);
}