Skip to content

Commit 8621edf

Browse files
committed
Consolidated Cast operators for Array and Dictionary
1 parent d97240e commit 8621edf

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

Source/Array.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,9 @@ public struct Array<T>
215215
return array.platformList
216216
}
217217
#endif
218-
#endif
219218

220219
// Cocoa only: cast from/to different generic Cocoa type
221220

222-
#if TOFFEE || DARWIN
223221
public static func __explicit<U>(_ array: NSArray<U>) -> [T] {
224222
return (array as! NSArray<T>) as! [T]
225223
}

Source/Dictionary.swift

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,26 +117,24 @@ public struct Dictionary<Key, Value> /*: INSFastEnumeration<T>*/
117117
#if DARWIN
118118
#if ISLAND
119119
public static func __implicit(_ dictionary: NSDictionary<Key,Value>) -> [Key:Value] {
120-
return Dictionary<Key,Value>(dictionary)
120+
return PlatformDictionary<Key,Value>(dictionary)
121121
}
122122

123123
public static func __implicit(_ dictionary: [Key:Value]) -> NSDictionary<Key,Value> {
124124
return dictionary.dictionary.ToNSDictionary()
125125
}
126126

127-
public static func __implicit(_ list: [Key:Value]) -> NSMutableDictionary<Key,Value> {
128-
return Dictionary.dictionary.ToNSDictionary()
127+
public static func __implicit(_ dictionary: [Key:Value]) -> NSMutableDictionary<Key,Value> {
128+
return dictionary.dictionary.ToNSMutableDictionary()
129129
}
130130
#else
131-
public static func __implicit(_ list: [Key:Value]) -> PlatformImmutableDictionary<Key,Value> {
132-
return Dictionary.platformFictionary
131+
public static func __implicit(_ dictionary: [Key:Value]) -> PlatformImmutableDictionary<Key,Value> {
132+
return dictionary.platformDictionary
133133
}
134134
#endif
135-
#endif
136135

137136
// Cocoa only: cast from/to different generic Cocoa type
138137

139-
#if TOFFEE || DARWIN
140138
public static func __explicit<Key2,Value2>(_ dictionary: NSDictionary<Key2,Value2>) -> [Key:Value] {
141139
return (dictionary as! NSDictionary<Key,Value>) as! [Key:Value]
142140
}

0 commit comments

Comments
 (0)