Swift: syntax ambiguity in generic constraints

Originator:d
Number:rdar://23919603 Date Originated:16-Dec-2015 03:27 PM
Status:Open Resolved:
Product:Developer Tools Product Version:Swift 2.1.1
Classification:Serious Bug Reproducible:Always
 
Summary:
There’s an ambiguity case in Swift’s generic constraint syntax that happens when specifying more than one generic types, the first one needing to be constrained using `where`.

Long story short, the compiler interprets the second generic type as part of the `where` statement.

Steps to Reproduce:
```
protocol Protocol1 { }
protocol Protocol2 { }

class Class { }

class GenericClass<A: Class where A: Protocol1, B: Protocol2> {

}
```

Expected Results:
Swift interprets GenericClass<A, B>.

Actual Results:
Swift interprets GenericClass<A>, and throws an error because B is implicitly part of the `where` statement (which it shouldn’t).

Error: “Use of undeclared type B”

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!