-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes issue with nested method type args. (#6658)
## Description When a method application called another one that uses more type args than the impl trait type args the type substitution was not working. This was fixed by making a type substitution of placeholders of impl trait type parameters. ## Checklist - [x] I have linked to any relevant issues. - [x] I have commented my code, particularly in hard-to-understand areas. - [ ] 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: Sophie Dankel <47993817+sdankel@users.noreply.github.com> Co-authored-by: João Matos <joao@tritao.eu>
- Loading branch information
1 parent
ba8951e
commit cc842e3
Showing
7 changed files
with
138 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
test/src/e2e_vm_tests/test_programs/should_pass/language/method_nested_type_args/Forc.lock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[[package]] | ||
name = "core" | ||
source = "path+from-root-765123F2C684AE5A" | ||
|
||
[[package]] | ||
name = "method_nested_type_args" | ||
source = "member" | ||
dependencies = ["std"] | ||
|
||
[[package]] | ||
name = "std" | ||
source = "path+from-root-765123F2C684AE5A" | ||
dependencies = ["core"] |
8 changes: 8 additions & 0 deletions
8
test/src/e2e_vm_tests/test_programs/should_pass/language/method_nested_type_args/Forc.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[project] | ||
authors = ["Fuel Labs <contact@fuel.sh>"] | ||
license = "Apache-2.0" | ||
name = "method_nested_type_args" | ||
entry = "main.sw" | ||
|
||
[dependencies] | ||
std = { path = "../../../../reduced_std_libs/sway-lib-std-assert" } |
26 changes: 26 additions & 0 deletions
26
test/src/e2e_vm_tests/test_programs/should_pass/language/method_nested_type_args/src/main.sw
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
script; | ||
|
||
trait T1 {} | ||
trait T2 {} | ||
|
||
struct S<T> where T: T1 { | ||
x: T, | ||
} | ||
|
||
impl<T> S<T> where T: T1{ | ||
fn not_just_t1(self) -> u64 where T: T2 { | ||
Self::also_t2(self) | ||
} | ||
fn also_t2(self) -> u64 where T: T2 { | ||
42 | ||
} | ||
} | ||
|
||
impl T1 for u8 {} | ||
impl T1 for u64 {} | ||
impl T2 for u64 {} | ||
|
||
fn main() { | ||
let a = S::<u64>{x: 42}; | ||
assert_eq(a.not_just_t1(), 42); | ||
} |
5 changes: 5 additions & 0 deletions
5
test/src/e2e_vm_tests/test_programs/should_pass/language/method_nested_type_args/test.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
category = "run" | ||
expected_result = { action = "return", value = 0 } | ||
expected_result_new_encoding = { action = "return_data", value = "" } | ||
validate_abi = false | ||
expected_warnings = 1 |