fail_extend_impl_scope.carbon 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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/fail_extend_impl_scope.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/fail_extend_impl_scope.carbon
  10. interface I {}
  11. // CHECK:STDERR: fail_extend_impl_scope.carbon:[[@LINE+3]]:1: error: `extend impl` can only be used in a class
  12. // CHECK:STDERR: extend impl i32 as I {}
  13. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~
  14. extend impl i32 as I {}
  15. // CHECK:STDOUT: --- fail_extend_impl_scope.carbon
  16. // CHECK:STDOUT:
  17. // CHECK:STDOUT: constants {
  18. // CHECK:STDOUT: %.1: type = interface_type @I [template]
  19. // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self, 0 [symbolic]
  20. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  21. // CHECK:STDOUT: %.2: type = tuple_type () [template]
  22. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  23. // CHECK:STDOUT: %.3: <witness> = interface_witness () [template]
  24. // CHECK:STDOUT: }
  25. // CHECK:STDOUT:
  26. // CHECK:STDOUT: imports {
  27. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  28. // CHECK:STDOUT: .Int32 = %import_ref
  29. // CHECK:STDOUT: import Core//prelude
  30. // CHECK:STDOUT: import Core//prelude/operators
  31. // CHECK:STDOUT: import Core//prelude/types
  32. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  33. // CHECK:STDOUT: import Core//prelude/operators/as
  34. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  35. // CHECK:STDOUT: import Core//prelude/operators/comparison
  36. // CHECK:STDOUT: import Core//prelude/types/bool
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT:
  41. // CHECK:STDOUT: file {
  42. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  43. // CHECK:STDOUT: .Core = imports.%Core
  44. // CHECK:STDOUT: .I = %I.decl
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT: %Core.import = import Core
  47. // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%.1] {} {}
  48. // CHECK:STDOUT: impl_decl @impl [template] {} {
  49. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  50. // CHECK:STDOUT: %.loc16_13.1: type = value_of_initializer %int.make_type_32 [template = i32]
  51. // CHECK:STDOUT: %.loc16_13.2: type = converted %int.make_type_32, %.loc16_13.1 [template = i32]
  52. // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [template = constants.%.1]
  53. // CHECK:STDOUT: }
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT:
  56. // CHECK:STDOUT: interface @I {
  57. // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
  58. // CHECK:STDOUT:
  59. // CHECK:STDOUT: !members:
  60. // CHECK:STDOUT: .Self = %Self
  61. // CHECK:STDOUT: witness = ()
  62. // CHECK:STDOUT: }
  63. // CHECK:STDOUT:
  64. // CHECK:STDOUT: impl @impl: %.loc16_13.2 as %I.ref {
  65. // CHECK:STDOUT: %.loc16_22: <witness> = interface_witness () [template = constants.%.3]
  66. // CHECK:STDOUT:
  67. // CHECK:STDOUT: !members:
  68. // CHECK:STDOUT: witness = %.loc16_22
  69. // CHECK:STDOUT: }
  70. // CHECK:STDOUT:
  71. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  72. // CHECK:STDOUT: