groue / GRDBCombine

GRDB ❤️ Combine
MIT License
223 stars 16 forks source link

Compiler error with Swift 5.2 snapshot #30

Closed pocketpixels closed 4 years ago

pocketpixels commented 4 years ago

This is more of a heads-up: In the current Swift 5.2 toolchain snapshots GRDBCombine does not build because DispatchQueue appears to no longer conform to the Scheduler protocol. Not sure if that is a bug in the current implementation or a change coming in Swift 5.2.

The error is: Instance method 'readPublisher(receiveOn:value:)' requires that 'DispatchQueue' conform to 'Scheduler'

The Swift 5.2 toolchain has much improved error reporting for SwiftUI code, which is why I wanted to try using it. But this issue currently prevents that.

groue commented 4 years ago

Hello @pocketpixels. Thanks for heads-up.

I would be surprised if DispatchQueue would lose Scheduler conformance, as this would be a major breaking change. I suggest reporting a bug on http://feedbackassistant.apple.com and https://bugs.swift.org.

Meanwhile, you may want to add the missing conformance in your copy of GRDBCombine.

pocketpixels commented 4 years ago

Thanks for the quick reply. I filed a bug report in the Feedback Assistant against the Dispatch framework. Though maybe the Swift bug tracker would be the better place? Not sure.

Just adding

extension DispatchQueue: Scheduler { }

does not work. The compiler reports: Type 'DispatchQueue' does not conform to protocol 'Scheduler'

groue commented 4 years ago

I filed a bug report in the Feedback Assistant against the Dispatch framework. Though maybe the Swift bug tracker would be the better place? Not sure.

I don't know who is responsible for the Dispatch and Combine SDKs which ships with the toolchain snapshots. Just in doubt I would report in the Swift bug tracker as well.

Just adding

extension DispatchQueue: Scheduler { }

does not work. The compiler reports: Type 'DispatchQueue' does not conform to protocol 'Scheduler'

Sure. The conformance has to be written down (there are three required methods). GRDB does not use the SchedulerOptions associated type, if I remember well, so you can just use Void or Never for this associated type. As for the SchedulerTimeType associated type, I think the regular (non-toolchain) Dispatch library uses DispatchTimeInterval.

pocketpixels commented 4 years ago

Thanks. I just filed a bug in the Swift bug tracker also: https://bugs.swift.org/browse/SR-12077

pocketpixels commented 4 years ago

I haven't heard much from the filed bugs, but now we have a first beta of Xcode 11.4 which includes a beta Swift 5.2 compiler, and this issue no longer shows up with that. So I am closing this issue.