impl_as.carbon 3.6 KB

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