fail_require_member_access.carbon 619 B

123456789101112131415161718192021222324
  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. interface HasFoo {
  8. fn Foo();
  9. }
  10. constraint ImplAsHasFoo {
  11. require Self impls HasFoo;
  12. }
  13. fn CallFoo[T:! ImplAsHasFoo](x: T) {
  14. // OK, T is HasFoo.
  15. x.(HasFoo.Foo)();
  16. // CHECK:STDERR: COMPILATION ERROR: fail_require_member_access.carbon:[[@LINE+1]]: member access, Foo not in constraint ImplAsHasFoo where T impls interface HasFoo
  17. x.Foo();
  18. }
  19. fn Main() -> i32 { return 0; }