fail_adapt_with_base.carbon 4.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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/adapter/fail_adapt_with_base.carbon
  11. // TIP: To dump output, run:
  12. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/adapter/fail_adapt_with_base.carbon
  13. class Simple {};
  14. base class AdaptWithVirtual {
  15. virtual fn F[self: Self]();
  16. // CHECK:STDERR: fail_adapt_with_base.carbon:[[@LINE+7]]:3: error: adapter with virtual function [AdaptWithVirtual]
  17. // CHECK:STDERR: adapt Simple;
  18. // CHECK:STDERR: ^~~~~~~~~~~~~
  19. // CHECK:STDERR: fail_adapt_with_base.carbon:[[@LINE-4]]:3: note: first virtual function declaration is here [AdaptWithVirtualHere]
  20. // CHECK:STDERR: virtual fn F[self: Self]();
  21. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~
  22. // CHECK:STDERR:
  23. adapt Simple;
  24. }
  25. // CHECK:STDOUT: --- fail_adapt_with_base.carbon
  26. // CHECK:STDOUT:
  27. // CHECK:STDOUT: constants {
  28. // CHECK:STDOUT: %Simple: type = class_type @Simple [concrete]
  29. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  30. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  31. // CHECK:STDOUT: %AdaptWithVirtual: type = class_type @AdaptWithVirtual [concrete]
  32. // CHECK:STDOUT: %pattern_type: type = pattern_type %AdaptWithVirtual [concrete]
  33. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  34. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  35. // CHECK:STDOUT: }
  36. // CHECK:STDOUT:
  37. // CHECK:STDOUT: imports {
  38. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  39. // CHECK:STDOUT: import Core//prelude
  40. // CHECK:STDOUT: import Core//prelude/...
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT:
  44. // CHECK:STDOUT: file {
  45. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  46. // CHECK:STDOUT: .Core = imports.%Core
  47. // CHECK:STDOUT: .Simple = %Simple.decl
  48. // CHECK:STDOUT: .AdaptWithVirtual = %AdaptWithVirtual.decl
  49. // CHECK:STDOUT: }
  50. // CHECK:STDOUT: %Core.import = import Core
  51. // CHECK:STDOUT: %Simple.decl: type = class_decl @Simple [concrete = constants.%Simple] {} {}
  52. // CHECK:STDOUT: %AdaptWithVirtual.decl: type = class_decl @AdaptWithVirtual [concrete = constants.%AdaptWithVirtual] {} {}
  53. // CHECK:STDOUT: }
  54. // CHECK:STDOUT:
  55. // CHECK:STDOUT: class @Simple {
  56. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete = constants.%empty_struct_type]
  57. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type]
  58. // CHECK:STDOUT: complete_type_witness = %complete_type
  59. // CHECK:STDOUT:
  60. // CHECK:STDOUT: !members:
  61. // CHECK:STDOUT: .Self = constants.%Simple
  62. // CHECK:STDOUT: }
  63. // CHECK:STDOUT:
  64. // CHECK:STDOUT: class @AdaptWithVirtual {
  65. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  66. // CHECK:STDOUT: %self.patt: %pattern_type = binding_pattern self [concrete]
  67. // CHECK:STDOUT: %self.param_patt: %pattern_type = value_param_pattern %self.patt, call_param0 [concrete]
  68. // CHECK:STDOUT: } {
  69. // CHECK:STDOUT: %self.param: %AdaptWithVirtual = value_param call_param0
  70. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%AdaptWithVirtual [concrete = constants.%AdaptWithVirtual]
  71. // CHECK:STDOUT: %self: %AdaptWithVirtual = bind_name self, %self.param
  72. // CHECK:STDOUT: }
  73. // CHECK:STDOUT: %Simple.ref: type = name_ref Simple, file.%Simple.decl [concrete = constants.%Simple]
  74. // CHECK:STDOUT: adapt_decl %Simple.ref [concrete]
  75. // CHECK:STDOUT: complete_type_witness = <error>
  76. // CHECK:STDOUT:
  77. // CHECK:STDOUT: !members:
  78. // CHECK:STDOUT: .Self = constants.%AdaptWithVirtual
  79. // CHECK:STDOUT: .F = %F.decl
  80. // CHECK:STDOUT: .Simple = <poisoned>
  81. // CHECK:STDOUT: }
  82. // CHECK:STDOUT:
  83. // CHECK:STDOUT: virtual fn @F(%self.param: %AdaptWithVirtual);
  84. // CHECK:STDOUT: