gcc/testsuite/gdc.test/fail_compilation/fail262.d
raw| 1 | /* |
| 2 | TEST_OUTPUT: |
| 3 | --- |
| 4 | fail_compilation/fail262.d(23): Error: function `const void fail262.B.f()` does not override any function, did you mean to override `shared const void fail262.A.f()`? |
| 5 | --- |
| 6 | */ |
| 7 | |
| 8 | // https://issues.dlang.org/show_bug.cgi?id=1645 |
| 9 | // can override base class' const method with non-const method |
| 10 | import core.stdc.stdio; |
| 11 | |
| 12 | class A |
| 13 | { |
| 14 | int x; |
| 15 | shared const void f() |
| 16 | { |
| 17 | printf("A\n"); |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | class B : A |
| 22 | { |
| 23 | override const void f() |
| 24 | { |
| 25 | //x = 2; |
| 26 | printf("B\n"); |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | void main() |
| 31 | { |
| 32 | A y = new B; |
| 33 | y.f; |
| 34 | } |