|
| 1 | +// RUN: %target-typecheck-verify-swift -enable-experimental-associated-type-inference |
| 2 | +// RUN: %target-typecheck-verify-swift -disable-experimental-associated-type-inference |
| 3 | + |
| 4 | +// REQUIRES: objc_interop |
| 5 | + |
| 6 | +import Foundation |
| 7 | + |
| 8 | +public struct CustomCollection<Element>: RandomAccessCollection, MutableCollection, ExpressibleByArrayLiteral { |
| 9 | + public typealias Indices = Range<Int> |
| 10 | + public typealias Index = Int |
| 11 | + |
| 12 | + public init() {} |
| 13 | + |
| 14 | + public init(arrayLiteral elements: Element ...) { |
| 15 | + fatalError() |
| 16 | + } |
| 17 | +} |
| 18 | + |
| 19 | +extension CustomCollection { |
| 20 | + public var startIndex: Int { fatalError() } |
| 21 | + public var endIndex: Int { fatalError() } |
| 22 | + |
| 23 | + public subscript(position: Int) -> Element { |
| 24 | + get { fatalError() } |
| 25 | + set { fatalError() } |
| 26 | + } |
| 27 | +} |
| 28 | + |
| 29 | +extension CustomCollection: RangeReplaceableCollection { |
| 30 | + public mutating func append(_ newElement: Element) { } |
| 31 | + public mutating func append<S: Sequence>(contentsOf newElements: S) where S.Element == Element { } |
| 32 | + public mutating func reserveCapacity(_ minimumCapacity: Int) { } |
| 33 | + public mutating func removeAll(keepingCapacity keepCapacity: Bool = false) { } |
| 34 | + public mutating func replaceSubrange<C: Collection>(_ subRange: Range<Int>, with newElements: C) where C.Element == Element { } |
| 35 | +} |
| 36 | + |
| 37 | +extension CustomCollection { |
| 38 | + public func withUnsafeBytes<R>(_ body: (UnsafeRawBufferPointer) throws -> R) rethrows -> R { fatalError() } |
| 39 | +} |
| 40 | + |
| 41 | +extension CustomCollection: ContiguousBytes where Element == UInt8 { } |
| 42 | + |
| 43 | +extension CustomCollection: DataProtocol where Element == UInt8 { |
| 44 | + public var regions: CollectionOfOne<CustomCollection<UInt8>> { fatalError() } |
| 45 | +} |
0 commit comments