Skip to content

Sema: Fix order dependency in @objc inference from witnessed protocol requirement #24255

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

slavapestov
Copy link
Contributor

If we haven't validated the declaration yet, the 'witnesses @objc
requirement' check would immediately fail. Move the validateDecl()
call to matchWitness() to fix this.

Fixes rdar://problem/49482328, https://bugs.swift.org/browse/SR-10257.

@slavapestov slavapestov requested a review from jrose-apple April 24, 2019 21:12
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

… requirement

If we haven't validated the declaration yet, the 'witnesses @objc
requirement' check would immediately fail. Move the validateDecl()
call to matchWitness() to fix this.

Fixes <rdar://problem/49482328>, <https://bugs.swift.org/browse/SR-10257>.
@slavapestov slavapestov force-pushed the objc-from-witnessed-requirement-ordering branch from 6cd1afd to 04ac33d Compare April 24, 2019 21:35
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

Copy link
Contributor

@jrose-apple jrose-apple left a comment

Choose a reason for hiding this comment

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

Ugh. This makes sense. Only one comment regarding cases of actual circularity:

// If the witness is invalid, record that and stop now.
if (witness->isInvalid())
return RequirementMatch(witness, MatchKind::WitnessInvalid);

// If we're currently validating the witness, bail out.
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment seems like it shouldn't be correct. Either this function is called re-entrantly and will loop infinitely because of the above call, or the above call notices the circularity and returns without setting anything up. If you're talking about the latter, maybe this should move inside the first if to make it clearer what's going on?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, it's not this function that's called re-entrantly; the bad case is when validateDecl() calls us, and we call validateDecl(). In this case validateDecl() returns without doing anything.

@slavapestov slavapestov merged commit e68a233 into swiftlang:master Apr 25, 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.

2 participants