Skip to content

[silgen] Teach SILGen how to emit a forced dynamic member ref given nonisolated(nonsending) casts. #82029

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

Conversation

gottesmm
Copy link
Contributor

@gottesmm gottesmm commented Jun 5, 2025

Specifically, I taught SILGen how to emit an AST like the following:

(force_value_expr implicit type="nonisolated(nonsending) (Date?) async -> Void" implicit_iuo_unwrap
  (open_existential_expr implicit type="(nonisolated(nonsending) (Date?) async  -> Void)?"
    (opaque_value_expr implicit type="AnyObject")
    (declref_expr type="AnyObject" decl="test.(file).repro()[email protected]:6:7" function_ref=unapplied)
    (optional_evaluation_expr type="(nonisolated(nonsending) (Date?) async -> Void)?"
      (inject_into_optional type="(nonisolated(nonsending) (Date?) async -> Void)?"
        (function_conversion_expr type="nonisolated(nonsending) (Date?) async -> Void"
          (bind_optional_expr type="(Date?) async -> Void" depth=0
            (dynamic_member_ref_expr type="((Date?) async -> Void)?" decl="__ObjC.(file).Foo.start(at:)"
              (opaque_value_expr type="AnyObject"))))))))

Since we are emitting an objc async function, there isn't an extra implicit parameter like if we were using a swift async function. So, I just reused code that was already used locally to look through these sorts of conversions. I just had to add to that code support for conversions that add nonisolated(nonsending). Previously it only supported looking through global actor conversions.

rdar://152596823

@gottesmm gottesmm requested a review from jckarter as a code owner June 5, 2025 20:32
@gottesmm
Copy link
Contributor Author

gottesmm commented Jun 5, 2025

@swift-ci smoke test

…onisolated(nonsending) casts.

Specifically, I taught SILGen how to emit an AST like the following:

```
(force_value_expr implicit type="nonisolated(nonsending) (Date?) async -> Void" implicit_iuo_unwrap
  (open_existential_expr implicit type="(nonisolated(nonsending) (Date?) async  -> Void)?"
    (opaque_value_expr implicit type="AnyObject")
    (declref_expr type="AnyObject" decl="test.(file).repro()[email protected]:6:7" function_ref=unapplied)
    (optional_evaluation_expr type="(nonisolated(nonsending) (Date?) async -> Void)?"
      (inject_into_optional type="(nonisolated(nonsending) (Date?) async -> Void)?"
        (function_conversion_expr type="nonisolated(nonsending) (Date?) async -> Void"
          (bind_optional_expr type="(Date?) async -> Void" depth=0
            (dynamic_member_ref_expr type="((Date?) async -> Void)?" decl="__ObjC.(file).Foo.start(at:)"
              (opaque_value_expr type="AnyObject"))))))))
```

Since we are emitting an objc async function, there isn't an extra implicit
parameter like if we were using a swift async function. So, I just reused code
that was already used locally to look through these sorts of conversions. I
just had to add to that code support for conversions that add
nonisolated(nonsending). Previously it only supported looking through global
actor conversions.

rdar://152596823
@gottesmm gottesmm force-pushed the pr-4393908bd2ab4d5c84cd415ea5da407b148fceb1 branch from 12f2298 to 662dbdb Compare June 5, 2025 20:34
@gottesmm
Copy link
Contributor Author

gottesmm commented Jun 5, 2025

@swift-ci smoke test

@gottesmm gottesmm requested a review from rjmccall June 5, 2025 20:35
@gottesmm gottesmm enabled auto-merge June 6, 2025 00:15
@gottesmm
Copy link
Contributor Author

gottesmm commented Jun 6, 2025

@swift-ci smoke test linux platform

@gottesmm gottesmm merged commit 4b06d1e into swiftlang:main Jun 6, 2025
3 checks passed
@gottesmm gottesmm deleted the pr-4393908bd2ab4d5c84cd415ea5da407b148fceb1 branch June 6, 2025 17:36
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.

2 participants