-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
SE-0072: Fully eliminate implicit bridging conversions from Swift #2419
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 |
---|---|---|
|
@@ -29,9 +29,9 @@ extension SCNVector3 { | |
self.z = SCNFloat(z) | ||
} | ||
public init(_ x: CGFloat, _ y: CGFloat, _ z: CGFloat) { | ||
self.x = SCNFloat(x) | ||
self.y = SCNFloat(y) | ||
self.z = SCNFloat(z) | ||
self.x = SCNFloat(x as NSNumber) | ||
self.y = SCNFloat(y as NSNumber) | ||
self.z = SCNFloat(z as NSNumber) | ||
} | ||
public init(_ x: Double, _ y: Double, _ z: Double) { | ||
self.init(SCNFloat(x), SCNFloat(y), SCNFloat(z)) | ||
|
@@ -69,10 +69,10 @@ extension SCNVector4 { | |
self.w = SCNFloat(w) | ||
} | ||
public init(_ x: CGFloat, _ y: CGFloat, _ z: CGFloat, _ w: CGFloat) { | ||
self.x = SCNFloat(x) | ||
self.y = SCNFloat(y) | ||
self.z = SCNFloat(z) | ||
self.w = SCNFloat(w) | ||
self.x = SCNFloat(x as NSNumber) | ||
self.y = SCNFloat(y as NSNumber) | ||
self.z = SCNFloat(z as NSNumber) | ||
self.w = SCNFloat(w as NSNumber) | ||
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. Same here. |
||
} | ||
public init(_ x: Double, _ y: Double, _ z: Double, _ w: Double) { | ||
self.init(SCNFloat(x), SCNFloat(y), SCNFloat(z), SCNFloat(w)) | ||
|
@@ -182,7 +182,7 @@ extension SCNSceneSource { | |
@warn_unused_result | ||
public func entryWithIdentifier<T>(_ uid: String, withClass entryClass: T.Type) -> T? { | ||
return SCN_Swift_SCNSceneSource_entryWithIdentifier( | ||
self, uid, entryClass as! AnyObject) as! T? | ||
self, uid as NSString, entryClass as! AnyObject) as! T? | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ if #available(iOS 8.0, OSX 10.10, *) { | |
expectEqual(scn_float_from_d, 2.0) | ||
|
||
let cg = CGFloat(3.0) | ||
let scn_float_from_cg = SCNFloat(cg) | ||
let scn_float_from_cg = SCNFloat(cg as NSNumber) | ||
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 don't think it was intended to be a bridging conversion. |
||
expectEqual(scn_float_from_cg, 3.0) | ||
|
||
let node = SCNNode() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,15 +23,15 @@ func test(_ URL: NSURL, controller: NSDocumentController) { | |
|
||
extension NSBox { | ||
func foo() { | ||
print("abc") // expected-warning {{use of 'print' treated as a reference to instance method in class 'NSView'}} | ||
print("abc" as NSString) // expected-warning {{use of 'print' treated as a reference to instance method in class 'NSView'}} | ||
// expected-note@-1 {{use 'self.' to silence this warning}} {{5-5=self.}} | ||
// expected-note@-2 {{use 'Swift.' to reference the global function}} {{5-5=Swift.}} | ||
} | ||
} | ||
|
||
class MyView : NSView { | ||
func foo() { | ||
print("abc") // expected-warning {{use of 'print' treated as a reference to instance method in class 'NSView'}} | ||
print("abc" as NSString) // expected-warning {{use of 'print' treated as a reference to instance method in class 'NSView'}} | ||
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. What happens for a regular 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'll still infer type String for "abc", and then raise an invalid conversion error. (We do this because String is the favored type for all string literals.) I'll see if I can do something about this case. 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. Given the intent of the test, maybe we should change it to 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 think that would work - yeah. |
||
// expected-note@-1 {{use 'self.' to silence this warning}} {{5-5=self.}} | ||
// expected-note@-2 {{use 'Swift.' to reference the global function}} {{5-5=Swift.}} | ||
} | ||
|
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, I don't think that was intended.
Given this definition, this was intended as a plain conversion, not a bridge.
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.
Agreed - debugging in, though, we've definitely been introducing this conversion implicitly. I've filed SR-1432 to track my investigation of what's been going on.