Skip to content

(WIP) Fixing up @autoclosure #10094

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

Closed

Conversation

slavapestov
Copy link
Contributor

No description provided.

The type of an @autoclosure parameter as seen inside a function
body should *not* have the @autoclosure attribute.

We should only ever see @autoclosure on a parameter type of a
function being called, because it introduces an implicit
conversion from T => @autoclosure () -> T.

Fixes <rdar://problem/20591571> and <rdar://problem/30906031>.
Saying "implicitly non-escaping because it was declared @autoclosure"
does not make sense. Parameters of function type are now always
non-escaping by default, whether or not they are @autoclosure.

This note is a holdover from the Swift 2 days, where escaping was
the default, and @autoclosure implied @NoEscape.

Now, always emit the basic "implicitly non-escaping" note.
rjmccall added a commit to rjmccall/swift that referenced this pull request Jun 19, 2018
This is correct because it's the apparent rule used by CSSimplify:
value-to-autoclosure conversion is considered if and only if the
input type is not an autoclosure function type.

The real solution to this problem is that @autoclosure should be tracked
as a bit on the parameter type instead of as a bit on function types.
Slava has a PR leading towards that (swiftlang#10094),
but it causes a source-compatibility problem when forwarding autoclosures.
You really shouldn't be able to forward autoclosures, but that's an
issue for the core team to resolve, and in the meantime there's this bug.

Fixes rdar://41219750.
@slavapestov
Copy link
Contributor Author

@xedin fixed this better on master.

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.

1 participant