Skip to content

Commit 2acf98f

Browse files
authored
Merge pull request #4664 from jckarter/rdar27905230
Foundation overlay: Remove unnecessary precondition that array elements be ObjectiveCBridgeable.
2 parents 3625f0e + 8232d33 commit 2acf98f

File tree

4 files changed

+31
-4
lines changed

4 files changed

+31
-4
lines changed

stdlib/public/SDK/Foundation/Foundation.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -498,10 +498,6 @@ extension Array : _ObjectiveCBridgeable {
498498
_ source: NSArray,
499499
result: inout Array?
500500
) {
501-
_precondition(
502-
Swift._isBridgedToObjectiveC(Element.self),
503-
"array element type is not bridged to Objective-C")
504-
505501
// If we have the appropriate native storage already, just adopt it.
506502
if let native =
507503
Array._bridgeFromObjectiveCAdoptingNativeStorageOf(source) {

test/stdlib/ArrayBridge.swift.gyb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,4 +470,16 @@ tests.test("testMutableArray") {
470470
expectEqualSequence(aCopy, a)
471471
}
472472

473+
tests.test("rdar://problem/27905230") {
474+
let dict = RDar27905230.mutableDictionaryOfMutableLists()!
475+
let arr = dict["list"]!
476+
expectEqual(arr[0] as! NSNull, NSNull())
477+
expectEqual(arr[1] as! String, "")
478+
expectEqual(arr[2] as! Int, 1)
479+
expectEqual(arr[3] as! Bool, true)
480+
expectEqual((arr[4] as! NSValue).rangeValue.location, 0)
481+
expectEqual((arr[4] as! NSValue).rangeValue.length, 1)
482+
expectEqual(arr[5] as! Date, Date(timeIntervalSince1970: 0))
483+
}
484+
473485
runAllTests()

test/stdlib/Inputs/ArrayBridge/ArrayBridge.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,7 @@ NSArray* idAsArray(id a);
1616

1717
void testSubclass(id thunks);
1818
void testBridgeableValue(id thunks);
19+
20+
@interface RDar27905230 : NSObject
21+
+ (NSDictionary<NSString *, NSArray<id> *> *)mutableDictionaryOfMutableLists;
22+
@end

test/stdlib/Inputs/ArrayBridge/ArrayBridge.m

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,18 @@ void testBridgeableValue(id thunks) {
6666
[toSwiftArr addObject: [thunks createSubclass:14]];
6767
[thunks acceptBridgeableValueArray: toSwiftArr];
6868
}
69+
70+
@implementation RDar27905230
71+
72+
+ (NSDictionary<NSString *, NSArray<id> *> *)mutableDictionaryOfMutableLists {
73+
NSMutableArray *arr = [NSMutableArray array];
74+
[arr addObject:[NSNull null]];
75+
[arr addObject:@""];
76+
[arr addObject:@1];
77+
[arr addObject:@YES];
78+
[arr addObject:[NSValue valueWithRange:NSMakeRange(0, 1)]];
79+
[arr addObject:[NSDate dateWithTimeIntervalSince1970: 0]];
80+
return [NSMutableDictionary dictionaryWithObject:arr forKey:@"list"];
81+
}
82+
83+
@end

0 commit comments

Comments
 (0)