extend_impl.carbon 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 HasF {
  7. fn F();
  8. }
  9. class C {
  10. extend impl as HasF {
  11. fn F() {}
  12. }
  13. }
  14. fn G(c: C) {
  15. C.F();
  16. c.F();
  17. }
  18. // CHECK:STDOUT: --- extend_impl.carbon
  19. // CHECK:STDOUT:
  20. // CHECK:STDOUT: constants {
  21. // CHECK:STDOUT: %.1: type = interface_type @HasF [template]
  22. // CHECK:STDOUT: %Self: HasF = bind_symbolic_name Self 0 [symbolic]
  23. // CHECK:STDOUT: %F.1: type = fn_type @F.1 [template]
  24. // CHECK:STDOUT: %.2: type = tuple_type () [template]
  25. // CHECK:STDOUT: %struct.1: F = struct_value () [template]
  26. // CHECK:STDOUT: %.3: type = assoc_entity_type @HasF, F [template]
  27. // CHECK:STDOUT: %.4: <associated F in HasF> = assoc_entity element0, @HasF.%F.decl [template]
  28. // CHECK:STDOUT: %C: type = class_type @C [template]
  29. // CHECK:STDOUT: %F.2: type = fn_type @F.2 [template]
  30. // CHECK:STDOUT: %struct.2: F = struct_value () [template]
  31. // CHECK:STDOUT: %.5: <witness> = interface_witness (%struct.2) [template]
  32. // CHECK:STDOUT: %.6: type = struct_type {} [template]
  33. // CHECK:STDOUT: %G: type = fn_type @G [template]
  34. // CHECK:STDOUT: %struct.3: G = struct_value () [template]
  35. // CHECK:STDOUT: %.7: type = ptr_type {} [template]
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT:
  38. // CHECK:STDOUT: file {
  39. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  40. // CHECK:STDOUT: .Core = %Core
  41. // CHECK:STDOUT: .HasF = %HasF.decl
  42. // CHECK:STDOUT: .C = %C.decl
  43. // CHECK:STDOUT: .G = %G.decl
  44. // CHECK:STDOUT: }
  45. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  46. // CHECK:STDOUT: %HasF.decl: type = interface_decl @HasF [template = constants.%.1] {}
  47. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {}
  48. // CHECK:STDOUT: %G.decl: G = fn_decl @G [template = constants.%struct.3] {
  49. // CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C]
  50. // CHECK:STDOUT: %c.loc17_6.1: C = param c
  51. // CHECK:STDOUT: @G.%c: C = bind_name c, %c.loc17_6.1
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT: }
  54. // CHECK:STDOUT:
  55. // CHECK:STDOUT: interface @HasF {
  56. // CHECK:STDOUT: %Self: HasF = bind_symbolic_name Self 0 [symbolic = constants.%Self]
  57. // CHECK:STDOUT: %F.decl: F = fn_decl @F.1 [template = constants.%struct.1] {}
  58. // CHECK:STDOUT: %.loc8: <associated F in HasF> = assoc_entity element0, %F.decl [template = constants.%.4]
  59. // CHECK:STDOUT:
  60. // CHECK:STDOUT: !members:
  61. // CHECK:STDOUT: .Self = %Self
  62. // CHECK:STDOUT: .F = %.loc8
  63. // CHECK:STDOUT: witness = (%F.decl)
  64. // CHECK:STDOUT: }
  65. // CHECK:STDOUT:
  66. // CHECK:STDOUT: impl @impl: C as HasF {
  67. // CHECK:STDOUT: %F.decl: F = fn_decl @F.2 [template = constants.%struct.2] {}
  68. // CHECK:STDOUT: %.1: <witness> = interface_witness (%F.decl) [template = constants.%.5]
  69. // CHECK:STDOUT:
  70. // CHECK:STDOUT: !members:
  71. // CHECK:STDOUT: .F = %F.decl
  72. // CHECK:STDOUT: witness = %.1
  73. // CHECK:STDOUT: }
  74. // CHECK:STDOUT:
  75. // CHECK:STDOUT: class @C {
  76. // CHECK:STDOUT: impl_decl @impl {
  77. // CHECK:STDOUT: %HasF.ref: type = name_ref HasF, file.%HasF.decl [template = constants.%.1]
  78. // CHECK:STDOUT: }
  79. // CHECK:STDOUT:
  80. // CHECK:STDOUT: !members:
  81. // CHECK:STDOUT: .Self = constants.%C
  82. // CHECK:STDOUT: extend name_scope2
  83. // CHECK:STDOUT: }
  84. // CHECK:STDOUT:
  85. // CHECK:STDOUT: fn @F.1();
  86. // CHECK:STDOUT:
  87. // CHECK:STDOUT: fn @F.2() {
  88. // CHECK:STDOUT: !entry:
  89. // CHECK:STDOUT: return
  90. // CHECK:STDOUT: }
  91. // CHECK:STDOUT:
  92. // CHECK:STDOUT: fn @G(%c: C) {
  93. // CHECK:STDOUT: !entry:
  94. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  95. // CHECK:STDOUT: %F.ref.loc18: <associated F in HasF> = name_ref F, @HasF.%.loc8 [template = constants.%.4]
  96. // CHECK:STDOUT: %.1: F = interface_witness_access @impl.%.1, element0 [template = constants.%struct.2]
  97. // CHECK:STDOUT: %F.call.loc18: init () = call %.1()
  98. // CHECK:STDOUT: %c.ref: C = name_ref c, %c
  99. // CHECK:STDOUT: %F.ref.loc19: <associated F in HasF> = name_ref F, @HasF.%.loc8 [template = constants.%.4]
  100. // CHECK:STDOUT: %.2: F = interface_witness_access @impl.%.1, element0 [template = constants.%struct.2]
  101. // CHECK:STDOUT: %F.call.loc19: init () = call %.2()
  102. // CHECK:STDOUT: return
  103. // CHECK:STDOUT: }
  104. // CHECK:STDOUT: