Commit 27c5fc1
fix(semantic+codegen): complete __getitem__/__setitem__ support for user-defined types (#279)
- Fix TypeInferenceService to check ProtocolMethods (not just OperatorMethods) for
__getitem__, since container dunders are protocol dunders
- Add codegen for IndexAccess on user-defined types: emit obj.GetItem(key) instead
of obj[key] since user-defined classes don't have C# indexer properties
- Add codegen for index assignment on user-defined types: emit obj.SetItem(key, value)
instead of obj[key] = value
- Remove dunder_container.skip now that the test passes end-to-end
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent 8330880 commit 27c5fc1
4 files changed
Lines changed: 45 additions & 5 deletions
File tree
- src
- Sharpy.Compiler.Tests/Integration/TestFixtures/classes
- Sharpy.Compiler
- CodeGen
- Semantic
Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 15 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
877 | 877 | | |
878 | 878 | | |
879 | 879 | | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
880 | 895 | | |
881 | 896 | | |
882 | 897 | | |
883 | 898 | | |
884 | 899 | | |
885 | | - | |
886 | 900 | | |
887 | 901 | | |
888 | 902 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
395 | 395 | | |
396 | 396 | | |
397 | 397 | | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
398 | 424 | | |
399 | 425 | | |
400 | 426 | | |
401 | 427 | | |
402 | | - | |
| 428 | + | |
403 | 429 | | |
404 | 430 | | |
405 | 431 | | |
406 | 432 | | |
407 | 433 | | |
408 | 434 | | |
409 | 435 | | |
410 | | - | |
| 436 | + | |
411 | 437 | | |
412 | 438 | | |
413 | 439 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
730 | 730 | | |
731 | 731 | | |
732 | 732 | | |
733 | | - | |
| 733 | + | |
| 734 | + | |
734 | 735 | | |
735 | 736 | | |
736 | 737 | | |
| |||
0 commit comments