summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gdc.test/compilable/future.d
blob: 30439847ef4a186a32f473c1a4f5ca3611949766 (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
42
43
44
45
46
47
/* PERMUTE_ARGS:
 * TEST_OUTPUT:
---
compilable/future.d(15): Deprecation: `@__future` base class method `future.A.msg` is being overridden by `future.B.msg`; rename the latter
---
 */

class A
{
    @__future char msg() { return 'a'; }
}

class B : A
{
    char msg() { return 'b'; }
}

class C : B
{
    override char msg() { return 'c'; }
}

class D : A
{
    override char msg() { return 'd'; }
}

int main()
{
    auto a = new A();
    assert(a.msg() == 'a');
    auto b = new B();
    assert(b.msg() == 'b');
    auto c = new C();
    assert(c.msg() == 'c');
    auto d = new D();
    assert(d.msg() == 'd');

    assert(b.A.msg() == 'a');

    auto ba = cast(A)b;
    assert(ba.msg() == 'a');

    auto da = cast(A)d;
    assert(da.msg() == 'd');
    return 0;
}