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