impl_as.carbon 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. interface Simple {
  7. fn F();
  8. }
  9. class C {
  10. impl as Simple {
  11. fn F() {
  12. // C is a complete type here.
  13. var c: C = {};
  14. }
  15. }
  16. }
  17. // CHECK:STDOUT: --- impl_as.carbon
  18. // CHECK:STDOUT:
  19. // CHECK:STDOUT: constants {
  20. // CHECK:STDOUT: %.1: type = interface_type @Simple [template]
  21. // CHECK:STDOUT: %.2: type = assoc_entity_type @Simple, <function> [template]
  22. // CHECK:STDOUT: %.3: <associated <function> in Simple> = assoc_entity element0, @Simple.%F [template]
  23. // CHECK:STDOUT: %C: type = class_type @C [template]
  24. // CHECK:STDOUT: %.4: <witness> = interface_witness (@impl.%F) [template]
  25. // CHECK:STDOUT: %.5: type = struct_type {} [template]
  26. // CHECK:STDOUT: %.6: type = tuple_type () [template]
  27. // CHECK:STDOUT: %.7: type = ptr_type {} [template]
  28. // CHECK:STDOUT: %.8: C = struct_value () [template]
  29. // CHECK:STDOUT: }
  30. // CHECK:STDOUT:
  31. // CHECK:STDOUT: file {
  32. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  33. // CHECK:STDOUT: .Core = %Core
  34. // CHECK:STDOUT: .Simple = %Simple.decl
  35. // CHECK:STDOUT: .C = %C.decl
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  38. // CHECK:STDOUT: %Simple.decl: type = interface_decl @Simple [template = constants.%.1] {}
  39. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {}
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT:
  42. // CHECK:STDOUT: interface @Simple {
  43. // CHECK:STDOUT: %Self: Simple = bind_symbolic_name Self [symbolic]
  44. // CHECK:STDOUT: %F: <function> = fn_decl @F.1 [template] {}
  45. // CHECK:STDOUT: %.loc8: <associated <function> in Simple> = assoc_entity element0, %F [template = constants.%.3]
  46. // CHECK:STDOUT:
  47. // CHECK:STDOUT: !members:
  48. // CHECK:STDOUT: .Self = %Self
  49. // CHECK:STDOUT: .F = %.loc8
  50. // CHECK:STDOUT: witness = (%F)
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT:
  53. // CHECK:STDOUT: impl @impl: C as Simple {
  54. // CHECK:STDOUT: %F: <function> = fn_decl @F.2 [template] {}
  55. // CHECK:STDOUT: %.1: <witness> = interface_witness (%F) [template = constants.%.4]
  56. // CHECK:STDOUT:
  57. // CHECK:STDOUT: !members:
  58. // CHECK:STDOUT: .F = %F
  59. // CHECK:STDOUT: witness = %.1
  60. // CHECK:STDOUT: }
  61. // CHECK:STDOUT:
  62. // CHECK:STDOUT: class @C {
  63. // CHECK:STDOUT: impl_decl @impl {
  64. // CHECK:STDOUT: %Simple.ref: type = name_ref Simple, file.%Simple.decl [template = constants.%.1]
  65. // CHECK:STDOUT: }
  66. // CHECK:STDOUT:
  67. // CHECK:STDOUT: !members:
  68. // CHECK:STDOUT: .Self = constants.%C
  69. // CHECK:STDOUT: }
  70. // CHECK:STDOUT:
  71. // CHECK:STDOUT: fn @F.1();
  72. // CHECK:STDOUT:
  73. // CHECK:STDOUT: fn @F.2() {
  74. // CHECK:STDOUT: !entry:
  75. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  76. // CHECK:STDOUT: %c.var: ref C = var c
  77. // CHECK:STDOUT: %c: ref C = bind_name c, %c.var
  78. // CHECK:STDOUT: %.loc15_19.1: {} = struct_literal ()
  79. // CHECK:STDOUT: %.loc15_19.2: init C = class_init (), %c.var [template = constants.%.8]
  80. // CHECK:STDOUT: %.loc15_19.3: init C = converted %.loc15_19.1, %.loc15_19.2 [template = constants.%.8]
  81. // CHECK:STDOUT: assign %c.var, %.loc15_19.3
  82. // CHECK:STDOUT: return
  83. // CHECK:STDOUT: }
  84. // CHECK:STDOUT: