base_function_unqualified.carbon 4.9 KB

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