Commit bb27386
authored
Fix cross-module generic class export/import (4 co-operating bugs) (#280)
A generic class's bare template declaration never reached the module's
declaration-export text at all: mlirGen(ClassLikeDeclaration) returns
early into registerGenericClass whenever processing the template (vs.
a concrete instantiation), before ever calling
addClassDeclarationToExport. Fixed by exporting the generic's own
ORIGINAL source text (not a signature-only declaration like concrete
classes get, since a generic has no compiled body anywhere for an
importer to link against - it needs the real, recompilable source)
via a new addGenericClassDeclarationToExport/printGenericClass.
That exposed two more bugs once generics started actually reaching
the reimport path:
- The existing declaration-reimport mechanism parses with a
"partial.d.ts" filename, which implicitly marks everything ambient/
external regardless of any per-declaration @dllimport marker - fine
for every other declaration kind (bodies already compiled elsewhere)
but fatal for a generic's real body. Fixed by giving generic
declarations their own separate embedded global
("__decls_generic_<file>_<hash>"), reparsed with a plain ".ts"
filename instead.
- Reimporting the generic's own text re-declares it a second time
inside the importer, which re-attempts the export call with a
stale source-file/AST-position pairing, throwing an unhandled
std::out_of_range (surfaced as a blocked "Microsoft Visual C++
Runtime Library" dialog - near-zero CPU, looked like a hang from
the outside). Fixed with a bounds-check that skips the redundant
re-export instead of crashing.
Also fixes a related, separately-triggered bug: a concrete generic
instantiation (e.g. Pair<number,string>) was inheriting its
template's `export` modifier, and the mangled name's comma broke the
linker's /EXPORT: directive syntax outright. Fixed by forcing
isExport/isPublic false on any class reached via a generic
specialization's codegen path.
Re-enables all 3 tiers (compile / -shared / -jit-shared) of
export_class_generic.ts/import_class_generic.ts, previously disabled.
Full suite: 789/789, no regressions.1 parent 71a1b7b commit bb27386
6 files changed
Lines changed: 209 additions & 28 deletions
File tree
- tslang
- include/TypeScript/MLIRLogic
- lib/TypeScript
- test/tester
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
511 | 511 | | |
512 | 512 | | |
513 | 513 | | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
514 | 528 | | |
515 | 529 | | |
516 | 530 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
19 | 29 | | |
20 | 30 | | |
21 | 31 | | |
| |||
40 | 50 | | |
41 | 51 | | |
42 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
43 | 65 | | |
44 | 66 | | |
45 | 67 | | |
| |||
71 | 93 | | |
72 | 94 | | |
73 | 95 | | |
74 | | - | |
75 | 96 | | |
76 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
77 | 117 | | |
78 | 118 | | |
79 | 119 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
219 | 219 | | |
220 | 220 | | |
221 | 221 | | |
| 222 | + | |
222 | 223 | | |
223 | 224 | | |
224 | 225 | | |
| |||
10308 | 10309 | | |
10309 | 10310 | | |
10310 | 10311 | | |
10311 | | - | |
| 10312 | + | |
10312 | 10313 | | |
10313 | 10314 | | |
10314 | 10315 | | |
10315 | 10316 | | |
10316 | 10317 | | |
10317 | 10318 | | |
10318 | | - | |
| 10319 | + | |
10319 | 10320 | | |
10320 | 10321 | | |
10321 | 10322 | | |
10322 | 10323 | | |
10323 | 10324 | | |
10324 | 10325 | | |
| 10326 | + | |
| 10327 | + | |
| 10328 | + | |
| 10329 | + | |
| 10330 | + | |
| 10331 | + | |
| 10332 | + | |
| 10333 | + | |
| 10334 | + | |
| 10335 | + | |
| 10336 | + | |
| 10337 | + | |
| 10338 | + | |
| 10339 | + | |
| 10340 | + | |
| 10341 | + | |
| 10342 | + | |
| 10343 | + | |
| 10344 | + | |
| 10345 | + | |
| 10346 | + | |
| 10347 | + | |
| 10348 | + | |
| 10349 | + | |
| 10350 | + | |
| 10351 | + | |
| 10352 | + | |
| 10353 | + | |
| 10354 | + | |
| 10355 | + | |
| 10356 | + | |
| 10357 | + | |
| 10358 | + | |
| 10359 | + | |
| 10360 | + | |
| 10361 | + | |
| 10362 | + | |
| 10363 | + | |
| 10364 | + | |
| 10365 | + | |
| 10366 | + | |
| 10367 | + | |
| 10368 | + | |
| 10369 | + | |
| 10370 | + | |
10325 | 10371 | | |
10326 | 10372 | | |
10327 | 10373 | | |
| |||
10990 | 11036 | | |
10991 | 11037 | | |
10992 | 11038 | | |
| 11039 | + | |
| 11040 | + | |
| 11041 | + | |
| 11042 | + | |
| 11043 | + | |
| 11044 | + | |
| 11045 | + | |
| 11046 | + | |
| 11047 | + | |
10993 | 11048 | | |
10994 | 11049 | | |
10995 | 11050 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
334 | 334 | | |
335 | 335 | | |
336 | 336 | | |
337 | | - | |
338 | | - | |
339 | | - | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
340 | 380 | | |
341 | 381 | | |
342 | 382 | | |
| |||
649 | 689 | | |
650 | 690 | | |
651 | 691 | | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
652 | 697 | | |
653 | 698 | | |
654 | 699 | | |
| |||
879 | 924 | | |
880 | 925 | | |
881 | 926 | | |
882 | | - | |
| 927 | + | |
883 | 928 | | |
884 | 929 | | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
885 | 942 | | |
886 | | - | |
| 943 | + | |
887 | 944 | | |
888 | 945 | | |
889 | 946 | | |
890 | | - | |
| 947 | + | |
891 | 948 | | |
892 | 949 | | |
893 | 950 | | |
| |||
0 commit comments