fail_redeclare_virtual_method.carbon 584 B

12345678910111213141516171819202122
  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. // NOAUTOUPDATE
  6. package ExplorerTest api;
  7. base class C {
  8. virtual fn Foo[self:Self]() {}
  9. }
  10. class D {
  11. extend base: C;
  12. // CHECK:STDERR: COMPILATION ERROR: fail_redeclare_virtual_method.carbon:[[@LINE+1]]: Error declaring `Foo`: method is declared virtual in base class, use `impl` to override it.
  13. virtual fn Foo[self:Self]() {}
  14. }
  15. fn Main() -> i32 {
  16. let c: C = {};
  17. return 0;
  18. }