fail_extend_non_interface.carbon 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/int.carbon
  6. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  7. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  8. //
  9. // AUTOUPDATE
  10. // TIP: To test this file alone, run:
  11. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/impl/fail_extend_non_interface.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/fail_extend_non_interface.carbon
  14. class C {
  15. // CHECK:STDERR: fail_extend_non_interface.carbon:[[@LINE+4]]:3: error: impl as non-facet type `i32` [ImplAsNonFacetType]
  16. // CHECK:STDERR: extend impl as i32;
  17. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~
  18. // CHECK:STDERR:
  19. extend impl as i32;
  20. }
  21. // CHECK:STDOUT: --- fail_extend_non_interface.carbon
  22. // CHECK:STDOUT:
  23. // CHECK:STDOUT: constants {
  24. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  25. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  26. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  27. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  28. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  29. // CHECK:STDOUT: %Destroy.type: type = facet_type <@Destroy> [concrete]
  30. // CHECK:STDOUT: %pattern_type.f6d: type = pattern_type auto [concrete]
  31. // CHECK:STDOUT: %Destroy.impl_witness: <witness> = impl_witness @C.%Destroy.impl_witness_table [concrete]
  32. // CHECK:STDOUT: %ptr.019: type = ptr_type %C [concrete]
  33. // CHECK:STDOUT: %pattern_type.44a: type = pattern_type %ptr.019 [concrete]
  34. // CHECK:STDOUT: %C.as.Destroy.impl.Op.type: type = fn_type @C.as.Destroy.impl.Op [concrete]
  35. // CHECK:STDOUT: %C.as.Destroy.impl.Op: %C.as.Destroy.impl.Op.type = struct_value () [concrete]
  36. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  37. // CHECK:STDOUT: %complete_type.357: <witness> = complete_type_witness %empty_struct_type [concrete]
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT:
  40. // CHECK:STDOUT: imports {
  41. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  42. // CHECK:STDOUT: .Int = %Core.Int
  43. // CHECK:STDOUT: .Destroy = %Core.Destroy
  44. // CHECK:STDOUT: import Core//prelude
  45. // CHECK:STDOUT: import Core//prelude/...
  46. // CHECK:STDOUT: }
  47. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/parts/int, Int, loaded [concrete = constants.%Int.generic]
  48. // CHECK:STDOUT: %Core.Destroy: type = import_ref Core//prelude/parts/destroy, Destroy, loaded [concrete = constants.%Destroy.type]
  49. // CHECK:STDOUT: }
  50. // CHECK:STDOUT:
  51. // CHECK:STDOUT: file {
  52. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  53. // CHECK:STDOUT: .Core = imports.%Core
  54. // CHECK:STDOUT: .C = %C.decl
  55. // CHECK:STDOUT: }
  56. // CHECK:STDOUT: %Core.import = import Core
  57. // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {}
  58. // CHECK:STDOUT: }
  59. // CHECK:STDOUT:
  60. // CHECK:STDOUT: impl @C.as.<error>.impl: %Self.ref as %i32;
  61. // CHECK:STDOUT:
  62. // CHECK:STDOUT: impl @C.as.Destroy.impl: @C.%Self.ref as constants.%Destroy.type {
  63. // CHECK:STDOUT: %C.as.Destroy.impl.Op.decl: %C.as.Destroy.impl.Op.type = fn_decl @C.as.Destroy.impl.Op [concrete = constants.%C.as.Destroy.impl.Op] {
  64. // CHECK:STDOUT: %self.patt: %pattern_type.44a = binding_pattern self [concrete]
  65. // CHECK:STDOUT: %self.param_patt: %pattern_type.44a = value_param_pattern %self.patt, call_param0 [concrete]
  66. // CHECK:STDOUT: %.loc15: %pattern_type.f6d = addr_pattern %self.param_patt [concrete]
  67. // CHECK:STDOUT: } {
  68. // CHECK:STDOUT: %self.param: %ptr.019 = value_param call_param0
  69. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%C [concrete = constants.%C]
  70. // CHECK:STDOUT: %self: %ptr.019 = bind_name self, %self.param
  71. // CHECK:STDOUT: }
  72. // CHECK:STDOUT:
  73. // CHECK:STDOUT: !members:
  74. // CHECK:STDOUT: .Op = %C.as.Destroy.impl.Op.decl
  75. // CHECK:STDOUT: witness = @C.%Destroy.impl_witness
  76. // CHECK:STDOUT: }
  77. // CHECK:STDOUT:
  78. // CHECK:STDOUT: class @C {
  79. // CHECK:STDOUT: impl_decl @C.as.<error>.impl [concrete] {} {
  80. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%C [concrete = constants.%C]
  81. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  82. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  83. // CHECK:STDOUT: }
  84. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%C [concrete = constants.%C]
  85. // CHECK:STDOUT: impl_decl @C.as.Destroy.impl [concrete] {} {}
  86. // CHECK:STDOUT: %Destroy.impl_witness_table = impl_witness_table (@C.as.Destroy.impl.%C.as.Destroy.impl.Op.decl), @C.as.Destroy.impl [concrete]
  87. // CHECK:STDOUT: %Destroy.impl_witness: <witness> = impl_witness %Destroy.impl_witness_table [concrete = constants.%Destroy.impl_witness]
  88. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type.357]
  89. // CHECK:STDOUT: complete_type_witness = %complete_type
  90. // CHECK:STDOUT:
  91. // CHECK:STDOUT: !members:
  92. // CHECK:STDOUT: .Self = constants.%C
  93. // CHECK:STDOUT: extend @C.as.<error>.impl.%i32
  94. // CHECK:STDOUT: has_error
  95. // CHECK:STDOUT: }
  96. // CHECK:STDOUT:
  97. // CHECK:STDOUT: fn @C.as.Destroy.impl.Op(%self.param: %ptr.019) = "no_op";
  98. // CHECK:STDOUT: