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

Typealias.Type Crashes when more than 2 protocols are used

    XMLWordPrintable

    Details

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

      Description

      Creating a typealias that is composed of more than two protocols causes a crash when attempting to use an object, that conforms to all types, to a property of that type. Probably easier to understand with an example, so....

      protocol One { var string1: String { get } }
      extension One { var string1: String { return "string1" } }
      
      protocol Two { var string2: String { get } }
      extension Two { var string2: String { return "string2" } }
      
      protocol Three { var string3: String { get } }
      extension Three { var string3: String { return "string3" } }
      
      typealias OneAndTwo = One & Two
      typealias AllThree = One & Two & Three
      
      class Stringy: One & Two {}
      class Stringier: One & Two & Three {}
      
      var firstTwo: OneAndTwo.Type = Stringy.self // Works fine
      var allThree: AllThree.Type = Stringier.self // Crashes
      

      Worth noting: if I use `Stringier` in place of `Stringy` on the "Works fine" line, it doesn't crash.

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            wmike Mike Ole
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: