Skip to content

[TypeChecker] Drop @autoclosure attribute from invalid parameters #22186

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

Merged
merged 1 commit into from
Jan 29, 2019

Conversation

xedin
Copy link
Contributor

@xedin xedin commented Jan 28, 2019

While forming/validating parameters make sure that the type is indeed
a function type before marking it as autoclosure based on type
representative attributes, because parser doesn't change attributes
even after the error has been found and diagnosed.

Resolves: rdar://problem/47586626

@xedin xedin requested a review from slavapestov January 28, 2019 22:54
@xedin
Copy link
Contributor Author

xedin commented Jan 28, 2019

@swift-ci please smoke test

@xedin
Copy link
Contributor Author

xedin commented Jan 28, 2019

@swift-ci please test source compatibility

@xedin
Copy link
Contributor Author

xedin commented Jan 28, 2019

Actually it looks like I don't even need to mess with flags if declaration is marked as invalid, going to update PR in a few minutes.

@xedin
Copy link
Contributor Author

xedin commented Jan 28, 2019

@swift-ci please smoke test

@xedin
Copy link
Contributor Author

xedin commented Jan 28, 2019

@swift-ci please test source compatibility

// At this point we actually don't know if that's valid to mark
// this parameter declaration as `autoclosure` because type has
// not been resolved yet - it should either be a function type
// or typealias with underlying function type.
Copy link
Member

Choose a reason for hiding this comment

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

Huh, does this fix rdar://problem/47550733 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that must be something else because it's related to @escaping attribute.

// this decision couldn't be made based on type representative
// alone because it may be later resolved into an invalid type.
if (decl->isAutoClosure())
hadError |= !(Ty && Ty->is<FunctionType>());
Copy link
Member

Choose a reason for hiding this comment

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

Can we pull the diagnostic and the hadError = true; closer together? It feels strange to have them separated like this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently diagnostic is produced by type resolver but I can definitely move it to validateParameterType, not sure how much work that would be though.

Maybe it would make sense to revisit diagnostics separately from this PR?

While forming/validating parameters make sure that the type is indeed
a function type before marking it as `autoclosure` based on type
representative attributes, because parser doesn't change attributes
even after the error has been found and diagnosed.

Resolves: rdar://problem/47586626
@xedin
Copy link
Contributor Author

xedin commented Jan 29, 2019

@swift-ci please smoke test

@xedin
Copy link
Contributor Author

xedin commented Jan 29, 2019

@swift-ci please test source compatibility

@xedin
Copy link
Contributor Author

xedin commented Jan 29, 2019

Are you guys okay with me merging this as is? (I'd like to keep it minimal so it could be cherry-picked to 5.0)

@xedin xedin merged commit 2e0c6db into swiftlang:master Jan 29, 2019
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