fail_undefined_interface.carbon 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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/impl/no_prelude/fail_undefined_interface.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/no_prelude/fail_undefined_interface.carbon
  10. // --- fail_empty_struct.carbon
  11. library "[[@TEST_NAME]]";
  12. interface I;
  13. // CHECK:STDERR: fail_empty_struct.carbon:[[@LINE+7]]:1: error: implementation of undefined interface I [ImplOfUndefinedInterface]
  14. // CHECK:STDERR: impl {} as I {}
  15. // CHECK:STDERR: ^~~~~~~~~~~~~~
  16. // CHECK:STDERR: fail_empty_struct.carbon:[[@LINE-4]]:1: note: interface was forward declared here [InterfaceForwardDeclaredHere]
  17. // CHECK:STDERR: interface I;
  18. // CHECK:STDERR: ^~~~~~~~~~~~
  19. // CHECK:STDERR:
  20. impl {} as I {}
  21. // --- fail_class.carbon
  22. library "[[@TEST_NAME]]";
  23. interface J;
  24. class C {}
  25. // CHECK:STDERR: fail_class.carbon:[[@LINE+6]]:1: error: implementation of undefined interface J [ImplOfUndefinedInterface]
  26. // CHECK:STDERR: impl C as J {}
  27. // CHECK:STDERR: ^~~~~~~~~~~~~
  28. // CHECK:STDERR: fail_class.carbon:[[@LINE-5]]:1: note: interface was forward declared here [InterfaceForwardDeclaredHere]
  29. // CHECK:STDERR: interface J;
  30. // CHECK:STDERR: ^~~~~~~~~~~~
  31. impl C as J {}
  32. // CHECK:STDOUT: --- fail_empty_struct.carbon
  33. // CHECK:STDOUT:
  34. // CHECK:STDOUT: constants {
  35. // CHECK:STDOUT: %I.type: type = interface_type @I [template]
  36. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  37. // CHECK:STDOUT: %.2: type = tuple_type () [template]
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT:
  40. // CHECK:STDOUT: file {
  41. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  42. // CHECK:STDOUT: .I = %I.decl
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%I.type] {} {}
  45. // CHECK:STDOUT: impl_decl @impl [template] {} {
  46. // CHECK:STDOUT: %.loc12_7.1: %.1 = struct_literal ()
  47. // CHECK:STDOUT: %.loc12_7.2: type = converted %.loc12_7.1, constants.%.1 [template = constants.%.1]
  48. // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [template = constants.%I.type]
  49. // CHECK:STDOUT: }
  50. // CHECK:STDOUT: }
  51. // CHECK:STDOUT:
  52. // CHECK:STDOUT: interface @I;
  53. // CHECK:STDOUT:
  54. // CHECK:STDOUT: impl @impl: %.loc12_7.2 as %I.ref {
  55. // CHECK:STDOUT: !members:
  56. // CHECK:STDOUT: witness = <error>
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT:
  59. // CHECK:STDOUT: --- fail_class.carbon
  60. // CHECK:STDOUT:
  61. // CHECK:STDOUT: constants {
  62. // CHECK:STDOUT: %J.type: type = interface_type @J [template]
  63. // CHECK:STDOUT: %C: type = class_type @C [template]
  64. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  65. // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
  66. // CHECK:STDOUT: %.3: type = tuple_type () [template]
  67. // CHECK:STDOUT: }
  68. // CHECK:STDOUT:
  69. // CHECK:STDOUT: file {
  70. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  71. // CHECK:STDOUT: .J = %J.decl
  72. // CHECK:STDOUT: .C = %C.decl
  73. // CHECK:STDOUT: }
  74. // CHECK:STDOUT: %J.decl: type = interface_decl @J [template = constants.%J.type] {} {}
  75. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  76. // CHECK:STDOUT: impl_decl @impl [template] {} {
  77. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  78. // CHECK:STDOUT: %J.ref: type = name_ref J, file.%J.decl [template = constants.%J.type]
  79. // CHECK:STDOUT: }
  80. // CHECK:STDOUT: }
  81. // CHECK:STDOUT:
  82. // CHECK:STDOUT: interface @J;
  83. // CHECK:STDOUT:
  84. // CHECK:STDOUT: impl @impl: %C.ref as %J.ref {
  85. // CHECK:STDOUT: !members:
  86. // CHECK:STDOUT: witness = <error>
  87. // CHECK:STDOUT: }
  88. // CHECK:STDOUT:
  89. // CHECK:STDOUT: class @C {
  90. // CHECK:STDOUT: %.loc5: <witness> = complete_type_witness %.1 [template = constants.%.2]
  91. // CHECK:STDOUT:
  92. // CHECK:STDOUT: !members:
  93. // CHECK:STDOUT: .Self = constants.%C
  94. // CHECK:STDOUT: }
  95. // CHECK:STDOUT: