-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[ParseableInterfaces] Support inheriting default arguments in module interfaces via '= super' #24073
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
…n decl in module interfaces
…eters with an inherited default argument to using '= super'
…a module interface
@swift-ci please test |
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.
Thanks for tackling this! And thanks for adding Syntax tests too.
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.
Looks pretty good, only minor comments!
…interfaces Also: - additionally require the containing and overridden initializers are designated, as that's the only case in which we should produce the '= super' syntax in module interfaces - Add notes to point out the locations of the overriden initializer when it's not designated, and the corresponding parameter in that initializer when it doesn't have a default argument to inherit.
@swift-ci please test |
Build failed |
Build failed |
@swift-ci please test Linux |
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.
Do you think we need a SILGen or execution test to make sure the value's getting parsed correctly? That can probably be a follow-up commit, but it seems like a good idea to me.
… an execution test Also pass the decls themselves rather than their locations when diagnosing incorrect usage of '= super'.
@swift-ci please test |
@jrose-apple I've added the execution test, but I haven't actually written one before. Does this look ok? |
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.
Thank you!
Build failed |
// | ||
// RUN: %target-build-swift -I%t -L%t -lInherited -o %t/main %target-rpath(%t) %t/main.swift -swift-version 5 | ||
// RUN: %target-codesign %t/main %t/%target-library-name(Inherited) | ||
// RUN: %target-run %t/main | %FileCheck --check-prefix=OUTPUT %s |
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.
Oops, look like this broke device testing. In order to make sure libInherited.dylib gets copied to the device, you have to pass it as an argument to %t/main
. (That's the hack we came up with, anyway: pretend it's an input.)
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.
Oh, you're way ahead of me. :-)
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.
Yeah, I wasn't sure what I was missing, but @harlanhaskins helped me out!
Since we try not to synthesize inherited initializers, we want to be explicit and print them in subclasses. Since the default argument kind was
Inherited
, though, we were printing them as:which didn't parse. Harlan initially tried fixing this by changing how we print the module interfaces (#23933) but that approach isn't always correct. This PR changes how we consume them by updating the parser to accept the
= super
syntax in module interface files to mean the argument kind isInherited
.I also added diagnostics for
= super
showing up where it shouldn't, but maybe that's overkill since module interfaces are generated?Resolves rdar://49789274