simple_mix_in_mixin.carbon 541 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. package ExplorerTest api;
  7. __mixin M1 {
  8. fn Scale10[self: Self](x:i32) -> i32{
  9. return x * 10;
  10. }
  11. }
  12. __mixin M2 {
  13. __mix M1;
  14. fn Square[self: Self](x:i32) -> i32{
  15. return x * x;
  16. }
  17. }
  18. class C {
  19. __mix M2;
  20. }
  21. fn Main() -> i32 {
  22. var c: C = {};
  23. return c.Square(11) - c.Scale10(10) - 21;
  24. }
  25. // CHECK:STDOUT: result: 0