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