Skip to content

[SR-14232] Documentation comments from witnessed protocol requirement favoured over own documentation #56599

@karwa

Description

@karwa
Previous ID SR-14232
Radar None
Original Reporter @karwa
Type Bug

Attachment: Download

Environment

Xcode Version 12.4 (12D4e)

Apple Swift version 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28).

Additional Detail from JIRA
Votes 0
Component/s CodeCompletion
Labels Bug
Assignee None
Priority Medium

md5: 44c973aa5bca6206d65f65cd774f99aa

Issue Description:

When an initializer witnesses a protocol requirement, documentation from the protocol will be favoured over the witness' own documentation. This is unfortunate - for example, I'm making a type which conforms to LosslessStringConvertible, and I'd like to document on the initializer which formats the type is able to parse, but this gets lost and it just shows generic LSC documentation about instantiating a type from a string.

struct Foo: LosslessStringConvertible {
  
  /// My documentation comment.
  ///
  /// Hello, world!
  ///
  init?<S>(_ description: S) where S: StringProtocol {}
  var description: String { "" }
}


func testDocComment() {
  Foo(                     // <- Autocomplete here, after the '('
}

See the documentation summary in the autocomplete window of the attached screenshot.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.code completionArea → source tooling: code completionsource toolingArea: IDE support, SourceKit, and other source tooling

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions