fail_interface_missing_member.carbon 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  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_interface_missing_member.carbon:19: field access, Scale not in Vector
  11. package ExecutableSemanticsTest api;
  12. interface Vector {
  13. fn Add[me: Self](b: Self) -> Self;
  14. }
  15. fn ScaleGeneric[T:! Vector](a: T, s: i32) -> T {
  16. return a.Scale(s);
  17. }
  18. class Point {
  19. var x: i32;
  20. var y: i32;
  21. impl Point as Vector {
  22. fn Add[me: Point](b: Point) -> Point {
  23. return {.x = me.x + b.x, .y = me.y + b.y};
  24. }
  25. }
  26. }
  27. fn Main() -> i32 {
  28. var a: Point = {.x = 3, .y = 1};
  29. var b: Point = ScaleGeneric(a, 2);
  30. return b.x - 6;
  31. }