fail_impl_as_scope.carbon 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. interface Simple {
  7. fn F();
  8. }
  9. // CHECK:STDERR: fail_impl_as_scope.carbon:[[@LINE+3]]:6: ERROR: `impl as` can only be used in a class.
  10. // CHECK:STDERR: impl as Simple {
  11. // CHECK:STDERR: ^~
  12. impl as Simple {
  13. fn F() {}
  14. }
  15. // CHECK:STDOUT: --- fail_impl_as_scope.carbon
  16. // CHECK:STDOUT:
  17. // CHECK:STDOUT: constants {
  18. // CHECK:STDOUT: %.1: type = interface_type @Simple [template]
  19. // CHECK:STDOUT: %Self: Simple = bind_symbolic_name Self 0 [symbolic]
  20. // CHECK:STDOUT: %F.1: type = fn_type @F.1 [template]
  21. // CHECK:STDOUT: %.2: type = tuple_type () [template]
  22. // CHECK:STDOUT: %struct.1: F = struct_value () [template]
  23. // CHECK:STDOUT: %.3: type = assoc_entity_type @Simple, F [template]
  24. // CHECK:STDOUT: %.4: <associated F in Simple> = assoc_entity element0, @Simple.%F.decl [template]
  25. // CHECK:STDOUT: %F.2: type = fn_type @F.2 [template]
  26. // CHECK:STDOUT: %struct.2: F = struct_value () [template]
  27. // CHECK:STDOUT: %.5: <witness> = interface_witness (%struct.2) [template]
  28. // CHECK:STDOUT: }
  29. // CHECK:STDOUT:
  30. // CHECK:STDOUT: file {
  31. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  32. // CHECK:STDOUT: .Core = %Core
  33. // CHECK:STDOUT: .Simple = %Simple.decl
  34. // CHECK:STDOUT: }
  35. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  36. // CHECK:STDOUT: %Simple.decl: type = interface_decl @Simple [template = constants.%.1] {}
  37. // CHECK:STDOUT: impl_decl @impl {
  38. // CHECK:STDOUT: %Simple.ref: type = name_ref Simple, %Simple.decl [template = constants.%.1]
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT:
  42. // CHECK:STDOUT: interface @Simple {
  43. // CHECK:STDOUT: %Self: Simple = bind_symbolic_name Self 0 [symbolic = constants.%Self]
  44. // CHECK:STDOUT: %F.decl: F = fn_decl @F.1 [template = constants.%struct.1] {}
  45. // CHECK:STDOUT: %.loc8: <associated F in Simple> = assoc_entity element0, %F.decl [template = constants.%.4]
  46. // CHECK:STDOUT:
  47. // CHECK:STDOUT: !members:
  48. // CHECK:STDOUT: .Self = %Self
  49. // CHECK:STDOUT: .F = %.loc8
  50. // CHECK:STDOUT: witness = (%F.decl)
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT:
  53. // CHECK:STDOUT: impl @impl: <error> as Simple {
  54. // CHECK:STDOUT: %F.decl: F = fn_decl @F.2 [template = constants.%struct.2] {}
  55. // CHECK:STDOUT: %.1: <witness> = interface_witness (%F.decl) [template = constants.%.5]
  56. // CHECK:STDOUT:
  57. // CHECK:STDOUT: !members:
  58. // CHECK:STDOUT: .F = %F.decl
  59. // CHECK:STDOUT: witness = %.1
  60. // CHECK:STDOUT: }
  61. // CHECK:STDOUT:
  62. // CHECK:STDOUT: fn @F.1();
  63. // CHECK:STDOUT:
  64. // CHECK:STDOUT: fn @F.2() {
  65. // CHECK:STDOUT: !entry:
  66. // CHECK:STDOUT: return
  67. // CHECK:STDOUT: }
  68. // CHECK:STDOUT: