-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Type checker] Finalize referenced members of class extensions. #18199
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
DougGregor
merged 5 commits into
swiftlang:master
from
DougGregor:finalize-class-extension-members
Jul 26, 2018
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c2bc23e
[Type checker] Finalize referenced members of class extensions.
DougGregor 0a5eb5a
[Type checker] Add lazy var implementation as part of decl finalization.
DougGregor 9b88853
[Serialization] Serialize Objective-C method names for accessors.
DougGregor cde94f6
[AST] Eliminate the HasValidatedLayout bit.
DougGregor 6a8d321
[Type checker] Move ad-hoc isObjC/isDynamic checking to finalization.
DougGregor 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
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
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
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
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
struct External { | ||
var member: Something | ||
var member: Something // expected-error{{use of undeclared type 'Something'}} | ||
} | ||
|
||
struct OtherExternal {} |
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,27 @@ | ||
import Foundation | ||
|
||
public class Bar : Foo { | ||
@objc(method2WithValue:) public override func method2(_ value: Int) { } | ||
|
||
@objc(overloadedWithInt:) public func overloaded(_ x: Int) { } | ||
@objc(overloadedWithString:) public func overloaded(_ x: String) { } | ||
|
||
@objc(staticOverloadedWithInt:) public static func staticOverloaded(_ x: Int) { } | ||
@objc(staticOverloadedWithString:) public static func staticOverloaded(_ x: String) { } | ||
|
||
@objc(staticOrNonStatic:) public func staticOrNonStatic(_ x: Int) { } | ||
@objc(staticOrNonStatic:) public static func staticOrNonStatic(_ x: Int) { } | ||
|
||
@objc(theInstanceOne:) public func staticOrNonStatic2(_ x: Int) { } | ||
@objc(theStaticOne:) public static func staticOrNonStatic2(_ x: Int) { } | ||
} | ||
|
||
public class Foo { | ||
@objc(methodWithValue:label:) public func method(_ value: Int, label: String) { } | ||
|
||
@objc(method2WithValue:) public func method2(_ value: Int) { } | ||
|
||
@objc public func method3() { } | ||
|
||
@objc public var property: String = "" | ||
} |
Oops, something went wrong.
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.
This would be a regression. Maybe we should skip finalizing declarations if any errors have been emitted?
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.
We had that, and I removed it, because it suppresses a ton of unrelated errors.
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 mean, this way we're doing unnecessary work in other files.
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.
We're finalizing those declarations because something needed them from the other file. In this case, they're methods of a class so we are computing the layout. Prior to my change we would skip a little work once we had produced an error, but "stop doing any work if there's any error anywhere" doesn't seem like the right default policy.
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.
It might be more than a little work, though—it's all structs and enums you've used throughout the file, transitively. It seems like the same reasoning to me as "don't go on to SILGen if there are errors, even though you could still get some dataflow diagnostics".
Uh oh!
There was an error while loading. Please reload this page.
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 have an idea. Once we've encountered an error, we'll stop finalizing declarations from other source files. That way, you'll still get diagnostics in your own source file, but we won't do unnecessary work elsewhere. PR is up at #18259.
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.
That makes a lot of sense! I forgot that finalization is now the only way to get certain diagnostics from decls within the current file.