yandex / yandex/implicits

Improve immediate closure scope inheritance

Open
#45 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Swift
Stars
43
Forks
5
PR merge metrics
No merged PRs in 30d

Description

Follow-up to #44. The current implementation only supports MainActor.assumeIsolated with a hardcoded check. This issue tracks making the feature more general and user-extensible.

Tasks
  • Add more known immediate closure functionswithCheckedContinuation, withTaskGroup, withUnsafeBufferPointer, etc. Audit stdlib/concurrency APIs for functions that execute closures synchronously before returning.

  • Better matching — current matcher checks base.description == "MainActor" which is a string comparison on the syntax tree. Consider matching on the full qualified path and supporting chained member access.

  • User-side configuration or attribute-based system — allow users to declare their own immediate closure functions without modifying the library. Options:

    • Package-level config file listing immediate functions
    • A Swift attribute/annotation on function declarations (e.g. @ImmediateClosure on specific parameters)
  • Per-parameter granularity — move from "this function is immediate" to "this parameter is immediate". Functions can have multiple closure parameters where some execute immediately and some are escaping (e.g. UIView.animate(withDuration:animations:completion:)). Requires #43 first to model multiple trailing closures in the syntax tree.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the current MainActor.assumeIsolated handling and its syntax-tree matcher, then review #43 before designing per-parameter support. Audit the listed standard-library and concurrency APIs, and compare configuration and attribute-based options. Done means immediate closures are matched beyond the hardcoded case, user-extensible, and granular enough for functions with multiple closure parameters.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.