-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Turn on 'as' bridging for Linux (2) #16736
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1139,22 +1139,19 @@ bool swift::canUseScalarCheckedCastInstructions(SILModule &M, | |
if (!objectType.isAnyClassReferenceType()) | ||
return false; | ||
|
||
if (M.getASTContext().LangOpts.EnableObjCInterop) { | ||
auto super = archetype->getSuperclass(); | ||
if (super.isNull()) | ||
return false; | ||
|
||
// A base class constraint that isn't NSError rules out the archetype being | ||
// bound to NSError. | ||
if (auto nserror = M.Types.getNSErrorType()) | ||
return !super->isEqual(nserror); | ||
// If NSError wasn't loaded, any base class constraint must not be NSError. | ||
return true; | ||
} else { | ||
// If ObjC bridging isn't enabled, we can do a scalar cast from any | ||
// reference type to any class-constrained archetype. | ||
return archetype->requiresClass(); | ||
// A base class constraint that isn't NSError rules out the archetype being | ||
// bound to NSError. | ||
if (M.getASTContext().LangOpts.EnableObjCInterop) { | ||
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. every other change here seems to be about removing such calls, why does this remain? 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. I've been introducing the minimum change that supports the subset we need in s-c-f by elimination. A follow-up will be to add tests, and revisit paths here if we find corner cases that I missed. |
||
if (auto nserror = M.Types.getNSErrorType()) | ||
return !super->isEqual(nserror); | ||
} | ||
|
||
// If NSError wasn't loaded, any base class constraint must not be NSError. | ||
return true; | ||
} | ||
|
||
if (M.getASTContext().LangOpts.EnableObjCInterop | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1180,7 +1180,7 @@ public enum EncodingError : Error { | |
public var _userInfo: AnyObject? { | ||
// The error dictionary must be returned as an AnyObject. We can do this | ||
// only on platforms with bridging, unfortunately. | ||
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) | ||
#if _runtime(_ObjC) | ||
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. We could actually remove this 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. Oh, yeah :) |
||
let context: Context | ||
switch self { | ||
case .invalidValue(_, let c): context = c | ||
|
@@ -1290,7 +1290,7 @@ public enum DecodingError : Error { | |
public var _userInfo: AnyObject? { | ||
// The error dictionary must be returned as an AnyObject. We can do this | ||
// only on platforms with bridging, unfortunately. | ||
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) | ||
#if _runtime(_ObjC) | ||
let context: Context | ||
switch self { | ||
case .keyNotFound(_, let c): context = c | ||
|
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.
The indentation here should be fixed to match the surrounding code.
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.
Ok!