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
Fixed crash on binding to NSTableView #442
Conversation
Codecov Report
@@ Coverage Diff @@
## master #442 +/- ##
=======================================
Coverage 60.46% 60.46%
=======================================
Files 52 52
Lines 4619 4619
=======================================
Hits 2793 2793
Misses 1826 1826 Continue to review full report at Codecov.
|
@@ -196,7 +196,7 @@ public extension SignalProtocol where | |||
property: dataSource, | |||
to: #selector(NSTableViewDataSource.tableView(_:objectValueFor:row:)), | |||
map: { (dataSource: DataSource?, _: NSTableView, _: NSTableColumn, row: Int) -> Any? in | |||
return dataSource?[row] | |||
return dataSource?[row] as AnyObject |
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.
@tonyarnold would you know how this affects things?
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.
To be honest, I'm not sure what the intent here is. The closure still returns Any
, and it's not a conditional downcast… I don't think it's necessary?
@nayzak do you recall why you needed this?
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.
Hi @srdanrasic, @tonyarnold! Did you look at my demo (https://github.com/nayzak/BondBugDemo) that reproduces the bug? I've just updated it to Swift 4 and latest Bond release an it still crashes without casting to AnyObject
.
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.
Just had a look now - wow, that's… special.
I'm honestly not sure where this issue is coming from - I'm not saying we shouldn't fix it, but I'd like to know what knock-on effects we're going to see from casting absolutely everything to AnyObject
(which is essentially saying "this is a reference type now", right?)
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 was surprising for me too :) But obvious thing is that something goes wrong on a "glue level between Swift and ObjC". I've just made an assumption that objc definitely needs object, however Apple made Any
same thing as id
. Anyway I'm not that guy who knows what's actually going on in this case.
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.
@tonyarnold Can you post a link to your PR?
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.
@DivineDominion I'm not sure it was me who ended up fixing this. I think @srdanrasic ended up rewriting some of the protocol proxy to address similar issues to this one. What specifically did you want to see?
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'm hunting down a similar crash in another situation (and without Bond), so I am curious what you did to fix this.
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.
@DivineDominion This issue was very specific to Bond and how it implements protocol proxies by intercepting NSInvocations. The issue was related to Swift -> ObjC type bridging. Here is a first commit from the fix: 64f8e95
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 a ton!
Thanks @nayzak for bringing this up! |
@srdanrasic, @tonyarnold, thank you guys for spending your time for this helpful project 👍 |
Demo project to reproduce the bug https://github.com/nayzak/BondBugDemo.