fail_member_lookup.carbon 3.1 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. // AUTOUPDATE
  6. interface Interface {
  7. fn F();
  8. let T:! type;
  9. }
  10. fn F() {
  11. // CHECK:STDERR: fail_member_lookup.carbon:[[@LINE+3]]:3: ERROR: Value of type `<associated <function> in Interface>` is not callable.
  12. // CHECK:STDERR: Interface.F();
  13. // CHECK:STDERR: ^~~~~~~~~~~~
  14. Interface.F();
  15. // CHECK:STDERR: fail_member_lookup.carbon:[[@LINE+3]]:10: ERROR: Cannot implicitly convert from `<associated type in Interface>` to `type`.
  16. // CHECK:STDERR: var v: Interface.T;
  17. // CHECK:STDERR: ^~~~~~~~~~~
  18. var v: Interface.T;
  19. }
  20. // CHECK:STDOUT: --- fail_member_lookup.carbon
  21. // CHECK:STDOUT:
  22. // CHECK:STDOUT: constants {
  23. // CHECK:STDOUT: %.1: type = interface_type @Interface [template]
  24. // CHECK:STDOUT: %.2: type = assoc_entity_type @Interface, <function> [template]
  25. // CHECK:STDOUT: %.3: <associated <function> in Interface> = assoc_entity element0, @Interface.%F [template]
  26. // CHECK:STDOUT: %.4: type = assoc_entity_type @Interface, type [template]
  27. // CHECK:STDOUT: %.5: <associated type in Interface> = assoc_entity element1, @Interface.%T [template]
  28. // CHECK:STDOUT: }
  29. // CHECK:STDOUT:
  30. // CHECK:STDOUT: file {
  31. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  32. // CHECK:STDOUT: .Interface = %Interface.decl
  33. // CHECK:STDOUT: .F = %F
  34. // CHECK:STDOUT: }
  35. // CHECK:STDOUT: %Interface.decl: type = interface_decl @Interface [template = constants.%.1] {}
  36. // CHECK:STDOUT: %F: <function> = fn_decl @F.2 [template] {}
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT:
  39. // CHECK:STDOUT: interface @Interface {
  40. // CHECK:STDOUT: %Self: Interface = bind_symbolic_name Self [symbolic]
  41. // CHECK:STDOUT: %F: <function> = fn_decl @F.1 [template] {}
  42. // CHECK:STDOUT: %.loc8: <associated <function> in Interface> = assoc_entity element0, %F [template = constants.%.3]
  43. // CHECK:STDOUT: %T: type = assoc_const_decl T [template]
  44. // CHECK:STDOUT: %.loc10: <associated type in Interface> = assoc_entity element1, %T [template = constants.%.5]
  45. // CHECK:STDOUT:
  46. // CHECK:STDOUT: !members:
  47. // CHECK:STDOUT: .Self = %Self
  48. // CHECK:STDOUT: .F = %.loc8
  49. // CHECK:STDOUT: .T = %.loc10
  50. // CHECK:STDOUT: witness = (%F, %T)
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT:
  53. // CHECK:STDOUT: fn @F.1();
  54. // CHECK:STDOUT:
  55. // CHECK:STDOUT: fn @F.2() {
  56. // CHECK:STDOUT: !entry:
  57. // CHECK:STDOUT: %Interface.ref.loc17: type = name_ref Interface, file.%Interface.decl [template = constants.%.1]
  58. // CHECK:STDOUT: %F.ref: <associated <function> in Interface> = name_ref F, @Interface.%.loc8 [template = constants.%.3]
  59. // CHECK:STDOUT: %Interface.ref.loc22: type = name_ref Interface, file.%Interface.decl [template = constants.%.1]
  60. // CHECK:STDOUT: %T.ref: <associated type in Interface> = name_ref T, @Interface.%.loc10 [template = constants.%.5]
  61. // CHECK:STDOUT: %v.var: ref <error> = var v
  62. // CHECK:STDOUT: %v: ref <error> = bind_name v, %v.var
  63. // CHECK:STDOUT: return
  64. // CHECK:STDOUT: }
  65. // CHECK:STDOUT: