Commit d8c198a
committed
BridgeJS: Recognize cross-module extension conformances to @js protocols
A module may declare that a @js type exported by one of its dependencies
conforms to a @js protocol it defines:
// ModuleB, depending on ModuleA
@js protocol GraphNode { var id: String { get } }
extension Building: GraphNode {} // Building is ModuleA's @js struct
@js public func store<T: BridgedSwiftGenericBridgeable & GraphNode>(_ n: T) -> T { n }
The Swift compiler sees the retroactive conformance directly, so the
generic thunk already accepted ModuleA's type - but the JS-side token
check did not: the conformance was declared in ModuleB's sources while
the token belongs to ModuleA, and neither skeleton recorded it, so a
valid call threw a spurious TypeError.
Extension conformances whose target does not resolve in-module are now
resolved against the external module index and recorded in the skeleton
(externalJSProtocolConformances, keyed by the conformer's Swift dot
path, e.g. `Models.Site`). The link layer sees every module's skeleton,
maps that dot path to the defining module's token (`Models_Site`),
merges the record into that token's entry, and the refinement closure
applies on top.1 parent ff403eb commit d8c198a
5 files changed
Lines changed: 147 additions & 10 deletions
File tree
- Plugins/BridgeJS
- Sources
- BridgeJSCore
- BridgeJSLink
- BridgeJSSkeleton
- Tests/BridgeJSToolTests
- Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Exporting-Swift
Lines changed: 55 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
428 | 428 | | |
429 | 429 | | |
430 | 430 | | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
431 | 438 | | |
432 | | - | |
| 439 | + | |
433 | 440 | | |
434 | 441 | | |
435 | 442 | | |
436 | | - | |
437 | | - | |
438 | | - | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
439 | 449 | | |
440 | | - | |
441 | 450 | | |
442 | 451 | | |
443 | 452 | | |
| |||
447 | 456 | | |
448 | 457 | | |
449 | 458 | | |
| 459 | + | |
450 | 460 | | |
451 | 461 | | |
452 | 462 | | |
| 463 | + | |
453 | 464 | | |
454 | 465 | | |
455 | 466 | | |
456 | 467 | | |
457 | 468 | | |
| 469 | + | |
458 | 470 | | |
459 | 471 | | |
460 | 472 | | |
461 | 473 | | |
462 | 474 | | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
463 | 502 | | |
464 | 503 | | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
465 | 507 | | |
466 | 508 | | |
467 | 509 | | |
| |||
4137 | 4179 | | |
4138 | 4180 | | |
4139 | 4181 | | |
4140 | | - | |
| 4182 | + | |
4141 | 4183 | | |
4142 | 4184 | | |
4143 | 4185 | | |
| |||
4146 | 4188 | | |
4147 | 4189 | | |
4148 | 4190 | | |
4149 | | - | |
| 4191 | + | |
4150 | 4192 | | |
4151 | 4193 | | |
4152 | | - | |
| 4194 | + | |
4153 | 4195 | | |
4154 | 4196 | | |
| 4197 | + | |
| 4198 | + | |
| 4199 | + | |
| 4200 | + | |
| 4201 | + | |
4155 | 4202 | | |
4156 | 4203 | | |
4157 | 4204 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
517 | 517 | | |
518 | 518 | | |
519 | 519 | | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
520 | 534 | | |
521 | 535 | | |
522 | 536 | | |
523 | 537 | | |
524 | 538 | | |
525 | 539 | | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
526 | 546 | | |
527 | 547 | | |
528 | 548 | | |
| |||
536 | 556 | | |
537 | 557 | | |
538 | 558 | | |
539 | | - | |
540 | | - | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
541 | 565 | | |
542 | 566 | | |
543 | 567 | | |
| |||
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1304 | 1304 | | |
1305 | 1305 | | |
1306 | 1306 | | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
1307 | 1314 | | |
1308 | 1315 | | |
1309 | 1316 | | |
| |||
Lines changed: 42 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 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
169 | 211 | | |
170 | 212 | | |
171 | 213 | | |
| |||
Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
297 | 297 | | |
298 | 298 | | |
299 | 299 | | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
300 | 317 | | |
301 | 318 | | |
302 | 319 | | |
| |||
0 commit comments