-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Fix ParameterList::clone to handle deserialized defaults arguments. #7156
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
Fix ParameterList::clone to handle deserialized defaults arguments. #7156
Conversation
@swift-ci Please test |
@@ -102,8 +103,12 @@ ParameterList *ParameterList::clone(const ASTContext &C, | |||
decl->setName(C.getIdentifier("argument")); | |||
|
|||
// If we're inheriting a default argument, mark it as such. | |||
if (hadDefaultArgument && (options & Inherited)) { | |||
decl->setDefaultArgumentKind(DefaultArgumentKind::Inherited); | |||
// FIXME: Figure out how to clone default arguments as well. |
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.
Maybe just assert here?
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.
I had that at first and then had a wave of paranoia that someone would be depending on the current behavior. Not copying over the expression is nearly the same as setting the kind to None, but not quite.
@@ -0,0 +1,3 @@ | |||
open class Base { |
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.
Can you test the generic case also just in case?
Build failed |
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.
Ah, this explains the issue we had seen before. Thank you, LGTM!
Some generic cases are still broken. Glad Slava suggested looking at it! |
It was checking the wrong predicate, and therefore failing to mark inherited default arguments as actually being inherited. While here, explicitly clear out default arguments from non-inherited cloned parameter lists. I don't think this case can come up today, but it's better to be correct when we do hit it. rdar://problem/30167924
2cfcde1
to
3b4c9b9
Compare
Test cases added, dependent on #7169. @slavapestov, does this look good to you? |
@shahmishal, any idea why the above comment didn't result in https://ci.swift.org/job/swift-PR-osx-smoke-test/4784/ building with #7169? Well, that PR's been merged by now, so trying again. @swift-ci Please smoke test |
LGTM /me daydreams of one day having some kind of multi-file decl fuzzer... |
Not sure, it has the right sha. |
It built the correct SHA, and it identified the other PR as interesting. It just didn't merge it in for some reason. ...oh, because it's the same repo. I'll file a feature request for that. |
Or maybe I'll just do it the normal way from now on: base one branch on the other. |
…wiftlang#7156) It was checking the wrong predicate, and therefore failing to mark inherited default arguments as actually being inherited. While here, explicitly clear out default arguments from non-inherited cloned parameter lists. I don't think this case can come up today, but it's better to be correct when we do hit it. rdar://problem/30167924
…ed initializer (#7171) * [SILGen] Don't crash when calling a generic init with default args. (#7169) In cases where a default value is used for a parameter with generic type, the argument list might be empty. In that case, we don't need to emit any arguments! * Fix ParameterList::clone to handle deserialized defaults arguments. (#7156) It was checking the wrong predicate, and therefore failing to mark inherited default arguments as actually being inherited. While here, explicitly clear out default arguments from non-inherited cloned parameter lists. I don't think this case can come up today, but it's better to be correct when we do hit it. rdar://problem/30167924
It was checking the wrong predicate, and therefore failing to mark inherited default arguments as actually being inherited.
While here, explicitly clear out default arguments from non-inherited cloned parameter lists. I don't think this case can come up today, but it's better to be correct when we do hit it.
rdar://problem/30167924