Add Associated Type Constraints & Class and Protocol Existential example
Update token count to match these additions already managed by the grammar
This commit is contained in:
@ -30,7 +30,7 @@ public class SwiftTokenizerTest extends AbstractTokenizerTest {
|
||||
|
||||
@Test
|
||||
public void tokenizeTest() throws IOException {
|
||||
this.expectedTokenCount = 4155;
|
||||
this.expectedTokenCount = 4217;
|
||||
super.tokenizeTest();
|
||||
}
|
||||
}
|
||||
|
@ -982,3 +982,24 @@ func useSomeGenericFromExtension() {
|
||||
// Set subscript value
|
||||
let nameAndMoons2 = earthData[Set(["moons", "name"])] // [1, "Earth"]
|
||||
}
|
||||
|
||||
// Associated Type Constraints
|
||||
|
||||
protocol MyProtocol {
|
||||
associatedtype Element
|
||||
associatedtype SubSequence : Sequence where SubSequence.Iterator.Element == Iterator.Element
|
||||
}
|
||||
|
||||
// Class and Protocol Existential
|
||||
|
||||
protocol MyProtocol { }
|
||||
class View { }
|
||||
class ViewSubclass: View, MyProtocol { }
|
||||
|
||||
class MyClass {
|
||||
var delegate: (View & MyProtocol)?
|
||||
}
|
||||
|
||||
let myClass = MyClass()
|
||||
//myClass.delegate = View() // error: cannot assign value of type 'View' to type '(View & MyProtocol)?'
|
||||
myClass.delegate = ViewSubclass()
|
||||
|
Reference in New Issue
Block a user