base_function_unqualified.carbon 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/class/base_function_unqualified.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/base_function_unqualified.carbon
  10. base class Base {
  11. fn F();
  12. }
  13. class Derived {
  14. extend base: Base;
  15. fn G() { F(); }
  16. fn H();
  17. }
  18. fn Derived.H() {
  19. F();
  20. }
  21. // CHECK:STDOUT: --- base_function_unqualified.carbon
  22. // CHECK:STDOUT:
  23. // CHECK:STDOUT: constants {
  24. // CHECK:STDOUT: %Base: type = class_type @Base [concrete]
  25. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  26. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  27. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  28. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  29. // CHECK:STDOUT: %complete_type.357: <witness> = complete_type_witness %empty_struct_type [concrete]
  30. // CHECK:STDOUT: %Derived: type = class_type @Derived [concrete]
  31. // CHECK:STDOUT: %Derived.elem: type = unbound_element_type %Derived, %Base [concrete]
  32. // CHECK:STDOUT: %G.type: type = fn_type @G [concrete]
  33. // CHECK:STDOUT: %G: %G.type = struct_value () [concrete]
  34. // CHECK:STDOUT: %H.type: type = fn_type @H [concrete]
  35. // CHECK:STDOUT: %H: %H.type = struct_value () [concrete]
  36. // CHECK:STDOUT: %struct_type.base: type = struct_type {.base: %Base} [concrete]
  37. // CHECK:STDOUT: %complete_type.15c: <witness> = complete_type_witness %struct_type.base [concrete]
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT:
  40. // CHECK:STDOUT: imports {
  41. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  42. // CHECK:STDOUT: import Core//prelude
  43. // CHECK:STDOUT: import Core//prelude/...
  44. // CHECK:STDOUT: }
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT:
  47. // CHECK:STDOUT: file {
  48. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  49. // CHECK:STDOUT: .Core = imports.%Core
  50. // CHECK:STDOUT: .Base = %Base.decl
  51. // CHECK:STDOUT: .Derived = %Derived.decl
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT: %Core.import = import Core
  54. // CHECK:STDOUT: %Base.decl: type = class_decl @Base [concrete = constants.%Base] {} {}
  55. // CHECK:STDOUT: %Derived.decl: type = class_decl @Derived [concrete = constants.%Derived] {} {}
  56. // CHECK:STDOUT: %H.decl: %H.type = fn_decl @H [concrete = constants.%H] {} {}
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT:
  59. // CHECK:STDOUT: class @Base {
  60. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {} {}
  61. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete = constants.%empty_struct_type]
  62. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type.357]
  63. // CHECK:STDOUT: complete_type_witness = %complete_type
  64. // CHECK:STDOUT:
  65. // CHECK:STDOUT: !members:
  66. // CHECK:STDOUT: .Self = constants.%Base
  67. // CHECK:STDOUT: .F = %F.decl
  68. // CHECK:STDOUT: }
  69. // CHECK:STDOUT:
  70. // CHECK:STDOUT: class @Derived {
  71. // CHECK:STDOUT: %Base.ref: type = name_ref Base, file.%Base.decl [concrete = constants.%Base]
  72. // CHECK:STDOUT: %.loc16: %Derived.elem = base_decl %Base.ref, element0 [concrete]
  73. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [concrete = constants.%G] {} {}
  74. // CHECK:STDOUT: %H.decl: %H.type = fn_decl @H [concrete = constants.%H] {} {}
  75. // CHECK:STDOUT: %struct_type.base: type = struct_type {.base: %Base} [concrete = constants.%struct_type.base]
  76. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.base [concrete = constants.%complete_type.15c]
  77. // CHECK:STDOUT: complete_type_witness = %complete_type
  78. // CHECK:STDOUT:
  79. // CHECK:STDOUT: !members:
  80. // CHECK:STDOUT: .Self = constants.%Derived
  81. // CHECK:STDOUT: .Base = <poisoned>
  82. // CHECK:STDOUT: .base = %.loc16
  83. // CHECK:STDOUT: .G = %G.decl
  84. // CHECK:STDOUT: .H = %H.decl
  85. // CHECK:STDOUT: .F = <poisoned>
  86. // CHECK:STDOUT: extend %Base.ref
  87. // CHECK:STDOUT: }
  88. // CHECK:STDOUT:
  89. // CHECK:STDOUT: fn @F();
  90. // CHECK:STDOUT:
  91. // CHECK:STDOUT: fn @G() {
  92. // CHECK:STDOUT: !entry:
  93. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, @Base.%F.decl [concrete = constants.%F]
  94. // CHECK:STDOUT: %F.call: init %empty_tuple.type = call %F.ref()
  95. // CHECK:STDOUT: return
  96. // CHECK:STDOUT: }
  97. // CHECK:STDOUT:
  98. // CHECK:STDOUT: fn @H() {
  99. // CHECK:STDOUT: !entry:
  100. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, @Base.%F.decl [concrete = constants.%F]
  101. // CHECK:STDOUT: %F.call: init %empty_tuple.type = call %F.ref()
  102. // CHECK:STDOUT: return
  103. // CHECK:STDOUT: }
  104. // CHECK:STDOUT: