Skip to content

Conversation

tritao
Copy link
Contributor

@tritao tritao commented Aug 30, 2025

Description

This PR improves method resolution fo trait method name bindings, like this following example:

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..

A general refactor was also done for associated method resolution functions:

Refactor TypeCheckContext::find_method_for_type.

Refactor resolve_method_name.

Closes #7330.

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.

@tritao tritao self-assigned this Aug 30, 2025
@tritao tritao added compiler General compiler. Should eventually become more specific as the issue is triaged compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen labels Aug 30, 2025
Copy link

codspeed-hq bot commented Aug 30, 2025

CodSpeed Performance Report

Merging #7364 will improve performances by 22.38%

Comparing tritao:refactor-find-method-for-type (8610000) with master (1f9880f)

Summary

⚡ 1 improvements
✅ 24 untouched benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
code_lens 5.8 µs 4.8 µs +22.38%

@tritao tritao force-pushed the refactor-find-method-for-type branch from 7993294 to 9bfc436 Compare September 4, 2025 09:22
@tritao tritao changed the title Refactor TypeCheckContext::find_method_for_type Improve method resolution for trait method name bindings Sep 4, 2025
@tritao tritao force-pushed the refactor-find-method-for-type branch from 9bfc436 to f57f75b Compare September 4, 2025 18:58
@tritao tritao marked this pull request as ready for review September 4, 2025 23:20
@tritao tritao requested a review from a team as a code owner September 4, 2025 23:20
@tritao tritao force-pushed the refactor-find-method-for-type branch from f57f75b to 8610000 Compare September 4, 2025 23:21
@tritao tritao deployed to fuel-sway-bot September 4, 2025 23:21 — with GitHub Actions Active
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen compiler General compiler. Should eventually become more specific as the issue is triaged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Some implementations still require imports
1 participant