fail_no_impl.carbon 1.1 KB

123456789101112131415161718192021222324252627282930313233
  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. // RUN: %{not} %{executable_semantics} %s 2>&1 | \
  6. // RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes=false %s
  7. // RUN: %{not} %{executable_semantics} --trace %s 2>&1 | \
  8. // RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes %s
  9. // AUTOUPDATE: %{executable_semantics} %s
  10. // CHECK: COMPILATION ERROR: {{.*}}/executable_semantics/testdata/interface/fail_no_impl.carbon:31: could not find implementation of interface Vector for class Point
  11. package ExecutableSemanticsTest api;
  12. interface Vector {
  13. fn Add[me: Self](b: Self) -> Self;
  14. fn Scale[me: Self](v: i32) -> Self;
  15. }
  16. class Point {
  17. var x: i32;
  18. var y: i32;
  19. }
  20. fn AddAndScaleGeneric[T:! Vector](a: T, b: T, s: i32) -> T {
  21. return a.Add(b).Scale(s);
  22. }
  23. fn Main() -> i32 {
  24. var a: Point = {.x = 0, .y = 0};
  25. var b: Point = {.x = 2, .y = 3};
  26. var p: Point = AddAndScaleGeneric(a, b, 3);
  27. return p.x - 6;
  28. }