fail_todo_facet_lookup.carbon 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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/interface/no_prelude/fail_todo_facet_lookup.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interface/no_prelude/fail_todo_facet_lookup.carbon
  10. interface Interface { fn F(); }
  11. fn CallStatic(T:! Interface) {
  12. // CHECK:STDERR: fail_todo_facet_lookup.carbon:[[@LINE+4]]:3: error: value of type `<type of F>` is not callable [CallToNonCallable]
  13. // CHECK:STDERR: T.F();
  14. // CHECK:STDERR: ^~~~~
  15. // CHECK:STDERR:
  16. T.F();
  17. }
  18. fn CallFacet(T:! Interface, x: T) {
  19. // CHECK:STDERR: fail_todo_facet_lookup.carbon:[[@LINE+3]]:3: error: type `T` does not support qualified expressions [QualifiedExprUnsupported]
  20. // CHECK:STDERR: x.F();
  21. // CHECK:STDERR: ^~~
  22. x.F();
  23. }
  24. // CHECK:STDOUT: --- fail_todo_facet_lookup.carbon
  25. // CHECK:STDOUT:
  26. // CHECK:STDOUT: constants {
  27. // CHECK:STDOUT: %Interface.type: type = facet_type <@Interface> [template]
  28. // CHECK:STDOUT: %Self: %Interface.type = bind_symbolic_name Self, 0 [symbolic]
  29. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  30. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  31. // CHECK:STDOUT: %F.assoc_type: type = assoc_entity_type %Interface.type, %F.type [template]
  32. // CHECK:STDOUT: %assoc0: %F.assoc_type = assoc_entity element0, @Interface.%F.decl [template]
  33. // CHECK:STDOUT: %T: %Interface.type = bind_symbolic_name T, 0 [symbolic]
  34. // CHECK:STDOUT: %T.patt: %Interface.type = symbolic_binding_pattern T, 0 [symbolic]
  35. // CHECK:STDOUT: %CallStatic.type: type = fn_type @CallStatic [template]
  36. // CHECK:STDOUT: %CallStatic: %CallStatic.type = struct_value () [template]
  37. // CHECK:STDOUT: %T.as_wit: <witness> = facet_access_witness %T [symbolic]
  38. // CHECK:STDOUT: %impl.elem0: %F.type = impl_witness_access %T.as_wit, element0 [symbolic]
  39. // CHECK:STDOUT: %T.as_type: type = facet_access_type %T [symbolic]
  40. // CHECK:STDOUT: %CallFacet.type: type = fn_type @CallFacet [template]
  41. // CHECK:STDOUT: %CallFacet: %CallFacet.type = struct_value () [template]
  42. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type %T.as_type [symbolic]
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT:
  45. // CHECK:STDOUT: file {
  46. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  47. // CHECK:STDOUT: .Interface = %Interface.decl
  48. // CHECK:STDOUT: .CallStatic = %CallStatic.decl
  49. // CHECK:STDOUT: .CallFacet = %CallFacet.decl
  50. // CHECK:STDOUT: }
  51. // CHECK:STDOUT: %Interface.decl: type = interface_decl @Interface [template = constants.%Interface.type] {} {}
  52. // CHECK:STDOUT: %CallStatic.decl: %CallStatic.type = fn_decl @CallStatic [template = constants.%CallStatic] {
  53. // CHECK:STDOUT: %T.patt.loc13_15.1: %Interface.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc13_15.2 (constants.%T.patt)]
  54. // CHECK:STDOUT: %T.param_patt: %Interface.type = value_param_pattern %T.patt.loc13_15.1, runtime_param<invalid> [symbolic = %T.patt.loc13_15.2 (constants.%T.patt)]
  55. // CHECK:STDOUT: } {
  56. // CHECK:STDOUT: %T.param: %Interface.type = value_param runtime_param<invalid>
  57. // CHECK:STDOUT: %Interface.ref: type = name_ref Interface, file.%Interface.decl [template = constants.%Interface.type]
  58. // CHECK:STDOUT: %T.loc13_15.1: %Interface.type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc13_15.2 (constants.%T)]
  59. // CHECK:STDOUT: }
  60. // CHECK:STDOUT: %CallFacet.decl: %CallFacet.type = fn_decl @CallFacet [template = constants.%CallFacet] {
  61. // CHECK:STDOUT: %T.patt.loc21_14.1: %Interface.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc21_14.2 (constants.%T.patt)]
  62. // CHECK:STDOUT: %T.param_patt: %Interface.type = value_param_pattern %T.patt.loc21_14.1, runtime_param<invalid> [symbolic = %T.patt.loc21_14.2 (constants.%T.patt)]
  63. // CHECK:STDOUT: %x.patt: @CallFacet.%T.as_type.loc21_32.2 (%T.as_type) = binding_pattern x
  64. // CHECK:STDOUT: %x.param_patt: @CallFacet.%T.as_type.loc21_32.2 (%T.as_type) = value_param_pattern %x.patt, runtime_param0
  65. // CHECK:STDOUT: } {
  66. // CHECK:STDOUT: %T.param: %Interface.type = value_param runtime_param<invalid>
  67. // CHECK:STDOUT: %Interface.ref: type = name_ref Interface, file.%Interface.decl [template = constants.%Interface.type]
  68. // CHECK:STDOUT: %T.loc21_14.1: %Interface.type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc21_14.2 (constants.%T)]
  69. // CHECK:STDOUT: %x.param: @CallFacet.%T.as_type.loc21_32.2 (%T.as_type) = value_param runtime_param0
  70. // CHECK:STDOUT: %.loc21_32.1: type = splice_block %.loc21_32.2 [symbolic = %T.as_type.loc21_32.2 (constants.%T.as_type)] {
  71. // CHECK:STDOUT: %T.ref: %Interface.type = name_ref T, %T.loc21_14.1 [symbolic = %T.loc21_14.2 (constants.%T)]
  72. // CHECK:STDOUT: %T.as_type.loc21_32.1: type = facet_access_type %T.ref [symbolic = %T.as_type.loc21_32.2 (constants.%T.as_type)]
  73. // CHECK:STDOUT: %.loc21_32.2: type = converted %T.ref, %T.as_type.loc21_32.1 [symbolic = %T.as_type.loc21_32.2 (constants.%T.as_type)]
  74. // CHECK:STDOUT: }
  75. // CHECK:STDOUT: %x: @CallFacet.%T.as_type.loc21_32.2 (%T.as_type) = bind_name x, %x.param
  76. // CHECK:STDOUT: }
  77. // CHECK:STDOUT: }
  78. // CHECK:STDOUT:
  79. // CHECK:STDOUT: interface @Interface {
  80. // CHECK:STDOUT: %Self: %Interface.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
  81. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} {}
  82. // CHECK:STDOUT: %assoc0: %F.assoc_type = assoc_entity element0, %F.decl [template = constants.%assoc0]
  83. // CHECK:STDOUT:
  84. // CHECK:STDOUT: !members:
  85. // CHECK:STDOUT: .Self = %Self
  86. // CHECK:STDOUT: .F = %assoc0
  87. // CHECK:STDOUT: witness = (%F.decl)
  88. // CHECK:STDOUT: }
  89. // CHECK:STDOUT:
  90. // CHECK:STDOUT: generic fn @F(@Interface.%Self: %Interface.type) {
  91. // CHECK:STDOUT:
  92. // CHECK:STDOUT: fn();
  93. // CHECK:STDOUT: }
  94. // CHECK:STDOUT:
  95. // CHECK:STDOUT: generic fn @CallStatic(%T.loc13_15.1: %Interface.type) {
  96. // CHECK:STDOUT: %T.loc13_15.2: %Interface.type = bind_symbolic_name T, 0 [symbolic = %T.loc13_15.2 (constants.%T)]
  97. // CHECK:STDOUT: %T.patt.loc13_15.2: %Interface.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc13_15.2 (constants.%T.patt)]
  98. // CHECK:STDOUT:
  99. // CHECK:STDOUT: !definition:
  100. // CHECK:STDOUT: %T.as_wit.loc18_4.2: <witness> = facet_access_witness %T.loc13_15.2 [symbolic = %T.as_wit.loc18_4.2 (constants.%T.as_wit)]
  101. // CHECK:STDOUT: %impl.elem0.loc18_4.2: %F.type = impl_witness_access %T.as_wit.loc18_4.2, element0 [symbolic = %impl.elem0.loc18_4.2 (constants.%impl.elem0)]
  102. // CHECK:STDOUT:
  103. // CHECK:STDOUT: fn(%T.param_patt: %Interface.type) {
  104. // CHECK:STDOUT: !entry:
  105. // CHECK:STDOUT: %T.ref: %Interface.type = name_ref T, %T.loc13_15.1 [symbolic = %T.loc13_15.2 (constants.%T)]
  106. // CHECK:STDOUT: %F.ref: %F.assoc_type = name_ref F, @Interface.%assoc0 [template = constants.%assoc0]
  107. // CHECK:STDOUT: %T.as_wit.loc18_4.1: <witness> = facet_access_witness %T.ref [symbolic = %T.as_wit.loc18_4.2 (constants.%T.as_wit)]
  108. // CHECK:STDOUT: %impl.elem0.loc18_4.1: %F.type = impl_witness_access %T.as_wit.loc18_4.1, element0 [symbolic = %impl.elem0.loc18_4.2 (constants.%impl.elem0)]
  109. // CHECK:STDOUT: return
  110. // CHECK:STDOUT: }
  111. // CHECK:STDOUT: }
  112. // CHECK:STDOUT:
  113. // CHECK:STDOUT: generic fn @CallFacet(%T.loc21_14.1: %Interface.type) {
  114. // CHECK:STDOUT: %T.loc21_14.2: %Interface.type = bind_symbolic_name T, 0 [symbolic = %T.loc21_14.2 (constants.%T)]
  115. // CHECK:STDOUT: %T.patt.loc21_14.2: %Interface.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc21_14.2 (constants.%T.patt)]
  116. // CHECK:STDOUT: %T.as_type.loc21_32.2: type = facet_access_type %T.loc21_14.2 [symbolic = %T.as_type.loc21_32.2 (constants.%T.as_type)]
  117. // CHECK:STDOUT:
  118. // CHECK:STDOUT: !definition:
  119. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type @CallFacet.%T.as_type.loc21_32.2 (%T.as_type) [symbolic = %require_complete (constants.%require_complete)]
  120. // CHECK:STDOUT:
  121. // CHECK:STDOUT: fn(%T.param_patt: %Interface.type, %x.param_patt: @CallFacet.%T.as_type.loc21_32.2 (%T.as_type)) {
  122. // CHECK:STDOUT: !entry:
  123. // CHECK:STDOUT: %x.ref: @CallFacet.%T.as_type.loc21_32.2 (%T.as_type) = name_ref x, %x
  124. // CHECK:STDOUT: return
  125. // CHECK:STDOUT: }
  126. // CHECK:STDOUT: }
  127. // CHECK:STDOUT:
  128. // CHECK:STDOUT: specific @F(constants.%Self) {}
  129. // CHECK:STDOUT:
  130. // CHECK:STDOUT: specific @CallStatic(constants.%T) {
  131. // CHECK:STDOUT: %T.loc13_15.2 => constants.%T
  132. // CHECK:STDOUT: %T.patt.loc13_15.2 => constants.%T
  133. // CHECK:STDOUT: }
  134. // CHECK:STDOUT:
  135. // CHECK:STDOUT: specific @CallFacet(constants.%T) {
  136. // CHECK:STDOUT: %T.loc21_14.2 => constants.%T
  137. // CHECK:STDOUT: %T.patt.loc21_14.2 => constants.%T
  138. // CHECK:STDOUT: %T.as_type.loc21_32.2 => constants.%T.as_type
  139. // CHECK:STDOUT: }
  140. // CHECK:STDOUT: