You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This seems like correct behavior to me: in both cases the compiler has to choose which test is more specific. In the first case, the only thing it has to go on is whether it's going to need to use variadics, and the preference there is to not use variadics. In the second, though, there's also the difference in where the method is implemented: a class is more specific than a protocol it conforms to. That's considered a more important difference.
If calling an unlabeled variadic func with zero arguments is allowed, then calling a labeled variadic func with zero arguments should also be allowed?
classTest {
functest(values: Int...) {
print(values)
}
}
lett = Test()
t.test(values:) // ??? func with label and without label should be different func?
Also
classTest {
functest(_values: Int...) {
print(values)
}
functest(values: Int...) {
print(values)
}
}
lett = Test()
t.test(1, 2, 3) // validt.test(values: 1, 2, 3) // validt.test() // call which one? Ambiguous use of 'test'.
Environment
Xcode 10.2.1
Additional Detail from JIRA
md5: 71e965ac97186a32717d5be022d32ced
Issue Description:
https://forums.swift.org/t/unexpected-behavior-of-variadic-parameters/23892
However if func test() is implemented in extension of Protocol, it behaves different.
The text was updated successfully, but these errors were encountered: