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

Compiler wrongfully complains of illegal syntax when declaring multiple conformances for a protocol's associated type.

    XMLWordPrintable

    Details

      Description

      The following code is legal:

      Unable to find source-code formatter for language: swift . Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      protocol A
      {
          
      }
      
      protocol B
      {
          
      }
      
      typealias C_AssociatedTypeA_Inheritance = protocol<A, B>
      
      protocol C
      {
          associatedtype AssociatedTypeA: C_AssociatedTypeA_Inheritance
      }
      
      

      While this is not:

      protocol A
      {
          
      }
      
      protocol B
      {
          
      }
      
      protocol C
      {
          associatedtype AssociatedTypeA: protocol<A, B>
      }
      
      

      EDIT: I had assumed that this was just a bug, but according to the comments this is intended to be illegal. However, I feel that we should allow this syntax. I've corrected the 'Issue Type' to 'Improvement'.

        Attachments

          Activity

            People

            Assignee:
            slavapestov Slava Pestov
            Reporter:
            Vatsal Manot Vatsal Manot
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: