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:
kenji21
2017-12-08 06:13:11 +01:00
parent b10e21df7f
commit 56cead8423
2 changed files with 22 additions and 1 deletions

View File

@ -30,7 +30,7 @@ public class SwiftTokenizerTest extends AbstractTokenizerTest {
@Test
public void tokenizeTest() throws IOException {
this.expectedTokenCount = 4155;
this.expectedTokenCount = 4217;
super.tokenizeTest();
}
}

View File

@ -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()