fail_todo_generic_method.carbon 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. // CHECK:STDERR: fail_todo_generic_method.carbon:[[@LINE+4]]:1: ERROR: Semantics TODO: `generic class`.
  7. // CHECK:STDERR: class Class(T:! type) {
  8. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~
  9. // CHECK:STDERR:
  10. class Class(T:! type) {
  11. var a: T;
  12. fn F[self: Self](n: T);
  13. }
  14. // CHECK:STDERR: fail_todo_generic_method.carbon:[[@LINE+10]]:1: ERROR: Duplicate name being declared in the same scope.
  15. // CHECK:STDERR: fn Class(T:! type).F[self: Self](n: T) {}
  16. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  17. // CHECK:STDERR: fail_todo_generic_method.carbon:[[@LINE-8]]:1: Name is previously declared here.
  18. // CHECK:STDERR: class Class(T:! type) {
  19. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~
  20. // CHECK:STDERR:
  21. // CHECK:STDERR: fail_todo_generic_method.carbon:[[@LINE+3]]:19: ERROR: `fn` declarations must either end with a `;` or have a `{ ... }` block for a definition.
  22. // CHECK:STDERR: fn Class(T:! type).F[self: Self](n: T) {}
  23. // CHECK:STDERR: ^
  24. fn Class(T:! type).F[self: Self](n: T) {}
  25. // CHECK:STDOUT: --- fail_todo_generic_method.carbon
  26. // CHECK:STDOUT:
  27. // CHECK:STDOUT: constants {
  28. // CHECK:STDOUT: %Class: type = class_type @Class [template]
  29. // CHECK:STDOUT: %.1: type = unbound_element_type Class, T [symbolic]
  30. // CHECK:STDOUT: %.2: type = struct_type {.a: T} [symbolic]
  31. // CHECK:STDOUT: }
  32. // CHECK:STDOUT:
  33. // CHECK:STDOUT: file {
  34. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  35. // CHECK:STDOUT: .Core = %Core
  36. // CHECK:STDOUT: .Class = %Class.decl
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  39. // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {
  40. // CHECK:STDOUT: %T.loc11_13.1: type = param T
  41. // CHECK:STDOUT: %T.loc11_13.2: type = bind_symbolic_name T, %T.loc11_13.1 [symbolic]
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT: %.loc26: <function> = fn_decl @.1 [template] {
  44. // CHECK:STDOUT: %T.loc26_10.1: type = param T
  45. // CHECK:STDOUT: @.1.%T: type = bind_symbolic_name T, %T.loc26_10.1 [symbolic]
  46. // CHECK:STDOUT: }
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT:
  49. // CHECK:STDOUT: class @Class {
  50. // CHECK:STDOUT: %T.ref.loc12: type = name_ref T, file.%T.loc11_13.2 [symbolic = file.%T.loc11_13.2]
  51. // CHECK:STDOUT: %.loc12: <unbound element of class Class> = field_decl a, element0 [template]
  52. // CHECK:STDOUT: %F: <function> = fn_decl @F [template] {
  53. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%Class [template = constants.%Class]
  54. // CHECK:STDOUT: %self.loc13_8.1: Class = param self
  55. // CHECK:STDOUT: %self.loc13_8.2: Class = bind_name self, %self.loc13_8.1
  56. // CHECK:STDOUT: %T.ref.loc13: type = name_ref T, file.%T.loc11_13.2 [symbolic = file.%T.loc11_13.2]
  57. // CHECK:STDOUT: %n.loc13_20.1: T = param n
  58. // CHECK:STDOUT: %n.loc13_20.2: T = bind_name n, %n.loc13_20.1
  59. // CHECK:STDOUT: }
  60. // CHECK:STDOUT:
  61. // CHECK:STDOUT: !members:
  62. // CHECK:STDOUT: .Self = constants.%Class
  63. // CHECK:STDOUT: .a = %.loc12
  64. // CHECK:STDOUT: .F = %F
  65. // CHECK:STDOUT: }
  66. // CHECK:STDOUT:
  67. // CHECK:STDOUT: fn @F[@Class.%self.loc13_8.2: Class](@Class.%n.loc13_20.2: T);
  68. // CHECK:STDOUT:
  69. // CHECK:STDOUT: fn @.1(%T: type);
  70. // CHECK:STDOUT: