Skip to content

[Typechecker] Fix duplicate diagnostics when using attributes #28888

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 4 commits into from
Dec 20, 2019
Merged

[Typechecker] Fix duplicate diagnostics when using attributes #28888

merged 4 commits into from
Dec 20, 2019

Conversation

theblixguy
Copy link
Collaborator

@theblixguy theblixguy commented Dec 20, 2019

We were not invalidating the TypeRepr after diagnosing in resolveAttributedType, which meant that trying to resolving the type for the same TypeRepr would result in the same diagnostic multiple times.

It seems to affect just @autoclosure and @escaping in some cases (and @noescape which is not supported anymore), but I've applied the invalidation in all cases to future proof this.

Resolves SR-9178

… after emitting a diagnostic, to prevent duplicate diagnostics later
@theblixguy theblixguy requested a review from xedin December 20, 2019 00:42
@theblixguy
Copy link
Collaborator Author

@swift-ci please smoke test

@theblixguy
Copy link
Collaborator Author

@swift-ci please smoke test

Copy link
Contributor

@xedin xedin left a comment

Choose a reason for hiding this comment

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

So seeing a pattern here - should we add a special diagnose method to TypeResolver just like we have for FailureDiagnostic which would also take repr and invalidate it internally?

@theblixguy
Copy link
Collaborator Author

@xedin Sure thing, I have done that now!

@theblixguy
Copy link
Collaborator Author

@swift-ci please smoke test

Copy link
Contributor

@xedin xedin left a comment

Choose a reason for hiding this comment

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

LGTM!

@xedin xedin requested a review from rintaro December 20, 2019 17:48
@xedin
Copy link
Contributor

xedin commented Dec 20, 2019

I have added @rintaro as a reviewer as well since he spend some time on type resolution as well.

Copy link
Member

@rintaro rintaro left a comment

Choose a reason for hiding this comment

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

No objection to this. Thanks!

@theblixguy theblixguy merged commit 3cda934 into swiftlang:master Dec 20, 2019
@theblixguy theblixguy deleted the fix/SR-9178 branch December 20, 2019 19:26
kitaisreal pushed a commit to kitaisreal/swift that referenced this pull request Dec 22, 2019
…ang#28888)

* [Typechecker] resolveAttributedType() should invalidate the type repr after emitting a diagnostic, to prevent duplicate diagnostics later

* [Test] Update '@NoEscape' attribute diagnostics

* [Typechecker] Add a special diagnose method to TypeResolver that accepts a TypeRepr and invalidates it

* [Typechecker] Rename the special 'diagnose' method to 'diagnoseInvalid' for clarity
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