Improve immediate closure scope inheritance
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 functions —
withCheckedContinuation,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.
@ImmediateClosureon 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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