[SR-4625] Compiler reports an error for protocol conformance for method with default parameter value

Hi! I stumbled on this old (2017) task while I was searching around. Any ideas if there are some modern solutions for something like this?

Suppose I define a type with a function that takes a default parameter:

struct S {
  func f(_ : Int = 0) { }
}

There's nothing stopping me from calling that function like this:

S().f()

Suppose I define a protocol:

protocol P {
  func f()
}

Ok… can my type conform to this protocol?

extension S: P { } // Type 'S' does not conform to protocol 'P'

I'm guess this might have just been The Way It Is and The Way It's Going To Be… unless there has been some modern solution that landed to work around this? Any ideas about that? Thanks!

2 Likes