swift-doc icon indicating copy to clipboard operation
swift-doc copied to clipboard

Different symbols have the same name and therefore the same anchor

Open Lukas-Stuehrk opened this issue 4 years ago • 1 comments

It's possible to have functions, methods, operators etc. with the same names, but different types. One example would be the following class declaration:

public class SomeClass {

    public func someMethod(arg: String) {

    }

    public func someMethod(arg: Int) {

    }
}

This creates symbols with exactly the same name in the documentation: Screenshot 2021-03-22 at 22 08 32

And for both methods we then create the same anchor #someclass.somemethod(arg:), therefore creating invalid HTML and making it impossible to directly link to the second method.

Lukas-Stuehrk avatar Mar 22 '21 21:03 Lukas-Stuehrk

The same happens when functions differ only in generics:

public class SomeClass {
    public func onMessage(action: () -> Void) {}

    public func onMessage<T>(action: (T) -> Void) {}
}

Tunous avatar Mar 23 '21 06:03 Tunous