-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Deserialization] Don't add an OverrideAttr if the 'overridden' decl is a convenience init when deserializing #24212
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
nathawes
merged 1 commit into
swiftlang:master
from
nathawes:overriding-convenience-init-module-interface
Apr 24, 2019
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// RUN: %empty-directory(%t) | ||
|
||
// Generate the parseable interface of the current file via the merge-modules step | ||
// RUN: %target-build-swift -emit-module -o %t/Test.swiftmodule -emit-parseable-module-interface-path %t/TestMerge.swiftinterface -module-name Test %s | ||
|
||
// Generate the parseable interface of the current file via a single frontend invocation | ||
// RUN: %target-swift-frontend -typecheck -enable-objc-interop -emit-parseable-module-interface-path %t/TestSingle.swiftinterface -module-name Test %s | ||
|
||
// Make sure both don't add override for inits shadowing convenience initializers | ||
// RUN: %FileCheck --check-prefixes=CHECK,SINGLE %s < %t/TestSingle.swiftinterface | ||
// RUN: %FileCheck --check-prefixes=CHECK,MERGE %s < %t/TestMerge.swiftinterface | ||
|
||
// Check we can consume the interface without issue | ||
// RUN: %target-swift-frontend -swift-version 5 -build-module-from-parseable-interface -o %t/Test.swiftmodule %t/TestSingle.swiftinterface | ||
// RUN: %target-swift-frontend -swift-version 5 -build-module-from-parseable-interface -o %t/Test.swiftmodule %t/TestMerge.swiftinterface | ||
|
||
public class Base { | ||
let x: Int | ||
public init(x: Int) { | ||
self.x = x | ||
} | ||
convenience public init() { | ||
self.init(x: 1) | ||
} | ||
} | ||
|
||
public class Derived: Base { | ||
// MERGE: {{^}} public init(z: Swift.Int) | ||
// SINGLE: {{^}} public init(z: Int) | ||
nathawes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
public init(z: Int) { | ||
super.init(x: z) | ||
} | ||
// MERGE: {{^}} public convenience init() | ||
// SINGLE: {{^}} convenience public init() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This switched order here is because we have a 'ConvenienceAttr` on the initializer when generating via the single invocation (which is printed when printing the decl's attributes) and don't after serializing/deserializing (where we print it based on the initializer kind). |
||
convenience public init() { | ||
self.init(z: 1) | ||
} | ||
} | ||
|
||
public class Derived2: Base { | ||
// CHECK: {{^}} public init() | ||
public init() { | ||
super.init(x: 1) | ||
} | ||
|
||
// MERGE: {{^}} override public convenience init(x: Swift.Int) | ||
// SINGLE: {{^}} override convenience public init(x: Int) | ||
override convenience public init(x: Int) { | ||
self.init() | ||
} | ||
} |
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.
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 leave a comment behind saying that this doesn't really make sense? Either the convenience init is an override or it isn't. cc @DougGregor
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 sure, will update shortly.