mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
49 lines
1.4 KiB
Swift
49 lines
1.4 KiB
Swift
// RUN: %target-swift-frontend -emit-ir -g -o - %s
|
|
|
|
// REQUIRES: objc_interop
|
|
|
|
// https://github.com/apple/swift/issues/51435
|
|
|
|
import Foundation
|
|
public final class Foo: NSObject, Collection {
|
|
public var storage = [String: Any]()
|
|
|
|
public typealias DictionaryType = [String: Any]
|
|
public typealias IndexDistance = Int
|
|
public typealias Indices = DictionaryType.Indices
|
|
public typealias Iterator = DictionaryType.Iterator
|
|
public typealias SubSequence = DictionaryType.SubSequence
|
|
public typealias Index = DictionaryType.Index
|
|
|
|
public var startIndex: Index { return storage.startIndex }
|
|
public var endIndex: DictionaryType.Index { return storage.endIndex }
|
|
public subscript(position: Index) -> Iterator.Element {
|
|
return storage[position]
|
|
}
|
|
|
|
public subscript(bounds: Range<Index>) -> SubSequence {
|
|
return storage[bounds]
|
|
}
|
|
|
|
public var indices: Indices { return storage.indices }
|
|
|
|
public subscript(key: String) -> Any? {
|
|
get { return storage[key] }
|
|
set { storage[key] = newValue }
|
|
}
|
|
|
|
public func index(after i: Index) -> Index { return storage.index(after: i) }
|
|
|
|
public func makeIterator() -> DictionaryIterator<String, Any> {
|
|
return storage.makeIterator()
|
|
}
|
|
|
|
public override func value(forKey key: String) -> Any? {
|
|
return storage[key]
|
|
}
|
|
|
|
public override func value(forUndefinedKey key: String) -> Any? {
|
|
return storage[key]
|
|
}
|
|
}
|