Code completion on a generic method

Not sure if this is just an XCode bug or I'm missing something about a language.

Code completion with a generic context doesn't work when used with a generic class method, but does work when used when the type is generic, or the function is global like in Playgrounds.

Here's an example:

protocol Fetchable: Codable {}

struct Foo: Fetchable {        
    let a: Int

    static let foo1 = Foo(a: 1)

If I do this, everything works as I'd expect:

class Client<T: Fetchable> {
   func compare(_ a: T, _ b: T) -> AnyPublisher<Bool, Never> {

let fooClient = Client<Foo>()

// code complete suggests foo1, init(a:) and init(from:) 1), . // <- code completing...

But if it's the method, not the type, that's generic:

class Client {
   func compare<T: Fetchable?(_ a: T, _ b: T) -> AnyPublisher<Bool, Never> {

let client = Client()

// code complete suggests only init(from:) 1), . // <- code completing...

code complete only suggests completions based on the protocol, not the conforming type.

Though it eventually still compiles if fully typed, so it suggests to me that it's an xcode bug, not a language issue. 1), .foo1)
Terms of Service

Privacy Policy

Cookie Policy