-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Fix generic method overrides #5424
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
swift-ci
merged 5 commits into
swiftlang:master
from
slavapestov:fix-generic-method-overrides
Oct 24, 2016
Merged
Fix generic method overrides #5424
swift-ci
merged 5 commits into
swiftlang:master
from
slavapestov:fix-generic-method-overrides
Oct 24, 2016
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@swift-ci Please smoke test |
This generalizes some code in Sema to fix the problem where generic method overrides don't work if the base class is more or less generic than the derived class. The problem here was that we were checking types for equality when matching overrides, which failed if generic parameters had different depths. Now, map the generic parameters of the base class member to the generic signature of the derived member, so that the equality check can succeed. Since SIL type lowering needs to perform a similar check, move this from Sema to a method on TypeBase to complement the existing getTypeOfMember(). Note that getTypeOfMember() still does a superclass walk, but ideally this will go away soon.
The isTypeReference parameter is now always true, so change the function to just take a TypeDecl.
We can use the new adjustSuperclassMemberDeclType() method here to eliminate some code duplication and fix some corner cases with generic method overrides. Fixes <rdar://problem/18560464>, <https://bugs.swift.org/browse/SR-2427>, <https://bugs.swift.org/browse/SR-2721>.
59a0619
to
2876437
Compare
@swift-ci Please test and merge |
1 similar comment
@swift-ci Please test and merge |
jrose-apple
reviewed
Oct 24, 2016
/// Get the type of a superclass member as seen from the subclass, | ||
/// substituting generic parameters, dynamic Self return, and the | ||
/// 'self' argument type as appropriate. | ||
Type adjustSuperclassMemberDeclType(const ValueDecl *decl, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is this different from getTypeOfMember
?
This was referenced Oct 24, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes a tricky corner case where method overrides did not work in the following case:
Eg,
Fixes rdar://problem/18560464, https://bugs.swift.org/browse/SR-2427,
https://bugs.swift.org/browse/SR-2721.