Commit ba00f45
authored
fix(binder,emit): implicit []T to IEnumerable[T] at static-call slots (#829)
Closes #821. The slice-to-interface implicit conversion (#570) and the
sequence-vs-slice receiver-call extension (#774) both classified slice
arguments correctly when the target interface's ClrType was a fully
closed live-runtime instantiation. At static-method / free-function
argument slots, the target's ClrType could be the type-erased open-
definition form because Binder.SubstituteType keeps the erased ClrType
on ImportedTypeSymbol.GetConstructed when MakeGenericType cannot close
across reflection contexts (open def in MetadataLoadContext vs live
runtime element type). The real substituted G# types live on
ImportedTypeSymbol.TypeArguments, but neither the binder's
slice-to-interface classifier nor the emitter's reference-compatibility
walk consulted them, so the call site was rejected with GS0155 (binder)
or GS9998 (emitter) depending on the path.
Three localized fixes:
- Conversion.SliceImplementsInterface: extends the slice-to-interface
arm to fall back to the target's symbolic TypeArguments and the open
definition's FullName when the constructed CLR target is erased,
matching slice-array interface arguments by leaf FullName so the
invariance guarantee is preserved.
- MethodBodyEmitter.IsReferenceCompatible: mirrors the binder fallback
so the emit-time reference upcast recognises the slice argument as
CLR-equivalent to the erased ImportedTypeSymbol target and emits a
no-op IL conversion.
- ReflectionMetadataEmitter.GetErasedObjectArgs: routes erased-object
generic instantiation through emitCtx.CoreObjectType when the open
definition lives outside the host runtime, fixing
"This type 'System.Object' was not loaded by the MetadataLoadContext"
failures when synthesizing the receiver TypeSpec for a call whose
parameter is a constructed CLR interface.
Restores the original IEnumerable[T] signatures on Sequences.Indexed /
Sequences.Pairwise in samples/TupleSequenceIterators.gs (the workaround
for #813 was the sequence[T] spelling).
Tests:
- Binder: 9 new tests covering issue repro plus IEnumerable[T] /
IList[T] / ICollection[T] / IReadOnlyList[T] at static-method and
free-function argument slots, plus negative variance guards.
- Emit: 7 new IL-verified CompileAndRun tests for the same shapes.
- Interpreter: 6 new closed-instantiation tests through GSharpRepl.
Related: #774 (open-generic receiver iteration), #813 (tuple-element
iterator state machines, source of the workaround being reverted),
#706 (parent / per-PR series).
Verified:
- dotnet test GSharp.sln green (5,253 passed, 1 skip baseline regen).
- ilverify clean (IlVerifier in every new emit test).
- website docs build clean (npm run build).1 parent f182b96 commit ba00f45
7 files changed
Lines changed: 939 additions & 6 deletions
File tree
- samples
- src/Core/CodeAnalysis
- Binding
- Emit
- test
- Compiler.Tests/Emit
- Core.Tests/CodeAnalysis/Binding
- Interpreter.Tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
462 | 462 | | |
463 | 463 | | |
464 | 464 | | |
465 | | - | |
| 465 | + | |
466 | 466 | | |
467 | 467 | | |
468 | 468 | | |
| |||
733 | 733 | | |
734 | 734 | | |
735 | 735 | | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
736 | 818 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
532 | 532 | | |
533 | 533 | | |
534 | 534 | | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
535 | 587 | | |
536 | 588 | | |
537 | 589 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5445 | 5445 | | |
5446 | 5446 | | |
5447 | 5447 | | |
| 5448 | + | |
| 5449 | + | |
| 5450 | + | |
| 5451 | + | |
| 5452 | + | |
| 5453 | + | |
| 5454 | + | |
| 5455 | + | |
| 5456 | + | |
| 5457 | + | |
| 5458 | + | |
| 5459 | + | |
| 5460 | + | |
| 5461 | + | |
| 5462 | + | |
| 5463 | + | |
| 5464 | + | |
| 5465 | + | |
| 5466 | + | |
| 5467 | + | |
| 5468 | + | |
| 5469 | + | |
| 5470 | + | |
| 5471 | + | |
| 5472 | + | |
| 5473 | + | |
| 5474 | + | |
| 5475 | + | |
| 5476 | + | |
| 5477 | + | |
| 5478 | + | |
| 5479 | + | |
| 5480 | + | |
| 5481 | + | |
| 5482 | + | |
| 5483 | + | |
| 5484 | + | |
| 5485 | + | |
| 5486 | + | |
| 5487 | + | |
| 5488 | + | |
| 5489 | + | |
| 5490 | + | |
| 5491 | + | |
| 5492 | + | |
| 5493 | + | |
| 5494 | + | |
| 5495 | + | |
| 5496 | + | |
| 5497 | + | |
| 5498 | + | |
| 5499 | + | |
| 5500 | + | |
5448 | 5501 | | |
5449 | 5502 | | |
5450 | 5503 | | |
| |||
6274 | 6327 | | |
6275 | 6328 | | |
6276 | 6329 | | |
6277 | | - | |
| 6330 | + | |
6278 | 6331 | | |
6279 | 6332 | | |
6280 | 6333 | | |
| |||
6380 | 6433 | | |
6381 | 6434 | | |
6382 | 6435 | | |
6383 | | - | |
| 6436 | + | |
| 6437 | + | |
| 6438 | + | |
| 6439 | + | |
| 6440 | + | |
| 6441 | + | |
| 6442 | + | |
| 6443 | + | |
| 6444 | + | |
6384 | 6445 | | |
6385 | 6446 | | |
6386 | 6447 | | |
| 6448 | + | |
6387 | 6449 | | |
6388 | 6450 | | |
6389 | | - | |
| 6451 | + | |
6390 | 6452 | | |
6391 | 6453 | | |
6392 | 6454 | | |
6393 | 6455 | | |
6394 | 6456 | | |
| 6457 | + | |
| 6458 | + | |
| 6459 | + | |
| 6460 | + | |
| 6461 | + | |
| 6462 | + | |
| 6463 | + | |
| 6464 | + | |
| 6465 | + | |
| 6466 | + | |
| 6467 | + | |
| 6468 | + | |
6395 | 6469 | | |
6396 | 6470 | | |
6397 | 6471 | | |
| |||
0 commit comments