fail_base_method_define.carbon 5.5 KB

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