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

Lie to the Swift compiler about isolation #15

Merged
merged 1 commit into from
Jul 15, 2024

Conversation

Supereg
Copy link
Member

@Supereg Supereg commented Jul 15, 2024

Lie to the Swift compiler about isolation

♻️ Current situation & Problem

In PR #14 we truthfully implemented strict concurrency checking for the XCTRuntimeAssertions library. However, this made it impossible to test runtime precondition failures on the @MainActor as it would completely block the actor (or the Task would only be scheduled after the XCTRuntimePrecondition call returned).
Therefore, it is necessary to always run XCTRuntimePrecondition expressions on a background thread. If we would keep correct @Sendable annotations for the expression closure, this would make it impossible to run XCTRuntimePreconditions on the @MainActor. Therefore, we lie to the compiler. We deliberately don't annotate the expression closure as @Sendable and silence the respective concurrency warning.
The impact of that is documented.

⚙️ Release Notes

  • Restore testing preconditions which are annotated to be isolated to the @MainActor.

📚 Documentation

Add documentation bubbles to explain the impact.

✅ Testing

Add unit testing to prevent regressions.

Code of Conduct & Contributing Guidelines

By submitting creating this pull request, you agree to follow our Code of Conduct and Contributing Guidelines:

@Supereg Supereg requested a review from PSchmiedmayer July 15, 2024 18:19
Copy link

codecov bot commented Jul 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.48%. Comparing base (2ebbbb4) to head (d00ef0f).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #15      +/-   ##
==========================================
+ Coverage   91.34%   91.48%   +0.15%     
==========================================
  Files           8        8              
  Lines         300      305       +5     
==========================================
+ Hits          274      279       +5     
  Misses         26       26              
Files Coverage Δ
.../XCTRuntimeAssertions/XCTRuntimePrecondition.swift 98.08% <100.00%> (+0.10%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2ebbbb4...d00ef0f. Read the comment docs.

@PSchmiedmayer PSchmiedmayer added enhancement New feature or request bug Something isn't working labels Jul 15, 2024
@Supereg Supereg merged commit 7ce2801 into main Jul 15, 2024
10 checks passed
@Supereg Supereg deleted the fix/preconditions-on-mainactor branch July 15, 2024 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants