fail_impl_method_not_virtual.carbon 650 B

12345678910111213141516171819202122232425
  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. package ExplorerTest api;
  7. base class C {
  8. fn Foo[self:Self]() -> i32 {
  9. return 1;
  10. }
  11. }
  12. class D extends C {
  13. impl fn Foo[self:Self]() -> i32 {
  14. return 1;
  15. // CHECK:STDERR: COMPILATION ERROR: explorer/testdata/class/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.
  16. }
  17. }
  18. fn Main() -> i32 {
  19. let c: C = {};
  20. return 0;
  21. }