fail_todo_facet_lookup.carbon 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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 `<associated <type of F> in Interface>` 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 = interface_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: %.1: type = tuple_type () [template]
  31. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  32. // CHECK:STDOUT: %.2: type = assoc_entity_type %Interface.type, %F.type [template]
  33. // CHECK:STDOUT: %.3: %.2 = assoc_entity element0, @Interface.%F.decl [template]
  34. // CHECK:STDOUT: %T: %Interface.type = bind_symbolic_name T, 0 [symbolic]
  35. // CHECK:STDOUT: %T.patt.1: %Interface.type = symbolic_binding_pattern T, 0 [symbolic]
  36. // CHECK:STDOUT: %CallStatic.type: type = fn_type @CallStatic [template]
  37. // CHECK:STDOUT: %CallStatic: %CallStatic.type = struct_value () [template]
  38. // CHECK:STDOUT: %T.patt.2: %Interface.type = symbolic_binding_pattern T, 0 [symbolic]
  39. // CHECK:STDOUT: %CallFacet.type: type = fn_type @CallFacet [template]
  40. // CHECK:STDOUT: %CallFacet: %CallFacet.type = struct_value () [template]
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT:
  43. // CHECK:STDOUT: file {
  44. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  45. // CHECK:STDOUT: .Interface = %Interface.decl
  46. // CHECK:STDOUT: .CallStatic = %CallStatic.decl
  47. // CHECK:STDOUT: .CallFacet = %CallFacet.decl
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT: %Interface.decl: type = interface_decl @Interface [template = constants.%Interface.type] {} {}
  50. // CHECK:STDOUT: %CallStatic.decl: %CallStatic.type = fn_decl @CallStatic [template = constants.%CallStatic] {
  51. // CHECK:STDOUT: %T.patt.loc13_15.1: %Interface.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc13_15.2 (constants.%T.patt.1)]
  52. // 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.1)]
  53. // CHECK:STDOUT: } {
  54. // CHECK:STDOUT: %Interface.ref: type = name_ref Interface, file.%Interface.decl [template = constants.%Interface.type]
  55. // CHECK:STDOUT: %T.param: %Interface.type = value_param runtime_param<invalid>
  56. // CHECK:STDOUT: %T.loc13_15.1: %Interface.type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc13_15.2 (constants.%T)]
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT: %CallFacet.decl: %CallFacet.type = fn_decl @CallFacet [template = constants.%CallFacet] {
  59. // CHECK:STDOUT: %T.patt.loc21_14.1: %Interface.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc21_14.2 (constants.%T.patt.2)]
  60. // 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.2)]
  61. // CHECK:STDOUT: %x.patt: @CallFacet.%T.loc21_14.2 (%T) = binding_pattern x
  62. // CHECK:STDOUT: %x.param_patt: @CallFacet.%T.loc21_14.2 (%T) = value_param_pattern %x.patt, runtime_param0
  63. // CHECK:STDOUT: } {
  64. // CHECK:STDOUT: %Interface.ref: type = name_ref Interface, file.%Interface.decl [template = constants.%Interface.type]
  65. // CHECK:STDOUT: %T.ref: %Interface.type = name_ref T, %T.loc21_14.1 [symbolic = %T.loc21_14.2 (constants.%T)]
  66. // CHECK:STDOUT: %.loc21_32.1: type = facet_type_access %T.ref [symbolic = %T.loc21_14.2 (constants.%T)]
  67. // CHECK:STDOUT: %.loc21_32.2: type = converted %T.ref, %.loc21_32.1 [symbolic = %T.loc21_14.2 (constants.%T)]
  68. // CHECK:STDOUT: %T.param: %Interface.type = value_param runtime_param<invalid>
  69. // CHECK:STDOUT: %T.loc21_14.1: %Interface.type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc21_14.2 (constants.%T)]
  70. // CHECK:STDOUT: %x.param: @CallFacet.%T.loc21_14.2 (%T) = value_param runtime_param0
  71. // CHECK:STDOUT: %x: @CallFacet.%T.loc21_14.2 (%T) = bind_name x, %x.param
  72. // CHECK:STDOUT: }
  73. // CHECK:STDOUT: }
  74. // CHECK:STDOUT:
  75. // CHECK:STDOUT: interface @Interface {
  76. // CHECK:STDOUT: %Self: %Interface.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
  77. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} {}
  78. // CHECK:STDOUT: %.loc11: %.2 = assoc_entity element0, %F.decl [template = constants.%.3]
  79. // CHECK:STDOUT:
  80. // CHECK:STDOUT: !members:
  81. // CHECK:STDOUT: .Self = %Self
  82. // CHECK:STDOUT: .F = %.loc11
  83. // CHECK:STDOUT: witness = (%F.decl)
  84. // CHECK:STDOUT: }
  85. // CHECK:STDOUT:
  86. // CHECK:STDOUT: generic fn @F(@Interface.%Self: %Interface.type) {
  87. // CHECK:STDOUT:
  88. // CHECK:STDOUT: fn();
  89. // CHECK:STDOUT: }
  90. // CHECK:STDOUT:
  91. // CHECK:STDOUT: generic fn @CallStatic(%T.loc13_15.1: %Interface.type) {
  92. // CHECK:STDOUT: %T.loc13_15.2: %Interface.type = bind_symbolic_name T, 0 [symbolic = %T.loc13_15.2 (constants.%T)]
  93. // CHECK:STDOUT: %T.patt.loc13_15.2: %Interface.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc13_15.2 (constants.%T.patt.1)]
  94. // CHECK:STDOUT:
  95. // CHECK:STDOUT: !definition:
  96. // CHECK:STDOUT:
  97. // CHECK:STDOUT: fn(%T.param_patt: %Interface.type) {
  98. // CHECK:STDOUT: !entry:
  99. // CHECK:STDOUT: %T.ref: %Interface.type = name_ref T, %T.loc13_15.1 [symbolic = %T.loc13_15.2 (constants.%T)]
  100. // CHECK:STDOUT: %F.ref: %.2 = name_ref F, @Interface.%.loc11 [template = constants.%.3]
  101. // CHECK:STDOUT: return
  102. // CHECK:STDOUT: }
  103. // CHECK:STDOUT: }
  104. // CHECK:STDOUT:
  105. // CHECK:STDOUT: generic fn @CallFacet(%T.loc21_14.1: %Interface.type) {
  106. // CHECK:STDOUT: %T.loc21_14.2: %Interface.type = bind_symbolic_name T, 0 [symbolic = %T.loc21_14.2 (constants.%T)]
  107. // CHECK:STDOUT: %T.patt.loc21_14.2: %Interface.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc21_14.2 (constants.%T.patt.2)]
  108. // CHECK:STDOUT:
  109. // CHECK:STDOUT: !definition:
  110. // CHECK:STDOUT:
  111. // CHECK:STDOUT: fn(%T.param_patt: %Interface.type, %x.param_patt: @CallFacet.%T.loc21_14.2 (%T)) {
  112. // CHECK:STDOUT: !entry:
  113. // CHECK:STDOUT: %x.ref: @CallFacet.%T.loc21_14.2 (%T) = name_ref x, %x
  114. // CHECK:STDOUT: return
  115. // CHECK:STDOUT: }
  116. // CHECK:STDOUT: }
  117. // CHECK:STDOUT:
  118. // CHECK:STDOUT: specific @F(constants.%Self) {}
  119. // CHECK:STDOUT:
  120. // CHECK:STDOUT: specific @CallStatic(constants.%T) {
  121. // CHECK:STDOUT: %T.loc13_15.2 => constants.%T
  122. // CHECK:STDOUT: %T.patt.loc13_15.2 => constants.%T
  123. // CHECK:STDOUT: }
  124. // CHECK:STDOUT:
  125. // CHECK:STDOUT: specific @CallFacet(constants.%T) {
  126. // CHECK:STDOUT: %T.loc21_14.2 => constants.%T
  127. // CHECK:STDOUT: %T.patt.loc21_14.2 => constants.%T
  128. // CHECK:STDOUT: }
  129. // CHECK:STDOUT: