fail_redeclare_virtual_method.carbon 673 B

1234567891011121314151617181920212223
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // AUTOUPDATE
  6. // RUN: %{not} %{explorer-run}
  7. // RUN: %{not} %{explorer-run-trace}
  8. package ExplorerTest api;
  9. base class C {
  10. virtual fn Foo[self:Self]() {}
  11. }
  12. class D extends C {
  13. // CHECK:STDERR: COMPILATION ERROR: {{.*}}/explorer/testdata/class/fail_redeclare_virtual_method.carbon:[[@LINE+1]]: Error declaring `Foo`: method is declared virtual in base class, use `impl` to override it.
  14. virtual fn Foo[self:Self]() {}
  15. }
  16. fn Main() -> i32 {
  17. let c: C = {};
  18. return 0;
  19. }