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(
8282 ) ,
8383 . package (
8484 url: " https://github.com/apple/swift-foundation " ,
85- revision: " db63ab39bb4f07eeb3ccf19fa7a9f928a7ca3972 "
85+ revision: " 3297fb33b49ba2d1161ba12757891c7b91c73a3e "
8686 ) ,
8787 ] ,
8888 targets: [
Original file line number Diff line number Diff line change 99
1010
1111@_implementationOnly import _CoreFoundation
12+ @_spi ( SwiftCorelibsFoundation) @_exported import FoundationEssentials
1213
1314internal let kCFNumberSInt8Type = CFNumberType . sInt8Type
1415internal let kCFNumberSInt16Type = CFNumberType . sInt16Type
@@ -1172,3 +1173,18 @@ protocol _NSNumberCastingWithoutBridging {
11721173}
11731174
11741175extension 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 {
17851785 }
17861786 }
17871787
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+
17881799 // -----
17891800
17901801 var writableTestDirectoryURL : URL !
You can’t perform that action at this time.
0 commit comments