Thomvis / BrightFutures

Write great asynchronous code in Swift using futures and promises
MIT License
1.9k stars 184 forks source link

Promise with success type of Self #141

Closed tomwhatmore closed 8 years ago

tomwhatmore commented 8 years ago

Quite new to Swift so this may well be an issue with my knowledge rather than Bright Futures itself but should it be possible to create a Promise that has a success type of Self in a protocol extension?

extension Promiser {
    func promise() -> Future<Self, Error> {
    let promise = Promise<Self, Error>()

    return promise.future
  }
}

Gives me the exceptionally helpful xcode error Consecutive statements on a line must be separated by ';'

Thomvis commented 8 years ago

As you suggest, this is something that is not possible in Swift and is not a problem related to BrightFutures. I'd look into adding an associatedtype to Promiser and use that instead of Self.