fail_impl_method_not_virtual.carbon 636 B

1234567891011121314151617181920212223242526
  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. fn Foo[self:Self]() -> i32 {
  9. return 1;
  10. }
  11. }
  12. class D {
  13. extend base: C;
  14. impl fn Foo[self:Self]() -> i32 {
  15. return 1;
  16. // CHECK:STDERR: COMPILATION ERROR: fail_impl_method_not_virtual.carbon:[[@LINE+1]]: Error declaring `Foo`: cannot override a method that is not declared `abstract` or `virtual` in base class.
  17. }
  18. }
  19. fn Main() -> i32 {
  20. let c: C = {};
  21. return 0;
  22. }