fail_no_impl.carbon 870 B

12345678910111213141516171819202122232425262728293031
  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. interface Vector {
  10. fn Add[self: Self](b: Self) -> Self;
  11. fn Scale[self: Self](v: i32) -> Self;
  12. }
  13. class Point {
  14. var x: i32;
  15. var y: i32;
  16. }
  17. fn AddAndScaleGeneric[T:! Vector](a: T, b: T, s: i32) -> T {
  18. return a.Add(b).Scale(s);
  19. }
  20. fn Main() -> i32 {
  21. var a: Point = {.x = 0, .y = 0};
  22. var b: Point = {.x = 2, .y = 3};
  23. // CHECK:STDERR: COMPILATION ERROR: {{.*}}/explorer/testdata/interface/fail_no_impl.carbon:[[@LINE+1]]: could not find implementation of interface Vector for class Point
  24. var p: Point = AddAndScaleGeneric(a, b, 3);
  25. return p.x - 6;
  26. }