fail_adapt_with_base.carbon 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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[self: Self]();
  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[self: Self]();
  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: %self.patt: %AdaptWithVirtual = binding_pattern self
  62. // CHECK:STDOUT: %self.param_patt: %AdaptWithVirtual = value_param_pattern %self.patt, call_param0
  63. // CHECK:STDOUT: } {
  64. // CHECK:STDOUT: %self.param: %AdaptWithVirtual = value_param call_param0
  65. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%AdaptWithVirtual [concrete = constants.%AdaptWithVirtual]
  66. // CHECK:STDOUT: %self: %AdaptWithVirtual = bind_name self, %self.param
  67. // CHECK:STDOUT: }
  68. // CHECK:STDOUT: %Simple.ref: type = name_ref Simple, file.%Simple.decl [concrete = constants.%Simple]
  69. // CHECK:STDOUT: adapt_decl %Simple.ref [concrete]
  70. // CHECK:STDOUT: complete_type_witness = <error>
  71. // CHECK:STDOUT:
  72. // CHECK:STDOUT: !members:
  73. // CHECK:STDOUT: .Self = constants.%AdaptWithVirtual
  74. // CHECK:STDOUT: .F = %F.decl
  75. // CHECK:STDOUT: .Simple = <poisoned>
  76. // CHECK:STDOUT: }
  77. // CHECK:STDOUT:
  78. // CHECK:STDOUT: virtual fn @F[%self.param_patt: %AdaptWithVirtual]();
  79. // CHECK:STDOUT: