fail_base_method_define.carbon 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  6. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  7. //
  8. // AUTOUPDATE
  9. // TIP: To test this file alone, run:
  10. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/class/fail_base_method_define.carbon
  11. // TIP: To dump output, run:
  12. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/fail_base_method_define.carbon
  13. base class B {
  14. fn F();
  15. class C {
  16. fn F();
  17. }
  18. }
  19. class D {
  20. extend base: B;
  21. }
  22. // CHECK:STDERR: fail_base_method_define.carbon:[[@LINE+4]]:6: error: out-of-line declaration requires a declaration in scoped entity [QualifiedDeclOutsideScopeEntity]
  23. // CHECK:STDERR: fn D.F() {}
  24. // CHECK:STDERR: ^
  25. // CHECK:STDERR:
  26. fn D.F() {}
  27. // CHECK:STDERR: fail_base_method_define.carbon:[[@LINE+4]]:6: error: name `C` not found [NameNotFound]
  28. // CHECK:STDERR: fn D.C.F() {}
  29. // CHECK:STDERR: ^
  30. // CHECK:STDERR:
  31. fn D.C.F() {}
  32. // CHECK:STDOUT: --- fail_base_method_define.carbon
  33. // CHECK:STDOUT:
  34. // CHECK:STDOUT: constants {
  35. // CHECK:STDOUT: %B: type = class_type @B [concrete]
  36. // CHECK:STDOUT: %F.type.8c6: type = fn_type @F.1 [concrete]
  37. // CHECK:STDOUT: %F.92a: %F.type.8c6 = struct_value () [concrete]
  38. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  39. // CHECK:STDOUT: %F.type.b77: type = fn_type @F.2 [concrete]
  40. // CHECK:STDOUT: %F.a5f: %F.type.b77 = struct_value () [concrete]
  41. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  42. // CHECK:STDOUT: %complete_type.357: <witness> = complete_type_witness %empty_struct_type [concrete]
  43. // CHECK:STDOUT: %D: type = class_type @D [concrete]
  44. // CHECK:STDOUT: %D.elem: type = unbound_element_type %D, %B [concrete]
  45. // CHECK:STDOUT: %struct_type.base: type = struct_type {.base: %B} [concrete]
  46. // CHECK:STDOUT: %complete_type.98e: <witness> = complete_type_witness %struct_type.base [concrete]
  47. // CHECK:STDOUT: %F.type.31906b.1: type = fn_type @F.3 [concrete]
  48. // CHECK:STDOUT: %F.34b733.1: %F.type.31906b.1 = struct_value () [concrete]
  49. // CHECK:STDOUT: %F.type.31906b.2: type = fn_type @F.4 [concrete]
  50. // CHECK:STDOUT: %F.34b733.2: %F.type.31906b.2 = struct_value () [concrete]
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT:
  53. // CHECK:STDOUT: imports {
  54. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  55. // CHECK:STDOUT: import Core//prelude
  56. // CHECK:STDOUT: import Core//prelude/...
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT: }
  59. // CHECK:STDOUT:
  60. // CHECK:STDOUT: file {
  61. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  62. // CHECK:STDOUT: .Core = imports.%Core
  63. // CHECK:STDOUT: .B = %B.decl
  64. // CHECK:STDOUT: .D = %D.decl
  65. // CHECK:STDOUT: }
  66. // CHECK:STDOUT: %Core.import = import Core
  67. // CHECK:STDOUT: %B.decl: type = class_decl @B [concrete = constants.%B] {} {}
  68. // CHECK:STDOUT: %D.decl: type = class_decl @D [concrete = constants.%D] {} {}
  69. // CHECK:STDOUT: %F.decl.loc30: %F.type.31906b.1 = fn_decl @F.3 [concrete = constants.%F.34b733.1] {} {}
  70. // CHECK:STDOUT: %F.decl.loc36: %F.type.31906b.2 = fn_decl @F.4 [concrete = constants.%F.34b733.2] {} {}
  71. // CHECK:STDOUT: }
  72. // CHECK:STDOUT:
  73. // CHECK:STDOUT: class @B {
  74. // CHECK:STDOUT: %F.decl: %F.type.8c6 = fn_decl @F.1 [concrete = constants.%F.92a] {} {}
  75. // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {}
  76. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete = constants.%empty_struct_type]
  77. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type.357]
  78. // CHECK:STDOUT: complete_type_witness = %complete_type
  79. // CHECK:STDOUT:
  80. // CHECK:STDOUT: !members:
  81. // CHECK:STDOUT: .Self = constants.%B
  82. // CHECK:STDOUT: .F = %F.decl
  83. // CHECK:STDOUT: .C = %C.decl
  84. // CHECK:STDOUT: }
  85. // CHECK:STDOUT:
  86. // CHECK:STDOUT: class @C {
  87. // CHECK:STDOUT: %F.decl: %F.type.b77 = fn_decl @F.2 [concrete = constants.%F.a5f] {} {}
  88. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete = constants.%empty_struct_type]
  89. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type.357]
  90. // CHECK:STDOUT: complete_type_witness = %complete_type
  91. // CHECK:STDOUT:
  92. // CHECK:STDOUT: !members:
  93. // CHECK:STDOUT: .Self = constants.%C
  94. // CHECK:STDOUT: .F = %F.decl
  95. // CHECK:STDOUT: }
  96. // CHECK:STDOUT:
  97. // CHECK:STDOUT: class @D {
  98. // CHECK:STDOUT: %B.ref: type = name_ref B, file.%B.decl [concrete = constants.%B]
  99. // CHECK:STDOUT: %.loc23: %D.elem = base_decl %B.ref, element0 [concrete]
  100. // CHECK:STDOUT: %struct_type.base: type = struct_type {.base: %B} [concrete = constants.%struct_type.base]
  101. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.base [concrete = constants.%complete_type.98e]
  102. // CHECK:STDOUT: complete_type_witness = %complete_type
  103. // CHECK:STDOUT:
  104. // CHECK:STDOUT: !members:
  105. // CHECK:STDOUT: .Self = constants.%D
  106. // CHECK:STDOUT: .B = <poisoned>
  107. // CHECK:STDOUT: .base = %.loc23
  108. // CHECK:STDOUT: .F = file.%F.decl.loc30
  109. // CHECK:STDOUT: extend %B.ref
  110. // CHECK:STDOUT: }
  111. // CHECK:STDOUT:
  112. // CHECK:STDOUT: fn @F.1();
  113. // CHECK:STDOUT:
  114. // CHECK:STDOUT: fn @F.2();
  115. // CHECK:STDOUT:
  116. // CHECK:STDOUT: fn @F.3() {
  117. // CHECK:STDOUT: !entry:
  118. // CHECK:STDOUT: return
  119. // CHECK:STDOUT: }
  120. // CHECK:STDOUT:
  121. // CHECK:STDOUT: fn @F.4() {
  122. // CHECK:STDOUT: !entry:
  123. // CHECK:STDOUT: return
  124. // CHECK:STDOUT: }
  125. // CHECK:STDOUT: