gcc/testsuite/gdc.test/fail_compilation/fail143.d
raw| 1 | /* |
| 2 | TEST_OUTPUT: |
| 3 | --- |
| 4 | fail_compilation/fail143.d(23): Error: calling non-static function `next` requires an instance of type `Quux` |
| 5 | fail_compilation/fail143.d(30): Error: template instance `fail143.Foo!int` error instantiating |
| 6 | --- |
| 7 | */ |
| 8 | |
| 9 | class Quux |
| 10 | { |
| 11 | uint x; |
| 12 | |
| 13 | final uint next() |
| 14 | { |
| 15 | return x; |
| 16 | } |
| 17 | } |
| 18 | |
| 19 | template Foo(T) |
| 20 | { |
| 21 | void bar() |
| 22 | { |
| 23 | int r = Quux.next; |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | int main(char[][] args) |
| 28 | { |
| 29 | auto prng = new Quux(); |
| 30 | alias Foo!(int).bar baz; |
| 31 | |
| 32 | int x = prng.next; |
| 33 | baz(); |
| 34 | |
| 35 | return 0; |
| 36 | } |