Uploaded image for project: 'Swift'
  1. Swift
  2. SR-9403

The 'Every protocol has an implicitly-created associated type ‘Self’' comment is misleading

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Medium
    • Resolution: Done
    • Component/s: Compiler
    • Labels:

      Description

      Looking at: https://github.com/apple/swift/blob/ebd701c4b72e29ea3e42c6a906bc46e136ebaaad/include/swift/AST/Decl.h#L2589

      The comment says: 
       

      /// Every protocol has an implicitly-created associated type ‘Self’ that
      /// describes a type that conforms to the protocol
      
      

       

      created has the connotation that it always has the type attached

      Yet the following code compiles without issues: 

       

       

      protocol Something {
      }
      var NoSelfOrAssociatedtypeRequirementArray : [Something] = []
      

        

      From what I understand the compiler assigns `Self` as an associatedtype only if Self is used. 

      Hence I think the comment should be adjusted. e.g.

       

      /// Every protocol that uses Self in its requirements will have an implicitly-created associated type ‘Self’ that
      /// describes a type that conforms to the protocol
      

       

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            swiftHoney mohammad faani
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: