fail_extend_non_interface.carbon 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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: %empty_struct_type: type = struct_type {} [concrete]
  30. // CHECK:STDOUT: %complete_type.357: <witness> = complete_type_witness %empty_struct_type [concrete]
  31. // CHECK:STDOUT: }
  32. // CHECK:STDOUT:
  33. // CHECK:STDOUT: imports {
  34. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  35. // CHECK:STDOUT: .Int = %Core.Int
  36. // CHECK:STDOUT: import Core//prelude
  37. // CHECK:STDOUT: import Core//prelude/...
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/parts/int, Int, loaded [concrete = constants.%Int.generic]
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT:
  42. // CHECK:STDOUT: file {
  43. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  44. // CHECK:STDOUT: .Core = imports.%Core
  45. // CHECK:STDOUT: .C = %C.decl
  46. // CHECK:STDOUT: }
  47. // CHECK:STDOUT: %Core.import = import Core
  48. // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {}
  49. // CHECK:STDOUT: }
  50. // CHECK:STDOUT:
  51. // CHECK:STDOUT: impl @impl: %Self.ref as %i32;
  52. // CHECK:STDOUT:
  53. // CHECK:STDOUT: class @C {
  54. // CHECK:STDOUT: impl_decl @impl [concrete] {} {
  55. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%C [concrete = constants.%C]
  56. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  57. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  58. // CHECK:STDOUT: }
  59. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete = constants.%empty_struct_type]
  60. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type.357]
  61. // CHECK:STDOUT: complete_type_witness = %complete_type
  62. // CHECK:STDOUT:
  63. // CHECK:STDOUT: !members:
  64. // CHECK:STDOUT: .Self = constants.%C
  65. // CHECK:STDOUT: extend @impl.%i32
  66. // CHECK:STDOUT: has_error
  67. // CHECK:STDOUT: }
  68. // CHECK:STDOUT: