Skip to content

Conversation

@btroller
Copy link
Contributor

@btroller btroller commented May 5, 2025

A bit of cleanup related to changes I made a while back for #71168.

Those changes added the method withContext() to SwiftReflectionContext, which templates over both the return type and the passed lambda. This can be simplified to just templating over the lambda and returning an 'auto', which doesn't require passing the templated return type at the call sites:

  return ContextRef->withContext<int>([&](auto *Context) {
    return Context->addImage(RemoteAddress(imageStart)).has_value();
  });

⬇️

  return ContextRef->withContext([&](auto *Context) {
    return Context->addImage(RemoteAddress(imageStart)).has_value();
  });

@btroller btroller requested a review from mikeash May 5, 2025 22:32
@btroller btroller requested a review from slavapestov as a code owner May 5, 2025 22:32
@btroller
Copy link
Contributor Author

btroller commented May 5, 2025

@swift-ci Please test

Copy link
Contributor

@mikeash mikeash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice little improvement.

@btroller btroller merged commit 3123cb0 into swiftlang:main May 7, 2025
5 checks passed
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.

3 participants