Repository navigation
Commit 2bfca9a
Resolve type variables against the most specific type
Type variables in field and method types were resolved against the
declaring type, which only knows the arguments passed in by its direct
subclass. When those were type variables too (e.g. Item extends
BaseItem<Long> extends AbstractItem<T>), the fallback matched them by
name against the first parameterized superclass. That recursed forever
when the names repeated, failed with "No type variable found" when they
differed, and silently picked the wrong argument when a subclass
reordered them.
Resolve them against the most specific type instead, which binds the
type variables of all its supertypes, or its owner types for those of
outer classes, and drop the name matching. Variables in wildcard bounds
(e.g. List<? extends T>, which Kotlin emits for List<T> parameters) are
resolved too. A variable that can't be resolved, such as one declared
by a generic method, fails with a clear error. One bound to a type
containing itself, which can only leak out of a raw type, is erased
like the raw type would instead of being expanded endlessly.
Generic types returned by methods of a generic superclass now keep
their resolved arguments, as fields already did. So two subclasses
binding them differently can't share one GraphQL type anymore, like
direct references to Page<A> and Page<B>. The "Two different classes"
error now prints the parameterized types to show the difference.
Fixes #460
Fixes #218
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>1 parent 349d56a commit 2bfca9a
5 files changed
Lines changed: 597 additions & 45 deletions
File tree
- src
- main/kotlin/graphql/kickstart/tools
- test/kotlin/graphql/kickstart/tools
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | 7 | | |
9 | 8 | | |
10 | 9 | | |
| |||
97 | 96 | | |
98 | 97 | | |
99 | 98 | | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
| 99 | + | |
108 | 100 | | |
109 | 101 | | |
110 | 102 | | |
111 | 103 | | |
112 | 104 | | |
113 | 105 | | |
114 | 106 | | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
| 107 | + | |
140 | 108 | | |
141 | 109 | | |
142 | | - | |
143 | | - | |
| 110 | + | |
| 111 | + | |
144 | 112 | | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
145 | 117 | | |
146 | 118 | | |
147 | 119 | | |
| |||
152 | 124 | | |
153 | 125 | | |
154 | 126 | | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
160 | 137 | | |
161 | | - | |
162 | | - | |
| 138 | + | |
163 | 139 | | |
164 | 140 | | |
165 | 141 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
360 | 360 | | |
361 | 361 | | |
362 | 362 | | |
363 | | - | |
| 363 | + | |
364 | 364 | | |
365 | 365 | | |
366 | 366 | | |
| |||
469 | 469 | | |
470 | 470 | | |
471 | 471 | | |
472 | | - | |
| 472 | + | |
473 | 473 | | |
474 | 474 | | |
475 | 475 | | |
| |||
Lines changed: 50 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
169 | 202 | | |
170 | 203 | | |
171 | 204 | | |
| |||
184 | 217 | | |
185 | 218 | | |
186 | 219 | | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
187 | 224 | | |
188 | 225 | | |
189 | 226 | | |
| |||
196 | 233 | | |
197 | 234 | | |
198 | 235 | | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
199 | 249 | | |
200 | 250 | | |
201 | 251 | | |
| |||
0 commit comments