[SR-8668] Give a sensible warning for protocol namespace issues #51182
Labels
compiler
The Swift compiler in itself
diagnostics QoI
Bug: Diagnostics Quality of Implementation
improvement
Additional Detail from JIRA
md5: 6d6e793fe9774b3d294ff06aadea402e
relates to:
Issue Description:
Have a module Foo with a public protocol FooProtocol, and a class FooClass:
class FooClass {
}
public protocol FooProtocol: class {
{{ func protocolFunc(_ foo: FooClass)}}
{{}}}
Implement a class in MyModule, where the module also implements its own FooClass:
class FooClass {
}
class MyClass: FooProtocol {
{{ func protocolFunc(_ foo: FooClass) {}}
{{ }}}
{{}}}
Xcode complains that you haven't implemented the protocol function, even though you have. It helpfully points out that the signature of the function you implemented is identical to the one that it wants. It even offers to add the 'missing' function, and if you do it complains that you now have duplicate functions.
The solution is to explicitly namespace FooClass - Foo.FooClass. However, a compiler warning hinting that this was the problem would eliminate many head/desk incidents trying to figure out why a protocol was missing, when it was the exact same protocol Xcode added as a 'fix'.
The text was updated successfully, but these errors were encountered: