fail_base_method_define.carbon 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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+3]]:6: error: name `C` not found [NameNotFound]
  25. // CHECK:STDERR: fn D.C.F() {}
  26. // CHECK:STDERR: ^
  27. fn D.C.F() {}
  28. // CHECK:STDOUT: --- fail_base_method_define.carbon
  29. // CHECK:STDOUT:
  30. // CHECK:STDOUT: constants {
  31. // CHECK:STDOUT: %B: type = class_type @B [template]
  32. // CHECK:STDOUT: %F.type.1: type = fn_type @F.1 [template]
  33. // CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [template]
  34. // CHECK:STDOUT: %C: type = class_type @C [template]
  35. // CHECK:STDOUT: %F.type.2: type = fn_type @F.2 [template]
  36. // CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [template]
  37. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  38. // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
  39. // CHECK:STDOUT: %D: type = class_type @D [template]
  40. // CHECK:STDOUT: %.4: type = unbound_element_type %D, %B [template]
  41. // CHECK:STDOUT: %.5: type = struct_type {.base: %B} [template]
  42. // CHECK:STDOUT: %.6: <witness> = complete_type_witness %.5 [template]
  43. // CHECK:STDOUT: %F.type.3: type = fn_type @F.3 [template]
  44. // CHECK:STDOUT: %F.3: %F.type.3 = struct_value () [template]
  45. // CHECK:STDOUT: %.type: type = fn_type @.1 [template]
  46. // CHECK:STDOUT: %.7: %.type = struct_value () [template]
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT:
  49. // CHECK:STDOUT: imports {
  50. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  51. // CHECK:STDOUT: import Core//prelude
  52. // CHECK:STDOUT: import Core//prelude/...
  53. // CHECK:STDOUT: }
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT:
  56. // CHECK:STDOUT: file {
  57. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  58. // CHECK:STDOUT: .Core = imports.%Core
  59. // CHECK:STDOUT: .B = %B.decl
  60. // CHECK:STDOUT: .D = %D.decl
  61. // CHECK:STDOUT: }
  62. // CHECK:STDOUT: %Core.import = import Core
  63. // CHECK:STDOUT: %B.decl: type = class_decl @B [template = constants.%B] {} {}
  64. // CHECK:STDOUT: %D.decl: type = class_decl @D [template = constants.%D] {} {}
  65. // CHECK:STDOUT: %F.decl: %F.type.3 = fn_decl @F.3 [template = constants.%F.3] {} {}
  66. // CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.7] {} {}
  67. // CHECK:STDOUT: }
  68. // CHECK:STDOUT:
  69. // CHECK:STDOUT: class @B {
  70. // CHECK:STDOUT: %F.decl: %F.type.1 = fn_decl @F.1 [template = constants.%F.1] {} {}
  71. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  72. // CHECK:STDOUT: %.loc17: <witness> = complete_type_witness %.1 [template = constants.%.2]
  73. // CHECK:STDOUT:
  74. // CHECK:STDOUT: !members:
  75. // CHECK:STDOUT: .Self = constants.%B
  76. // CHECK:STDOUT: .F = %F.decl
  77. // CHECK:STDOUT: .C = %C.decl
  78. // CHECK:STDOUT: }
  79. // CHECK:STDOUT:
  80. // CHECK:STDOUT: class @C {
  81. // CHECK:STDOUT: %F.decl: %F.type.2 = fn_decl @F.2 [template = constants.%F.2] {} {}
  82. // CHECK:STDOUT: %.loc16: <witness> = complete_type_witness %.1 [template = constants.%.2]
  83. // CHECK:STDOUT:
  84. // CHECK:STDOUT: !members:
  85. // CHECK:STDOUT: .Self = constants.%C
  86. // CHECK:STDOUT: .F = %F.decl
  87. // CHECK:STDOUT: }
  88. // CHECK:STDOUT:
  89. // CHECK:STDOUT: class @D {
  90. // CHECK:STDOUT: %B.ref: type = name_ref B, file.%B.decl [template = constants.%B]
  91. // CHECK:STDOUT: %.loc20: %.4 = base_decl %B, element0 [template]
  92. // CHECK:STDOUT: %.loc21: <witness> = complete_type_witness %.5 [template = constants.%.6]
  93. // CHECK:STDOUT:
  94. // CHECK:STDOUT: !members:
  95. // CHECK:STDOUT: .Self = constants.%D
  96. // CHECK:STDOUT: .base = %.loc20
  97. // CHECK:STDOUT: .F = file.%F.decl
  98. // CHECK:STDOUT: extend %B.ref
  99. // CHECK:STDOUT: }
  100. // CHECK:STDOUT:
  101. // CHECK:STDOUT: fn @F.1();
  102. // CHECK:STDOUT:
  103. // CHECK:STDOUT: fn @F.2();
  104. // CHECK:STDOUT:
  105. // CHECK:STDOUT: fn @F.3() {
  106. // CHECK:STDOUT: !entry:
  107. // CHECK:STDOUT: return
  108. // CHECK:STDOUT: }
  109. // CHECK:STDOUT:
  110. // CHECK:STDOUT: fn @.1() {
  111. // CHECK:STDOUT: !entry:
  112. // CHECK:STDOUT: return
  113. // CHECK:STDOUT: }
  114. // CHECK:STDOUT: