File tree Expand file tree Collapse file tree 3 files changed +28
-1
lines changed Expand file tree Collapse file tree 3 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ let package = Package(
82
82
) ,
83
83
. package (
84
84
url: " https://github.com/apple/swift-foundation " ,
85
- revision: " db63ab39bb4f07eeb3ccf19fa7a9f928a7ca3972 "
85
+ revision: " 3297fb33b49ba2d1161ba12757891c7b91c73a3e "
86
86
) ,
87
87
] ,
88
88
targets: [
Original file line number Diff line number Diff line change 9
9
10
10
11
11
@_implementationOnly import _CoreFoundation
12
+ @_spi ( SwiftCorelibsFoundation) @_exported import FoundationEssentials
12
13
13
14
internal let kCFNumberSInt8Type = CFNumberType . sInt8Type
14
15
internal let kCFNumberSInt16Type = CFNumberType . sInt16Type
@@ -1172,3 +1173,18 @@ protocol _NSNumberCastingWithoutBridging {
1172
1173
}
1173
1174
1174
1175
extension NSNumber : _NSNumberCastingWithoutBridging { }
1176
+
1177
+ // Called by FoundationEssentials
1178
+ internal final class _FoundationNSNumberInitializer : _NSNumberInitializer {
1179
+ public static func initialize( value: some BinaryInteger ) -> Any {
1180
+ if let int64 = Int64 ( exactly: value) {
1181
+ return NSNumber ( value: int64)
1182
+ } else {
1183
+ return NSNumber ( value: UInt64 ( value) )
1184
+ }
1185
+ }
1186
+
1187
+ public static func initialize( value: Bool ) -> Any {
1188
+ NSNumber ( value: value)
1189
+ }
1190
+ }
Original file line number Diff line number Diff line change @@ -1785,6 +1785,17 @@ class TestFileManager : XCTestCase {
1785
1785
}
1786
1786
}
1787
1787
1788
+ func testNSNumberUpcall( ) throws {
1789
+ let url = writableTestDirectoryURL. appending ( component: " foo " , directoryHint: . notDirectory)
1790
+ try FileManager . default. createDirectory ( at: writableTestDirectoryURL, withIntermediateDirectories: true )
1791
+ XCTAssertTrue ( FileManager . default. createFile ( atPath: url. path, contents: Data ( " foo " . utf8) ) )
1792
+ let attrs = try FileManager . default. attributesOfItem ( atPath: url. path)
1793
+ let size = attrs [ . size]
1794
+ XCTAssertNotNil ( size as? NSNumber )
1795
+ XCTAssertNotNil ( size as? UInt64 )
1796
+ XCTAssertNotNil ( size as? Double ) // Ensure implicit conversion to unexpected types works
1797
+ }
1798
+
1788
1799
// -----
1789
1800
1790
1801
var writableTestDirectoryURL : URL !
You can’t perform that action at this time.
0 commit comments