Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically import contract return type #6089

Merged
merged 8 commits into from
Jun 10, 2024

Conversation

xunilrj
Copy link
Contributor

@xunilrj xunilrj commented Jun 4, 2024

Description

This PR fixes #5936.

To avoid the error, we are importing all impls for all types in the contract return, but we are NOT binding the type name. That means that the return type becomes usable (fields, methods and trait impls), but one cannot instantiate the type. For that, the type still needs to be imported manually.

Checklist

  • I have linked to any relevant issues.
  • 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).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

@xunilrj xunilrj requested a review from a team as a code owner June 4, 2024 11:24
@xunilrj xunilrj self-assigned this Jun 4, 2024
Copy link

github-actions bot commented Jun 4, 2024

Benchmark for 0bc3d79

Click to view benchmark
Test Base PR %
code_action 5.6±0.02ms 5.7±0.21ms +1.79%
code_lens 335.0±10.42ns 337.1±8.95ns +0.63%
compile 4.1±0.07s 4.2±0.08s +2.44%
completion 4.8±0.08ms 4.9±0.10ms +2.08%
did_change_with_caching 3.7±0.09s 3.9±0.08s +5.41%
document_symbol 973.6±23.79µs 992.7±14.36µs +1.96%
format 75.3±2.01ms 74.1±0.74ms -1.59%
goto_definition 405.1±6.48µs 370.4±7.70µs -8.57%
highlight 9.2±0.08ms 9.4±0.38ms +2.17%
hover 581.1±3.39µs 547.5±15.42µs -5.78%
idents_at_position 122.8±0.48µs 123.9±1.36µs +0.90%
inlay_hints 662.8±22.09µs 675.3±22.41µs +1.89%
on_enter 483.9±46.13ns 468.1±19.30ns -3.27%
parent_decl_at_position 3.8±0.05ms 3.8±0.07ms 0.00%
prepare_rename 405.4±5.59µs 372.6±7.35µs -8.09%
rename 9.9±0.15ms 10.2±0.23ms +3.03%
semantic_tokens 991.8±39.65µs 998.8±31.08µs +0.71%
token_at_position 353.4±5.30µs 358.6±3.34µs +1.47%
tokens_at_position 3.8±0.02ms 3.9±0.15ms +2.63%
tokens_for_file 430.9±1.80µs 429.8±5.62µs -0.26%
traverse 40.1±0.96ms 41.5±1.11ms +3.49%

@xunilrj xunilrj force-pushed the xunilrj/import-contract-return-type branch from 49657e9 to e11e6ce Compare June 5, 2024 12:22
Copy link

github-actions bot commented Jun 5, 2024

Benchmark for 11be442

Click to view benchmark
Test Base PR %
code_action 5.3±0.12ms 5.2±0.21ms -1.89%
code_lens 332.2±12.06ns 335.1±18.16ns +0.87%
compile 3.9±0.06s 3.9±0.08s 0.00%
completion 4.7±0.11ms 4.6±0.22ms -2.13%
did_change_with_caching 3.6±0.06s 3.6±0.09s 0.00%
document_symbol 1021.3±23.71µs 1016.9±38.60µs -0.43%
format 71.5±1.71ms 73.7±2.26ms +3.08%
goto_definition 378.3±10.40µs 395.5±11.93µs +4.55%
highlight 9.0±0.24ms 8.7±0.30ms -3.33%
hover 556.3±8.53µs 574.9±12.17µs +3.34%
idents_at_position 121.6±2.31µs 122.6±2.40µs +0.82%
inlay_hints 653.4±31.46µs 648.0±21.59µs -0.83%
on_enter 462.6±15.55ns 459.7±22.01ns -0.63%
parent_decl_at_position 3.7±0.06ms 3.5±0.06ms -5.41%
prepare_rename 378.4±6.33µs 397.4±24.49µs +5.02%
rename 9.5±0.21ms 9.3±0.49ms -2.11%
semantic_tokens 955.8±23.93µs 969.4±17.36µs +1.42%
token_at_position 351.3±6.48µs 352.8±5.50µs +0.43%
tokens_at_position 3.7±0.04ms 3.5±0.07ms -5.41%
tokens_for_file 423.4±7.03µs 424.6±5.90µs +0.28%
traverse 38.2±1.47ms 38.7±1.31ms +1.31%

Copy link

github-actions bot commented Jun 5, 2024

Benchmark for 63d3985

Click to view benchmark
Test Base PR %
code_action 5.4±0.12ms 5.4±0.10ms 0.00%
code_lens 333.7±9.48ns 338.2±7.18ns +1.35%
compile 4.1±0.08s 4.0±0.08s -2.44%
completion 4.8±0.11ms 4.7±0.06ms -2.08%
did_change_with_caching 3.8±0.06s 3.7±0.10s -2.63%
document_symbol 993.8±35.91µs 971.9±16.94µs -2.20%
format 73.5±1.17ms 73.1±1.29ms -0.54%
goto_definition 364.0±6.45µs 361.7±6.29µs -0.63%
highlight 9.1±0.37ms 9.0±0.12ms -1.10%
hover 538.3±9.26µs 542.1±8.10µs +0.71%
idents_at_position 124.9±0.33µs 122.7±0.81µs -1.76%
inlay_hints 658.3±11.98µs 658.7±22.27µs +0.06%
on_enter 455.2±11.72ns 466.5±12.03ns +2.48%
parent_decl_at_position 3.7±0.02ms 3.7±0.05ms 0.00%
prepare_rename 373.4±20.33µs 363.6±18.42µs -2.62%
rename 9.6±0.15ms 9.6±0.17ms 0.00%
semantic_tokens 984.6±33.48µs 975.4±12.49µs -0.93%
token_at_position 359.7±2.52µs 358.3±2.08µs -0.39%
tokens_at_position 3.7±0.03ms 3.7±0.02ms 0.00%
tokens_for_file 433.0±2.12µs 430.2±2.23µs -0.65%
traverse 41.0±1.64ms 41.7±0.83ms +1.71%

tritao
tritao previously approved these changes Jun 5, 2024
Copy link
Contributor

@tritao tritao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good apart from single nit

Copy link

github-actions bot commented Jun 6, 2024

Benchmark for b5bd0f5

Click to view benchmark
Test Base PR %
code_action 5.4±0.14ms 5.5±0.17ms +1.85%
code_lens 336.1±11.29ns 339.2±14.80ns +0.92%
compile 4.1±0.13s 4.2±0.05s +2.44%
completion 4.7±0.01ms 4.9±0.19ms +4.26%
did_change_with_caching 3.8±0.08s 3.7±0.09s -2.63%
document_symbol 950.9±31.98µs 950.0±32.68µs -0.09%
format 73.7±1.20ms 73.9±0.70ms +0.27%
goto_definition 369.6±21.97µs 364.6±8.63µs -1.35%
highlight 9.1±0.22ms 9.1±0.05ms 0.00%
hover 542.1±8.57µs 541.1±7.93µs -0.18%
idents_at_position 124.3±1.07µs 124.1±1.14µs -0.16%
inlay_hints 672.0±30.98µs 679.2±52.98µs +1.07%
on_enter 457.0±13.34ns 460.8±13.57ns +0.83%
parent_decl_at_position 3.7±0.03ms 3.8±0.05ms +2.70%
prepare_rename 365.7±10.47µs 367.8±7.84µs +0.57%
rename 9.7±0.23ms 10.0±0.19ms +3.09%
semantic_tokens 987.7±23.26µs 978.0±23.63µs -0.98%
token_at_position 361.9±4.38µs 355.6±2.78µs -1.74%
tokens_at_position 3.7±0.06ms 3.7±0.04ms 0.00%
tokens_for_file 433.8±1.89µs 426.3±4.01µs -1.73%
traverse 40.3±2.03ms 41.5±1.75ms +2.98%

Copy link
Contributor

@jjcnn jjcnn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. We do need to make sure that this still works when combined with #6044 , but I don't see anything that immediately conflicts with it.

@IGI-111 IGI-111 enabled auto-merge (squash) June 8, 2024 01:38
Copy link

github-actions bot commented Jun 8, 2024

Benchmark for 956f5a0

Click to view benchmark
Test Base PR %
code_action 5.3±0.24ms 5.3±0.14ms 0.00%
code_lens 295.0±24.75ns 294.6±8.76ns -0.14%
compile 4.0±0.08s 4.0±0.10s 0.00%
completion 4.7±0.12ms 4.6±0.01ms -2.13%
did_change_with_caching 3.7±0.10s 3.6±0.02s -2.70%
document_symbol 1022.8±71.56µs 1012.6±18.53µs -1.00%
format 72.2±1.46ms 71.2±1.05ms -1.39%
goto_definition 378.8±3.16µs 367.9±6.28µs -2.88%
highlight 8.7±0.18ms 8.7±0.02ms 0.00%
hover 543.7±10.41µs 547.2±5.13µs +0.64%
idents_at_position 123.8±0.37µs 122.6±1.51µs -0.97%
inlay_hints 675.4±9.68µs 645.8±8.61µs -4.38%
on_enter 469.6±18.06ns 459.7±11.35ns -2.11%
parent_decl_at_position 3.6±0.01ms 3.6±0.03ms 0.00%
prepare_rename 369.2±5.84µs 367.8±5.34µs -0.38%
rename 9.2±0.06ms 9.4±0.23ms +2.17%
semantic_tokens 981.1±12.93µs 969.7±14.68µs -1.16%
token_at_position 361.7±2.30µs 359.0±4.78µs -0.75%
tokens_at_position 3.6±0.03ms 3.6±0.02ms 0.00%
tokens_for_file 416.3±2.20µs 433.7±6.46µs +4.18%
traverse 40.1±0.88ms 40.6±1.11ms +1.25%

@IGI-111 IGI-111 merged commit f4f9c13 into master Jun 10, 2024
36 checks passed
@IGI-111 IGI-111 deleted the xunilrj/import-contract-return-type branch June 10, 2024 07:54
Copy link

Benchmark for 0fac7e1

Click to view benchmark
Test Base PR %
code_action 5.6±0.25ms 5.3±0.03ms -5.36%
code_lens 289.6±13.02ns 285.2±8.62ns -1.52%
compile 4.3±0.09s 4.0±0.09s -6.98%
completion 4.7±0.16ms 4.9±0.17ms +4.26%
did_change_with_caching 3.9±0.08s 3.6±0.05s -7.69%
document_symbol 1052.4±15.53µs 991.2±35.96µs -5.82%
format 71.9±1.76ms 72.9±0.94ms +1.39%
goto_definition 373.2±7.38µs 371.0±7.53µs -0.59%
highlight 8.9±0.22ms 8.8±0.08ms -1.12%
hover 551.0±9.51µs 545.3±6.95µs -1.03%
idents_at_position 122.8±0.35µs 124.0±0.96µs +0.98%
inlay_hints 670.0±68.02µs 723.2±33.98µs +7.94%
on_enter 462.5±23.95ns 493.0±12.44ns +6.59%
parent_decl_at_position 3.6±0.04ms 3.6±0.06ms 0.00%
prepare_rename 377.4±4.46µs 367.1±6.82µs -2.73%
rename 9.5±0.30ms 9.4±0.27ms -1.05%
semantic_tokens 978.7±22.22µs 1004.7±36.50µs +2.66%
token_at_position 356.7±2.83µs 366.7±2.35µs +2.80%
tokens_at_position 3.6±0.03ms 3.6±0.06ms 0.00%
tokens_for_file 416.1±5.55µs 425.7±3.15µs +2.31%
traverse 42.2±0.98ms 39.9±1.52ms -5.45%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Contract calls need their return method imported manually
4 participants