Skip to content

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

Merged

Conversation

jrose-apple
Copy link
Contributor

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

@jrose-apple
Copy link
Contributor Author

@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.
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe just assert here?

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 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 {
Copy link
Contributor

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?

@swift-ci
Copy link
Contributor

Build failed
Jenkins build - Swift Test OS X Platform
Git Commit - 2cfcde1820883e16d9b0f1c6cc429d0a69408660
Test requested by - @jrose-apple

Copy link
Member

@DougGregor DougGregor left a 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!

@jrose-apple
Copy link
Contributor Author

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
@jrose-apple jrose-apple force-pushed the inherited-default-arguments branch from 2cfcde1 to 3b4c9b9 Compare January 31, 2017 22:07
@jrose-apple
Copy link
Contributor Author

jrose-apple commented Jan 31, 2017

Test cases added, dependent on #7169. @slavapestov, does this look good to you?

#7169
@swift-ci Please smoke test

@jrose-apple
Copy link
Contributor Author

@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

@slavapestov
Copy link
Contributor

LGTM

/me daydreams of one day having some kind of multi-file decl fuzzer...

@jrose-apple jrose-apple merged commit cde3543 into swiftlang:master Feb 1, 2017
@jrose-apple jrose-apple deleted the inherited-default-arguments branch February 1, 2017 00:30
@shahmishal
Copy link
Member

Setting status of 3b4c9b9116e726a172d0c0d03d5332df1ccc23e7 to FAILURE with url https://ci.swift.org/job/swift-PR-osx-smoke-test/4784/ and message: ' '
Using context: Swift Test OS X Platform (smoke test)

Not sure, it has the right sha.

@jrose-apple
Copy link
Contributor Author

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.

@jrose-apple
Copy link
Contributor Author

Or maybe I'll just do it the normal way from now on: base one branch on the other.

jrose-apple added a commit to jrose-apple/swift that referenced this pull request Feb 1, 2017
…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
tkremenek pushed a commit that referenced this pull request Feb 1, 2017
…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
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.

5 participants