|
2 | 2 | // Exceptions. See /LICENSE for license information.
|
3 | 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
4 | 4 | //
|
5 |
| -// TODO: Add ranges and switch to "--dump-sem-ir-ranges=only". |
6 |
| -// EXTRA-ARGS: --dump-sem-ir-ranges=if-present |
7 |
| -// |
8 | 5 | // AUTOUPDATE
|
9 | 6 | // TIP: To test this file alone, run:
|
10 | 7 | // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/class/fail_generic_method.carbon
|
11 | 8 | // TIP: To dump output, run:
|
12 | 9 | // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/fail_generic_method.carbon
|
13 | 10 |
|
| 11 | +class I {} |
| 12 | + |
14 | 13 | class Class(T:! type) {
|
15 | 14 | var a: T;
|
16 | 15 | fn F[self: Self](n: T);
|
17 | 16 | }
|
18 | 17 |
|
19 | 18 | // TODO: The follow-on errors here aren't great. Investigate whether we can
|
20 | 19 | // enter the scope anyway if the parameters don't match.
|
21 |
| -// CHECK:STDERR: fail_generic_method.carbon:[[@LINE+15]]:10: error: type `<pattern for i32>` of parameter 1 in redeclaration differs from previous parameter type `<pattern for type>` [RedeclParamDiffersType] |
22 |
| -// CHECK:STDERR: fn Class(N:! i32).F[self: Self](n: T) {} |
| 20 | +// CHECK:STDERR: fail_generic_method.carbon:[[@LINE+15]]:10: error: type `<pattern for I>` of parameter 1 in redeclaration differs from previous parameter type `<pattern for type>` [RedeclParamDiffersType] |
| 21 | +// CHECK:STDERR: fn Class(N:! I).F[self: Self](n: T) {} |
23 | 22 | // CHECK:STDERR: ^
|
24 | 23 | // CHECK:STDERR: fail_generic_method.carbon:[[@LINE-10]]:13: note: previous declaration's corresponding parameter here [RedeclParamPrevious]
|
25 | 24 | // CHECK:STDERR: class Class(T:! type) {
|
26 | 25 | // CHECK:STDERR: ^
|
27 | 26 | // CHECK:STDERR:
|
28 |
| -// CHECK:STDERR: fail_generic_method.carbon:[[@LINE+8]]:27: error: name `Self` not found [NameNotFound] |
29 |
| -// CHECK:STDERR: fn Class(N:! i32).F[self: Self](n: T) {} |
30 |
| -// CHECK:STDERR: ^~~~ |
| 27 | +// CHECK:STDERR: fail_generic_method.carbon:[[@LINE+8]]:25: error: name `Self` not found [NameNotFound] |
| 28 | +// CHECK:STDERR: fn Class(N:! I).F[self: Self](n: T) {} |
| 29 | +// CHECK:STDERR: ^~~~ |
31 | 30 | // CHECK:STDERR:
|
32 |
| -// CHECK:STDERR: fail_generic_method.carbon:[[@LINE+4]]:36: error: name `T` not found [NameNotFound] |
33 |
| -// CHECK:STDERR: fn Class(N:! i32).F[self: Self](n: T) {} |
34 |
| -// CHECK:STDERR: ^ |
| 31 | +// CHECK:STDERR: fail_generic_method.carbon:[[@LINE+4]]:34: error: name `T` not found [NameNotFound] |
| 32 | +// CHECK:STDERR: fn Class(N:! I).F[self: Self](n: T) {} |
| 33 | +// CHECK:STDERR: ^ |
35 | 34 | // CHECK:STDERR:
|
36 |
| -fn Class(N:! i32).F[self: Self](n: T) {} |
37 |
| - |
38 |
| -// CHECK:STDOUT: --- fail_generic_method.carbon |
39 |
| -// CHECK:STDOUT: |
40 |
| -// CHECK:STDOUT: constants { |
41 |
| -// CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic] |
42 |
| -// CHECK:STDOUT: %pattern_type.98f: type = pattern_type type [concrete] |
43 |
| -// CHECK:STDOUT: %Class.type: type = generic_class_type @Class [concrete] |
44 |
| -// CHECK:STDOUT: %Class.generic: %Class.type = struct_value () [concrete] |
45 |
| -// CHECK:STDOUT: %Class: type = class_type @Class, @Class(%T) [symbolic] |
46 |
| -// CHECK:STDOUT: %require_complete.4ae: <witness> = require_complete_type %T [symbolic] |
47 |
| -// CHECK:STDOUT: %Class.elem: type = unbound_element_type %Class, %T [symbolic] |
48 |
| -// CHECK:STDOUT: %pattern_type.3c1: type = pattern_type %Class [symbolic] |
49 |
| -// CHECK:STDOUT: %pattern_type.7dc: type = pattern_type %T [symbolic] |
50 |
| -// CHECK:STDOUT: %F.type.6d6: type = fn_type @F.1, @Class(%T) [symbolic] |
51 |
| -// CHECK:STDOUT: %F.cca: %F.type.6d6 = struct_value () [symbolic] |
52 |
| -// CHECK:STDOUT: %struct_type.a: type = struct_type {.a: %T} [symbolic] |
53 |
| -// CHECK:STDOUT: %complete_type.f1b: <witness> = complete_type_witness %struct_type.a [symbolic] |
54 |
| -// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete] |
55 |
| -// CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete] |
56 |
| -// CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete] |
57 |
| -// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete] |
58 |
| -// CHECK:STDOUT: %N.51e: %i32 = bind_symbolic_name N, 0 [symbolic] |
59 |
| -// CHECK:STDOUT: %F.type.b25: type = fn_type @F.2 [concrete] |
60 |
| -// CHECK:STDOUT: %F.c41: %F.type.b25 = struct_value () [concrete] |
61 |
| -// CHECK:STDOUT: } |
62 |
| -// CHECK:STDOUT: |
63 |
| -// CHECK:STDOUT: imports { |
64 |
| -// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] { |
65 |
| -// CHECK:STDOUT: .Int = %Core.Int |
66 |
| -// CHECK:STDOUT: import Core//prelude |
67 |
| -// CHECK:STDOUT: import Core//prelude/... |
68 |
| -// CHECK:STDOUT: } |
69 |
| -// CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/types/int, Int, loaded [concrete = constants.%Int.generic] |
70 |
| -// CHECK:STDOUT: } |
71 |
| -// CHECK:STDOUT: |
72 |
| -// CHECK:STDOUT: file { |
73 |
| -// CHECK:STDOUT: package: <namespace> = namespace [concrete] { |
74 |
| -// CHECK:STDOUT: .Core = imports.%Core |
75 |
| -// CHECK:STDOUT: .Class = %Class.decl |
76 |
| -// CHECK:STDOUT: .T = <poisoned> |
77 |
| -// CHECK:STDOUT: } |
78 |
| -// CHECK:STDOUT: %Core.import = import Core |
79 |
| -// CHECK:STDOUT: %Class.decl: %Class.type = class_decl @Class [concrete = constants.%Class.generic] { |
80 |
| -// CHECK:STDOUT: %T.patt: %pattern_type.98f = symbolic_binding_pattern T, 0 [concrete] |
81 |
| -// CHECK:STDOUT: } { |
82 |
| -// CHECK:STDOUT: %T.loc14_13.1: type = bind_symbolic_name T, 0 [symbolic = %T.loc14_13.2 (constants.%T)] |
83 |
| -// CHECK:STDOUT: } |
84 |
| -// CHECK:STDOUT: %F.decl: %F.type.b25 = fn_decl @F.2 [concrete = constants.%F.c41] { |
85 |
| -// CHECK:STDOUT: %self.patt: <error> = binding_pattern self [concrete] |
86 |
| -// CHECK:STDOUT: %self.param_patt: <error> = value_param_pattern %self.patt, call_param0 [concrete] |
87 |
| -// CHECK:STDOUT: %n.patt: <error> = binding_pattern n [concrete] |
88 |
| -// CHECK:STDOUT: %n.param_patt: <error> = value_param_pattern %n.patt, call_param1 [concrete] |
89 |
| -// CHECK:STDOUT: } { |
90 |
| -// CHECK:STDOUT: %.loc36: type = splice_block %i32 [concrete = constants.%i32] { |
91 |
| -// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] |
92 |
| -// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] |
93 |
| -// CHECK:STDOUT: } |
94 |
| -// CHECK:STDOUT: %N.loc36_10.1: %i32 = bind_symbolic_name N, 0 [symbolic = %N.loc36_10.2 (constants.%N.51e)] |
95 |
| -// CHECK:STDOUT: %self.param: <error> = value_param call_param0 |
96 |
| -// CHECK:STDOUT: %Self.ref: <error> = name_ref Self, <error> [concrete = <error>] |
97 |
| -// CHECK:STDOUT: %self: <error> = bind_name self, %self.param [concrete = <error>] |
98 |
| -// CHECK:STDOUT: %n.param: <error> = value_param call_param1 |
99 |
| -// CHECK:STDOUT: %T.ref: <error> = name_ref T, <error> [concrete = <error>] |
100 |
| -// CHECK:STDOUT: %n: <error> = bind_name n, %n.param [concrete = <error>] |
101 |
| -// CHECK:STDOUT: } |
102 |
| -// CHECK:STDOUT: } |
103 |
| -// CHECK:STDOUT: |
104 |
| -// CHECK:STDOUT: generic class @Class(%T.loc14_13.1: type) { |
105 |
| -// CHECK:STDOUT: %T.loc14_13.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc14_13.2 (constants.%T)] |
106 |
| -// CHECK:STDOUT: |
107 |
| -// CHECK:STDOUT: !definition: |
108 |
| -// CHECK:STDOUT: %require_complete: <witness> = require_complete_type %T.loc14_13.2 [symbolic = %require_complete (constants.%require_complete.4ae)] |
109 |
| -// CHECK:STDOUT: %Class: type = class_type @Class, @Class(%T.loc14_13.2) [symbolic = %Class (constants.%Class)] |
110 |
| -// CHECK:STDOUT: %Class.elem: type = unbound_element_type %Class, %T.loc14_13.2 [symbolic = %Class.elem (constants.%Class.elem)] |
111 |
| -// CHECK:STDOUT: %F.type: type = fn_type @F.1, @Class(%T.loc14_13.2) [symbolic = %F.type (constants.%F.type.6d6)] |
112 |
| -// CHECK:STDOUT: %F: @Class.%F.type (%F.type.6d6) = struct_value () [symbolic = %F (constants.%F.cca)] |
113 |
| -// CHECK:STDOUT: %struct_type.a.loc17_1.2: type = struct_type {.a: @Class.%T.loc14_13.2 (%T)} [symbolic = %struct_type.a.loc17_1.2 (constants.%struct_type.a)] |
114 |
| -// CHECK:STDOUT: %complete_type.loc17_1.2: <witness> = complete_type_witness %struct_type.a.loc17_1.2 [symbolic = %complete_type.loc17_1.2 (constants.%complete_type.f1b)] |
115 |
| -// CHECK:STDOUT: |
116 |
| -// CHECK:STDOUT: class { |
117 |
| -// CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc14_13.1 [symbolic = %T.loc14_13.2 (constants.%T)] |
118 |
| -// CHECK:STDOUT: %.loc15: @Class.%Class.elem (%Class.elem) = field_decl a, element0 [concrete] |
119 |
| -// CHECK:STDOUT: %F.decl: @Class.%F.type (%F.type.6d6) = fn_decl @F.1 [symbolic = @Class.%F (constants.%F.cca)] { |
120 |
| -// CHECK:STDOUT: %self.patt: @F.1.%pattern_type.loc16_8 (%pattern_type.3c1) = binding_pattern self [concrete] |
121 |
| -// CHECK:STDOUT: %self.param_patt: @F.1.%pattern_type.loc16_8 (%pattern_type.3c1) = value_param_pattern %self.patt, call_param0 [concrete] |
122 |
| -// CHECK:STDOUT: %n.patt: @F.1.%pattern_type.loc16_20 (%pattern_type.7dc) = binding_pattern n [concrete] |
123 |
| -// CHECK:STDOUT: %n.param_patt: @F.1.%pattern_type.loc16_20 (%pattern_type.7dc) = value_param_pattern %n.patt, call_param1 [concrete] |
124 |
| -// CHECK:STDOUT: } { |
125 |
| -// CHECK:STDOUT: %self.param: @F.1.%Class (%Class) = value_param call_param0 |
126 |
| -// CHECK:STDOUT: %.loc16_14.1: type = splice_block %Self.ref [symbolic = %Class (constants.%Class)] { |
127 |
| -// CHECK:STDOUT: %.loc16_14.2: type = specific_constant constants.%Class, @Class(constants.%T) [symbolic = %Class (constants.%Class)] |
128 |
| -// CHECK:STDOUT: %Self.ref: type = name_ref Self, %.loc16_14.2 [symbolic = %Class (constants.%Class)] |
129 |
| -// CHECK:STDOUT: } |
130 |
| -// CHECK:STDOUT: %self: @F.1.%Class (%Class) = bind_name self, %self.param |
131 |
| -// CHECK:STDOUT: %n.param: @F.1.%T (%T) = value_param call_param1 |
132 |
| -// CHECK:STDOUT: %T.ref: type = name_ref T, @Class.%T.loc14_13.1 [symbolic = %T (constants.%T)] |
133 |
| -// CHECK:STDOUT: %n: @F.1.%T (%T) = bind_name n, %n.param |
134 |
| -// CHECK:STDOUT: } |
135 |
| -// CHECK:STDOUT: %struct_type.a.loc17_1.1: type = struct_type {.a: %T} [symbolic = %struct_type.a.loc17_1.2 (constants.%struct_type.a)] |
136 |
| -// CHECK:STDOUT: %complete_type.loc17_1.1: <witness> = complete_type_witness %struct_type.a.loc17_1.1 [symbolic = %complete_type.loc17_1.2 (constants.%complete_type.f1b)] |
137 |
| -// CHECK:STDOUT: complete_type_witness = %complete_type.loc17_1.1 |
138 |
| -// CHECK:STDOUT: |
139 |
| -// CHECK:STDOUT: !members: |
140 |
| -// CHECK:STDOUT: .Self = constants.%Class |
141 |
| -// CHECK:STDOUT: .T = <poisoned> |
142 |
| -// CHECK:STDOUT: .a = %.loc15 |
143 |
| -// CHECK:STDOUT: .F = %F.decl |
144 |
| -// CHECK:STDOUT: } |
145 |
| -// CHECK:STDOUT: } |
146 |
| -// CHECK:STDOUT: |
147 |
| -// CHECK:STDOUT: generic fn @F.1(@Class.%T.loc14_13.1: type) { |
148 |
| -// CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)] |
149 |
| -// CHECK:STDOUT: %Class: type = class_type @Class, @Class(%T) [symbolic = %Class (constants.%Class)] |
150 |
| -// CHECK:STDOUT: %pattern_type.loc16_8: type = pattern_type %Class [symbolic = %pattern_type.loc16_8 (constants.%pattern_type.3c1)] |
151 |
| -// CHECK:STDOUT: %pattern_type.loc16_20: type = pattern_type %T [symbolic = %pattern_type.loc16_20 (constants.%pattern_type.7dc)] |
152 |
| -// CHECK:STDOUT: |
153 |
| -// CHECK:STDOUT: fn(%self.param: @F.1.%Class (%Class), %n.param: @F.1.%T (%T)); |
154 |
| -// CHECK:STDOUT: } |
155 |
| -// CHECK:STDOUT: |
156 |
| -// CHECK:STDOUT: generic fn @F.2(%N.loc36_10.1: %i32) { |
157 |
| -// CHECK:STDOUT: %N.loc36_10.2: %i32 = bind_symbolic_name N, 0 [symbolic = %N.loc36_10.2 (constants.%N.51e)] |
158 |
| -// CHECK:STDOUT: |
159 |
| -// CHECK:STDOUT: !definition: |
160 |
| -// CHECK:STDOUT: |
161 |
| -// CHECK:STDOUT: fn(%self.param: <error>, %n.param: <error>) { |
162 |
| -// CHECK:STDOUT: !entry: |
163 |
| -// CHECK:STDOUT: return |
164 |
| -// CHECK:STDOUT: } |
165 |
| -// CHECK:STDOUT: } |
166 |
| -// CHECK:STDOUT: |
167 |
| -// CHECK:STDOUT: specific @Class(constants.%T) { |
168 |
| -// CHECK:STDOUT: %T.loc14_13.2 => constants.%T |
169 |
| -// CHECK:STDOUT: } |
170 |
| -// CHECK:STDOUT: |
171 |
| -// CHECK:STDOUT: specific @F.1(constants.%T) { |
172 |
| -// CHECK:STDOUT: %T => constants.%T |
173 |
| -// CHECK:STDOUT: %Class => constants.%Class |
174 |
| -// CHECK:STDOUT: %pattern_type.loc16_8 => constants.%pattern_type.3c1 |
175 |
| -// CHECK:STDOUT: %pattern_type.loc16_20 => constants.%pattern_type.7dc |
176 |
| -// CHECK:STDOUT: } |
177 |
| -// CHECK:STDOUT: |
178 |
| -// CHECK:STDOUT: specific @F.2(constants.%N.51e) { |
179 |
| -// CHECK:STDOUT: %N.loc36_10.2 => constants.%N.51e |
180 |
| -// CHECK:STDOUT: } |
181 |
| -// CHECK:STDOUT: |
| 35 | +fn Class(N:! I).F[self: Self](n: T) {} |
0 commit comments