Files
swift-mirror/test/decl/protocol/protocol_overload_selection.swift
2015-12-09 17:16:56 -08:00

60 lines
1.1 KiB
Swift

// RUN: %target-parse-verify-swift
protocol P1 {
func foo() -> Int
}
protocol P2 : P1 {
func foo() -> Int
}
func f<C : P2> (elements: C) {
var _: Int = elements.foo() // should not error
}
protocol _Collection {
typealias Index
typealias _Element
subscript(i: Index) -> _Element {get}
}
protocol Collection : _Collection, Sequence {
subscript(i: Index) -> Iterator.Element {get}
}
protocol MutableCollection : Collection {
subscript(i: Index) -> Iterator.Element {get set}
}
func insertionSort<
C: MutableCollection
>(
inout elements: C,
i: C.Index
) {
var _: C.Iterator.Element = elements[i] // should not error
}
// rdar://problem/21322215
protocol FactoryType {
typealias Item
}
protocol MyCollectionType : Swift.Collection {}
struct TestClass<
Factory: FactoryType,
NodeCollection: MyCollectionType
where
NodeCollection.Iterator.Element == Factory.Item
> {
var flattenedNodes: NodeCollection
func test() {
let node1 = self.flattenedNodes[self.flattenedNodes.startIndex]
let typecheck1: NodeCollection.Iterator.Element = node1
_ = typecheck1
}
}