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

Swift 2.2 Regression: Using generic parameter as a generic argument in the same clause crashes the compiler

    XMLWordPrintable

    Details

      Description

      When using the generic argument of a function as a parameter of another generic class that is used in the signature, the compiler crashes with Illegal instruction: 4

      Example

      class GenericClass<T> { }
      
      protocol MyProtocol { }
      
      class MyClass {
        func myFunction<T, O: GenericClass<T> where T: MyProtocol>(myArg: O) -> T {
          fatalError()
        }
      }
      

      Interesting crash facts

      • This used to work with Swift 2.1
      • This works with the version of Swift that is shipped with Xcode 7.3 beta 2 (7D129n)
      • It crashes the Swift 2.2 and Swift 3 compiler since the snapshot of 01/11/2016 (that’s the oldest snapshot I have installed)
      • The code compiles fine with the current master (as of 02/10/2016, commit 073df63) iff myFunction is a global function and not a method in a class

        Attachments

          Activity

            People

            • Assignee:
              slavapestov Slava Pestov
              Reporter:
              ahoppen Alex Hoppen
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: