assoc_constant_constraints_in_scope.carbon 740 B

1234567891011121314151617181920212223242526272829303132
  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 A(T:! type) { let AResult:! type; }
  8. interface B(T:! type) { let BResult:! A(T); }
  9. interface I(T:! type) {
  10. let X:! B(T);
  11. // The constraints introduced by X should be in scope here.
  12. let Y:! X.BResult.AResult;
  13. }
  14. class CA {
  15. extend impl as A(i32) where .AResult = i32 {}
  16. }
  17. class CB {
  18. extend impl as B(i32) where .BResult = CA {}
  19. }
  20. class CI {
  21. extend impl as I(i32) where .X = CB and .Y = 5 {}
  22. }
  23. fn Main() -> i32 {
  24. var v: CI = {};
  25. return v.(I(i32).Y);
  26. }
  27. // CHECK:STDOUT: result: 5