https://kotlinlang.org logo
Title
d

darkmoon_uk

12/18/2018, 10:35 AM
Trying to implement a
UITableViewDataSource
Protocol in pure Kotlin... The bridging seems to think I'm overriding a totally different method signature in the protocol, and so is throwing a compile error (on the return type). Is this expected? A bug? Workarounds exist with annotations?
s

svyatoslav.scherbina

12/18/2018, 10:46 AM
The bridging seems to think I’m overriding a totally different method signature in the protocol, and so is throwing a compile error (on the return type)
Could you clarify? Btw, to override Objective-C method, you have to use the same parameter names.
d

darkmoon_uk

12/18/2018, 10:48 AM
I used IntelliJ's own code generation to override. I'll provide exact failing code:
class Source : NSObject(), UITableViewDataSourceProtocol {

    override fun tableView(tableView: UITableView, cellForRowAtIndexPath: NSIndexPath): UITableViewCell {...}

    override fun tableView(tableView: UITableView, numberOfRowsInSection: NSInteger): NSInteger {...}
}
I tried applying explicit
@ObjCMethod
to reaffirm ObjC signature, but no change.
s

svyatoslav.scherbina

12/18/2018, 11:00 AM
This issue is likely to be related to Kotlin/Native support in IntelliJ IDEA. The compiler should handle this code properly. Could you check this?
d

darkmoon_uk

12/18/2018, 11:10 AM
Yes, it does compile correctly despite the IDE errors - apologies for not checking that earlier.
s

svyatoslav.scherbina

12/18/2018, 11:12 AM
It’s ok 🙂 Could you please report the IDE issue to https://github.com/JetBrains/kotlin-native/issues ?
d

darkmoon_uk

12/18/2018, 11:27 AM