Commit 4565369
[generator] Improve generic type lookup (#552)
Fixes: #543
In commit 262743b we began stripping the arity from Cecil imported
types so that we wouldn't write invalid types like
``System.Collections.Generic.IList`1<string>``, in order to correctly
emit `System.Collections.Generic.IList<string>`.
However when we try to resolve these types in the `SymbolTable` we
only look at the type name, ignoring the generic type parameters. In
this case we are looking for `System.Collections.Generic.IList` but
the type is stored in the symbol table with the arity to disambiguate
types like ``Action`1`` and ``Action`2``. Therefore our lookup fails
because the table key is ``System.Collections.Generic.IList`1``.
For example, if we have `LibraryA.dll` with:
public class Foo : Java.Lang.Object {
public virtual void Bar (IList<string> p0) {…}
}
And we attempt to bind a `LibraryB.jar` which references
`LibraryA.dll`, overriding `Foo.Bar()`:
public class Foo2 : Foo {
public override void Bar (IList<string> p0) {…}
}
Then `Foo2.Bar()` would elicit a BG8800 warning:
warning BG8800: Unknown parameter type System.Collections.Generic.IList<System.String> in method Bar in managed type Foo2.
Fix type lookup so that if the type is not found in the `SymbolTable`
and there are generic type parameters, calculate the arity from the
generic type parameters and look in the table again.
That is, `System.Collections.Generic.IList<string>` is rechecked as
``System.Collections.Generic.IList`1``, which allows the type to be
found.1 parent 71afce5 commit 4565369
File tree
2 files changed
+75
-2
lines changed- tests/generator-Tests/Unit-Tests
- tools/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols
2 files changed
+75
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
Lines changed: 35 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
271 | | - | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
272 | 280 | | |
273 | 281 | | |
274 | 282 | | |
| |||
298 | 306 | | |
299 | 307 | | |
300 | 308 | | |
301 | | - | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
302 | 335 | | |
303 | 336 | | |
304 | 337 | | |
| |||
0 commit comments