fail_adapt_with_base.carbon 3.3 KB

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