Commit 5e22d64
Improve method resolution for trait method name bindings (#7364)
## Description
This PR improves method resolution for trait method name bindings, like
this following example:
```sway
script;
use std::time::Time;
pub fn main() {
let duration = Time::now().duration_since(Time::from(0)).unwrap();
let _ = duration + duration;
}
```
This fix is implemented in [Gather trait impls from the argument type
module when handling trait operator
calls.](8610000).
A general refactor was also done for associated method resolution
functions:
[Refactor
TypeCheckContext::find_method_for_type.](ace60ce)
[Refactor
resolve_method_name.](9d97d46)
Closes #7330.
## Checklist
- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
---------
Co-authored-by: IGI-111 <igi-111@protonmail.com>1 parent 4f1af43 commit 5e22d64
File tree
8 files changed
+614
-416
lines changed- sway-core/src
- language
- semantic_analysis
- ast_node/expression/typed_expression
- type_system
- test/src/e2e_vm_tests/test_programs/should_pass/trait_map_use_impl_in_scope
- src
8 files changed
+614
-416
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
375 | 375 | | |
376 | 376 | | |
377 | 377 | | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
378 | 385 | | |
379 | 386 | | |
380 | 387 | | |
| |||
Lines changed: 42 additions & 88 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
900 | 900 | | |
901 | 901 | | |
902 | 902 | | |
903 | | - | |
| 903 | + | |
904 | 904 | | |
905 | 905 | | |
906 | 906 | | |
907 | 907 | | |
908 | | - | |
| 908 | + | |
909 | 909 | | |
910 | 910 | | |
911 | 911 | | |
912 | 912 | | |
913 | | - | |
914 | | - | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
915 | 922 | | |
916 | 923 | | |
917 | 924 | | |
918 | 925 | | |
919 | | - | |
920 | 926 | | |
921 | 927 | | |
922 | 928 | | |
923 | 929 | | |
924 | | - | |
925 | | - | |
| 930 | + | |
926 | 931 | | |
927 | | - | |
928 | | - | |
| 932 | + | |
| 933 | + | |
929 | 934 | | |
930 | | - | |
| 935 | + | |
931 | 936 | | |
932 | | - | |
933 | | - | |
934 | | - | |
935 | | - | |
936 | | - | |
937 | | - | |
938 | | - | |
939 | | - | |
940 | | - | |
941 | | - | |
942 | | - | |
943 | | - | |
| 937 | + | |
944 | 938 | | |
| 939 | + | |
945 | 940 | | |
946 | | - | |
947 | | - | |
| 941 | + | |
948 | 942 | | |
949 | 943 | | |
950 | | - | |
951 | | - | |
952 | | - | |
| 944 | + | |
953 | 945 | | |
954 | 946 | | |
955 | 947 | | |
956 | 948 | | |
| 949 | + | |
957 | 950 | | |
958 | 951 | | |
959 | 952 | | |
960 | 953 | | |
961 | | - | |
| 954 | + | |
962 | 955 | | |
963 | 956 | | |
964 | 957 | | |
| |||
967 | 960 | | |
968 | 961 | | |
969 | 962 | | |
970 | | - | |
971 | | - | |
972 | | - | |
973 | | - | |
974 | | - | |
975 | | - | |
976 | | - | |
977 | | - | |
978 | | - | |
979 | | - | |
980 | | - | |
981 | | - | |
982 | | - | |
983 | | - | |
984 | | - | |
985 | | - | |
986 | | - | |
987 | | - | |
| 963 | + | |
| 964 | + | |
988 | 965 | | |
989 | | - | |
990 | | - | |
991 | | - | |
992 | 966 | | |
993 | | - | |
994 | | - | |
995 | | - | |
996 | | - | |
997 | | - | |
998 | | - | |
999 | | - | |
1000 | | - | |
1001 | | - | |
1002 | | - | |
1003 | | - | |
1004 | | - | |
1005 | | - | |
1006 | | - | |
1007 | | - | |
1008 | | - | |
1009 | | - | |
1010 | | - | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
1011 | 971 | | |
| 972 | + | |
1012 | 973 | | |
1013 | | - | |
1014 | | - | |
1015 | | - | |
| 974 | + | |
1016 | 975 | | |
1017 | | - | |
1018 | 976 | | |
1019 | | - | |
1020 | | - | |
1021 | | - | |
1022 | | - | |
1023 | | - | |
1024 | | - | |
1025 | | - | |
1026 | | - | |
1027 | | - | |
1028 | | - | |
1029 | | - | |
1030 | | - | |
1031 | | - | |
1032 | | - | |
1033 | | - | |
1034 | | - | |
| 977 | + | |
| 978 | + | |
1035 | 979 | | |
1036 | 980 | | |
1037 | 981 | | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
1038 | 992 | | |
1039 | 993 | | |
1040 | | - | |
| 994 | + | |
1041 | 995 | | |
1042 | 996 | | |
1043 | 997 | | |
| |||
0 commit comments