Skip to content

Commit 6af546e

Browse files
committed
Merge pull request #2419 from apple/se-0072
SE-0072: Fully eliminate implicit bridging conversions from Swift
2 parents 6e423a0 + ca1b525 commit 6af546e

16 files changed

+90
-94
lines changed

Diff for: lib/ClangImporter/ImportDecl.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -1701,8 +1701,10 @@ namespace {
17011701
// Construct right-hand side.
17021702
// FIXME: get the parameter from the init, and plug it in here.
17031703
auto rhs = new (cxt)
1704-
DeclRefExpr(init->getParameterList(1)->get(0), DeclNameLoc(),
1705-
/*Implicit=*/true);
1704+
CoerceExpr(new (cxt) DeclRefExpr(
1705+
init->getParameterList(1)->get(0),
1706+
DeclNameLoc(),
1707+
/*Implicit=*/true), {}, {nullptr, storedUnderlyingType});
17061708

17071709
// Add assignment.
17081710
auto assign = new (cxt) AssignExpr(lhs, SourceLoc(), rhs,

Diff for: lib/Sema/CSSimplify.cpp

+19-25
Original file line numberDiff line numberDiff line change
@@ -1709,33 +1709,27 @@ ConstraintSystem::matchTypes(Type type1, Type type2, TypeMatchKind kind,
17091709
// Bridging from a value type to an Objective-C class type.
17101710
// FIXME: Banned for operator parameters, like user conversions are.
17111711

1712-
// NOTE: The plan for <rdar://problem/18311362> was to make such bridging
1713-
// conversions illegal except when explicitly converting with the 'as'
1714-
// operator. But using a String to subscript an [NSObject : AnyObject] is
1715-
// sufficiently common due to bridging that disallowing such conversions is
1716-
// not yet feasible, and a more targeted fix in the type checker is hard to
1717-
// justify.
1718-
1719-
if (type1->isPotentiallyBridgedValueType() &&
1720-
type1->getAnyNominal()
1721-
!= TC.Context.getImplicitlyUnwrappedOptionalDecl() &&
1722-
!(flags & TMF_ApplyingOperatorParameter)) {
1723-
1724-
auto isBridgeableTargetType = type2->isBridgeableObjectType();
1725-
1726-
// Allow bridged conversions to CVarArg through NSObject.
1727-
if (!isBridgeableTargetType && type2->isExistentialType()) {
1728-
if (auto nominalType = type2->getAs<NominalType>())
1729-
isBridgeableTargetType = nominalType->getDecl()->getName() ==
1730-
TC.Context.Id_CVarArg;
1731-
}
1732-
1733-
if (isBridgeableTargetType && TC.getBridgedToObjC(DC, type1)) {
1734-
conversionsOrFixes.push_back(ConversionRestrictionKind::BridgeToObjC);
1712+
if (kind == TypeMatchKind::ExplicitConversion) {
1713+
1714+
if (type1->isPotentiallyBridgedValueType() &&
1715+
type1->getAnyNominal()
1716+
!= TC.Context.getImplicitlyUnwrappedOptionalDecl() &&
1717+
!(flags & TMF_ApplyingOperatorParameter)) {
1718+
1719+
auto isBridgeableTargetType = type2->isBridgeableObjectType();
1720+
1721+
// Allow bridged conversions to CVarArg through NSObject.
1722+
if (!isBridgeableTargetType && type2->isExistentialType()) {
1723+
if (auto nominalType = type2->getAs<NominalType>())
1724+
isBridgeableTargetType = nominalType->getDecl()->getName() ==
1725+
TC.Context.Id_CVarArg;
1726+
}
1727+
1728+
if (isBridgeableTargetType && TC.getBridgedToObjC(DC, type1)) {
1729+
conversionsOrFixes.push_back(ConversionRestrictionKind::BridgeToObjC);
1730+
}
17351731
}
1736-
}
17371732

1738-
if (kind == TypeMatchKind::ExplicitConversion) {
17391733
// Bridging from an Objective-C class type to a value type.
17401734
// Note that specifically require a class or class-constrained archetype
17411735
// here, because archetypes cannot be bridged.

Diff for: stdlib/private/StdlibUnittest/StdlibCoreExtras.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public func createTemporaryFile(
7373
_ fileNamePrefix: String, _ fileNameSuffix: String, _ contents: String
7474
) -> String {
7575
#if _runtime(_ObjC)
76-
let tempDir: NSString = NSTemporaryDirectory()
76+
let tempDir: NSString = NSTemporaryDirectory() as NSString
7777
var fileName = tempDir.appendingPathComponent(
7878
fileNamePrefix + "XXXXXX" + fileNameSuffix)
7979
#else

Diff for: stdlib/public/SDK/SceneKit/SceneKit.swift

+8-8
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ extension SCNVector3 {
2929
self.z = SCNFloat(z)
3030
}
3131
public init(_ x: CGFloat, _ y: CGFloat, _ z: CGFloat) {
32-
self.x = SCNFloat(x)
33-
self.y = SCNFloat(y)
34-
self.z = SCNFloat(z)
32+
self.x = SCNFloat(x as NSNumber)
33+
self.y = SCNFloat(y as NSNumber)
34+
self.z = SCNFloat(z as NSNumber)
3535
}
3636
public init(_ x: Double, _ y: Double, _ z: Double) {
3737
self.init(SCNFloat(x), SCNFloat(y), SCNFloat(z))
@@ -69,10 +69,10 @@ extension SCNVector4 {
6969
self.w = SCNFloat(w)
7070
}
7171
public init(_ x: CGFloat, _ y: CGFloat, _ z: CGFloat, _ w: CGFloat) {
72-
self.x = SCNFloat(x)
73-
self.y = SCNFloat(y)
74-
self.z = SCNFloat(z)
75-
self.w = SCNFloat(w)
72+
self.x = SCNFloat(x as NSNumber)
73+
self.y = SCNFloat(y as NSNumber)
74+
self.z = SCNFloat(z as NSNumber)
75+
self.w = SCNFloat(w as NSNumber)
7676
}
7777
public init(_ x: Double, _ y: Double, _ z: Double, _ w: Double) {
7878
self.init(SCNFloat(x), SCNFloat(y), SCNFloat(z), SCNFloat(w))
@@ -182,7 +182,7 @@ extension SCNSceneSource {
182182
@warn_unused_result
183183
public func entryWithIdentifier<T>(_ uid: String, withClass entryClass: T.Type) -> T? {
184184
return SCN_Swift_SCNSceneSource_entryWithIdentifier(
185-
self, uid, entryClass as! AnyObject) as! T?
185+
self, uid as NSString, entryClass as! AnyObject) as! T?
186186
}
187187
}
188188

Diff for: test/1_stdlib/ArrayBridge.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ func testRoundTrip() {
529529

530530
// Clear out the stats before returning array
531531
BridgedSwift.resetStats()
532-
return result
532+
return result as NSArray
533533
}
534534
}
535535

@@ -540,7 +540,7 @@ func testRoundTrip() {
540540
BridgedSwift(40), BridgedSwift(50) ]
541541

542542
BridgedSwift.resetStats()
543-
test.call(array)
543+
test.call(array as NSArray)
544544

545545
// CHECK-NEXT: ---Returned Array---
546546
print("---Returned Array---")

Diff for: test/1_stdlib/DictionaryLiteral.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ expectType(DictionaryLiteral<String, NSString>.self, &stringNSStringLiteral)
4848

4949
let aString = "1"
5050
let anNSString = "Foo" as NSString
51-
var stringNSStringLet: DictionaryLiteral = ["a": aString, "b": anNSString]
51+
var stringNSStringLet: DictionaryLiteral = [ "a": aString as NSString, "b": anNSString]
5252
expectType(DictionaryLiteral<String, NSString>.self, &stringNSStringLet)
5353

5454
var hetero1: DictionaryLiteral = ["a": 1, "b": "Foo" as NSString]

Diff for: test/1_stdlib/Inputs/DictionaryKeyValueTypesObjC.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,18 @@ func isCocoaDictionary<KeyTy : Hashable, ValueTy>(
4444
}
4545

4646
func isNativeNSDictionary(_ d: NSDictionary) -> Bool {
47-
let className: NSString = NSStringFromClass(d.dynamicType)
47+
let className: NSString = NSStringFromClass(d.dynamicType) as NSString
4848
return className.range(of: "_NativeDictionaryStorageOwner").length > 0
4949
}
5050

5151
func isCocoaNSDictionary(_ d: NSDictionary) -> Bool {
52-
let className: NSString = NSStringFromClass(d.dynamicType)
52+
let className: NSString = NSStringFromClass(d.dynamicType) as NSString
5353
return className.range(of: "NSDictionary").length > 0 ||
5454
className.range(of: "NSCFDictionary").length > 0
5555
}
5656

5757
func isNativeNSArray(_ d: NSArray) -> Bool {
58-
let className: NSString = NSStringFromClass(d.dynamicType)
58+
let className: NSString = NSStringFromClass(d.dynamicType) as NSString
5959
return className.range(of: "_SwiftDeferredNSArray").length > 0
6060
}
6161

Diff for: test/1_stdlib/NSStringAPI.swift

+7-7
Original file line numberDiff line numberDiff line change
@@ -1043,8 +1043,8 @@ NSStringAPIs.test("paragraphRangeFor(_:)") {
10431043
}
10441044

10451045
NSStringAPIs.test("pathComponents") {
1046-
expectEqual(["/", "foo", "bar"], "/foo/bar".pathComponents)
1047-
expectEqual(["/", "абв", "где"], "/абв/где".pathComponents)
1046+
expectEqual([ "/", "foo", "bar" ] as [NSString], ("/foo/bar" as NSString).pathComponents)
1047+
expectEqual([ "/", "абв", "где" ] as [NSString], ("/абв/где" as NSString).pathComponents)
10481048
}
10491049

10501050
NSStringAPIs.test("pathExtension") {
@@ -1646,10 +1646,10 @@ NSStringAPIs.test("trimmingCharacters(in:)") {
16461646
}
16471647

16481648
NSStringAPIs.test("NSString.stringsByAppendingPaths(_:)") {
1649-
expectEqual([], "".strings(byAppendingPaths: []))
1649+
expectEqual([] as [NSString], ("" as NSString).strings(byAppendingPaths: []))
16501650
expectEqual(
1651-
["/tmp/foo", "/tmp/bar"],
1652-
"/tmp".strings(byAppendingPaths: ["foo", "bar"]))
1651+
[ "/tmp/foo", "/tmp/bar" ] as [NSString],
1652+
("/tmp" as NSString).strings(byAppendingPaths: [ "foo", "bar" ]))
16531653
}
16541654

16551655
NSStringAPIs.test("substring(from:)") {
@@ -1867,8 +1867,8 @@ NSStringAPIs.test("MixedTypeComparisons") {
18671867
expectTrue(ys != "\u{1e69}")
18681868
expectFalse("\u{1e69}" == ys)
18691869
expectTrue("\u{1e69}" != ys)
1870-
expectFalse(xs == ys)
1871-
expectTrue(xs != ys)
1870+
expectFalse(xs as NSString == ys)
1871+
expectTrue(xs as NSString != ys)
18721872
expectTrue(ys == ys)
18731873
expectFalse(ys != ys)
18741874
}

Diff for: test/1_stdlib/SceneKit.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ if #available(iOS 8.0, OSX 10.10, *) {
3131
expectEqual(scn_float_from_d, 2.0)
3232

3333
let cg = CGFloat(3.0)
34-
let scn_float_from_cg = SCNFloat(cg)
34+
let scn_float_from_cg = SCNFloat(cg as NSNumber)
3535
expectEqual(scn_float_from_cg, 3.0)
3636

3737
let node = SCNNode()

Diff for: test/1_stdlib/StringDiagnostics.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ func testNonAmbiguousStringComparisons() {
4545

4646
func testAmbiguousStringComparisons(s: String) {
4747
let nsString = s as NSString
48-
let a1 = s == nsString
49-
let a2 = s != nsString
48+
let a1 = s as NSString == nsString
49+
let a2 = s as NSString != nsString
5050
let a3 = s < nsString // expected-error{{'NSString' is not implicitly convertible to 'String'; did you mean to use 'as' to explicitly convert?}} {{24-24= as String}}
5151
let a4 = s <= nsString // expected-error{{'NSString' is not implicitly convertible to 'String'; did you mean to use 'as' to explicitly convert?}} {{25-25= as String}}
5252
let a5 = s >= nsString // expected-error{{'NSString' is not implicitly convertible to 'String'; did you mean to use 'as' to explicitly convert?}} {{25-25= as String}}
5353
let a6 = s > nsString // expected-error{{'NSString' is not implicitly convertible to 'String'; did you mean to use 'as' to explicitly convert?}} {{24-24= as String}}
5454
// now the other way
55-
let a7 = nsString == s
56-
let a8 = nsString != s
55+
let a7 = nsString == s as NSString
56+
let a8 = nsString != s as NSString
5757
let a9 = nsString < s // expected-error{{'NSString' is not implicitly convertible to 'String'; did you mean to use 'as' to explicitly convert?}} {{20-20= as String}}
5858
let a10 = nsString <= s // expected-error{{'NSString' is not implicitly convertible to 'String'; did you mean to use 'as' to explicitly convert?}} {{21-21= as String}}
5959
let a11 = nsString >= s // expected-error{{'NSString' is not implicitly convertible to 'String'; did you mean to use 'as' to explicitly convert?}} {{21-21= as String}}

Diff for: test/ClangModules/AppKit_test.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ func test(_ URL: NSURL, controller: NSDocumentController) {
2323

2424
extension NSBox {
2525
func foo() {
26-
print("abc") // expected-warning {{use of 'print' treated as a reference to instance method in class 'NSView'}}
26+
print("abc" as NSString) // expected-warning {{use of 'print' treated as a reference to instance method in class 'NSView'}}
2727
// expected-note@-1 {{use 'self.' to silence this warning}} {{5-5=self.}}
2828
// expected-note@-2 {{use 'Swift.' to reference the global function}} {{5-5=Swift.}}
2929
}
3030
}
3131

3232
class MyView : NSView {
3333
func foo() {
34-
print("abc") // expected-warning {{use of 'print' treated as a reference to instance method in class 'NSView'}}
34+
print("abc" as NSString) // expected-warning {{use of 'print' treated as a reference to instance method in class 'NSView'}}
3535
// expected-note@-1 {{use 'self.' to silence this warning}} {{5-5=self.}}
3636
// expected-note@-2 {{use 'Swift.' to reference the global function}} {{5-5=Swift.}}
3737
}

Diff for: test/Constraints/bridging.swift

+18-18
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ func ==(x: OtherClass, y: OtherClass) -> Bool { return true }
9292

9393
// Basic bridging
9494
func bridgeToObjC(_ s: BridgedStruct) -> BridgedClass {
95-
return s
95+
return s // expected-error{{cannot convert return expression of type 'BridgedStruct' to return type 'BridgedClass'}}
9696
return s as BridgedClass
9797
}
9898

9999
func bridgeToAnyObject(_ s: BridgedStruct) -> AnyObject {
100-
return s
100+
return s // expected-error{{return expression of type 'BridgedStruct' does not conform to 'AnyObject'}}
101101
return s as AnyObject
102102
}
103103

@@ -115,10 +115,10 @@ func bridgeFromObjCDerived(_ s: BridgedClassSub) -> BridgedStruct {
115115
func arrayToNSArray() {
116116
var nsa: NSArray
117117

118-
nsa = [AnyObject]()
119-
nsa = [BridgedClass]()
120-
nsa = [OtherClass]()
121-
nsa = [BridgedStruct]()
118+
nsa = [AnyObject]() // expected-error {{cannot assign value of type '[AnyObject]' to type 'NSArray'}}
119+
nsa = [BridgedClass]() // expected-error {{cannot assign value of type '[BridgedClass]' to type 'NSArray'}}
120+
nsa = [OtherClass]() // expected-error {{cannot assign value of type '[OtherClass]' to type 'NSArray'}}
121+
nsa = [BridgedStruct]() // expected-error {{cannot assign value of type '[BridgedStruct]' to type 'NSArray'}}
122122
nsa = [NotBridgedStruct]() // expected-error{{cannot assign value of type '[NotBridgedStruct]' to type 'NSArray'}}
123123

124124
nsa = [AnyObject]() as NSArray
@@ -153,13 +153,13 @@ func dictionaryToNSDictionary() {
153153

154154
var nsd: NSDictionary
155155

156-
nsd = [NSObject : AnyObject]()
156+
nsd = [NSObject : AnyObject]() // expected-error {{cannot assign value of type '[NSObject : AnyObject]' to type 'NSDictionary'}}
157157
nsd = [NSObject : AnyObject]() as NSDictionary
158-
nsd = [NSObject : BridgedClass]()
158+
nsd = [NSObject : BridgedClass]() // expected-error {{cannot assign value of type '[NSObject : BridgedClass]' to type 'NSDictionary'}}
159159
nsd = [NSObject : BridgedClass]() as NSDictionary
160-
nsd = [NSObject : OtherClass]()
160+
nsd = [NSObject : OtherClass]() // expected-error {{cannot assign value of type '[NSObject : OtherClass]' to type 'NSDictionary'}}
161161
nsd = [NSObject : OtherClass]() as NSDictionary
162-
nsd = [NSObject : BridgedStruct]()
162+
nsd = [NSObject : BridgedStruct]() // expected-error {{cannot assign value of type '[NSObject : BridgedStruct]' to type 'NSDictionary'}}
163163
nsd = [NSObject : BridgedStruct]() as NSDictionary
164164
nsd = [NSObject : NotBridgedStruct]() // expected-error{{cannot assign value of type '[NSObject : NotBridgedStruct]' to type 'NSDictionary'}}
165165
nsd = [NSObject : NotBridgedStruct]() as NSDictionary // expected-error{{cannot convert value of type '[NSObject : NotBridgedStruct]' to type 'NSDictionary' in coercion}}
@@ -169,18 +169,18 @@ func dictionaryToNSDictionary() {
169169
nsd = [NSObject : BridgedStruct?]() // expected-error{{cannot assign value of type '[NSObject : BridgedStruct?]' to type 'NSDictionary'}}
170170
nsd = [NSObject : BridgedStruct?]() as NSDictionary //expected-error{{cannot convert value of type '[NSObject : BridgedStruct?]' to type 'NSDictionary' in coercion}}
171171

172-
nsd = [BridgedClass : AnyObject]()
172+
nsd = [BridgedClass : AnyObject]() // expected-error {{cannot assign value of type '[BridgedClass : AnyObject]' to type 'NSDictionary'}}
173173
nsd = [BridgedClass : AnyObject]() as NSDictionary
174-
nsd = [OtherClass : AnyObject]()
174+
nsd = [OtherClass : AnyObject]() // expected-error {{cannot assign value of type '[OtherClass : AnyObject]' to type 'NSDictionary'}}
175175
nsd = [OtherClass : AnyObject]() as NSDictionary
176-
nsd = [BridgedStruct : AnyObject]()
176+
nsd = [BridgedStruct : AnyObject]() // expected-error {{cannot assign value of type '[BridgedStruct : AnyObject]' to type 'NSDictionary'}}
177177
nsd = [BridgedStruct : AnyObject]() as NSDictionary
178178
nsd = [NotBridgedStruct : AnyObject]() // expected-error{{cannot assign value of type '[NotBridgedStruct : AnyObject]' to type 'NSDictionary'}}
179179
nsd = [NotBridgedStruct : AnyObject]() as NSDictionary // expected-error{{cannot convert value of type '[NotBridgedStruct : AnyObject]' to type 'NSDictionary' in coercion}}
180180

181181
// <rdar://problem/17134986>
182182
var bcOpt: BridgedClass?
183-
nsd = [BridgedStruct() : bcOpt] // expected-error{{value of optional type 'BridgedClass?' not unwrapped; did you mean to use '!' or '?'?}}
183+
nsd = [BridgedStruct() : bcOpt] // expected-error{{value of type 'BridgedStruct' does not conform to expected dictionary key type 'NSCopying'}}
184184
bcOpt = nil
185185
_ = nsd
186186
}
@@ -236,7 +236,7 @@ func rdar19695671() {
236236
// This failed at one point while fixing rdar://problem/19600325.
237237
func getArrayOfAnyObject(_: AnyObject) -> [AnyObject] { return [] }
238238
func testCallback(_ f: (AnyObject) -> AnyObject?) {}
239-
testCallback { return getArrayOfAnyObject($0) }
239+
testCallback { return getArrayOfAnyObject($0) } // expected-error {{cannot convert value of type '[AnyObject]' to closure result type 'AnyObject?'}}
240240

241241
// <rdar://problem/19724719> Type checker thinks "(optionalNSString ?? nonoptionalNSString) as String" is a forced cast
242242
func rdar19724719(_ f: (String) -> (), s1: NSString?, s2: NSString) {
@@ -295,10 +295,10 @@ func rdar19836341(_ ns: NSString?, vns: NSString?) {
295295

296296
// <rdar://problem/20029786> Swift compiler sometimes suggests changing "as!" to "as?!"
297297
func rdar20029786(_ ns: NSString?) {
298-
var s: String = ns ?? "str" as String as String // expected-error{{'NSString' is not implicitly convertible to 'String'; did you mean to use 'as' to explicitly convert?}} {{19-19=(}} {{50-50=) as String}}
299-
var s2 = ns ?? "str" as String as String
298+
var s: String = ns ?? "str" as String as String // expected-error{{cannot convert value of type 'NSString?' to expected argument type 'String?'}}
299+
var s2 = ns ?? "str" as String as String // expected-error {{binary operator '??' cannot be applied to operands of type 'NSString?' and 'String'}} expected-note{{}}
300300

301-
let s3: NSString? = "str" as String?
301+
let s3: NSString? = "str" as String? // expected-error {{cannot convert value of type 'String?' to specified type 'NSString?'}}
302302

303303
var s4: String = ns ?? "str" // expected-error{{'NSString' is not implicitly convertible to 'String'; did you mean to use 'as' to explicitly convert?}}{{20-20=(}}{{31-31=) as String}}
304304
var s5: String = (ns ?? "str") as String // fixed version

Diff for: test/Constraints/casts_objc.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ func test(_ a : CFString!, b : CFString) {
4242

4343

4444
// <rdar://problem/22507759> QoI: poor error message for invalid unsafeDowncast()
45-
let r22507759: NSObject! = "test"
45+
let r22507759: NSObject! = "test" as NSString
4646
let _: NSString! = unsafeDowncast(r22507759) // expected-error {{generic parameter 'T' could not be inferred}}
4747

Diff for: test/Interpreter/SDK/objc_array_of_classes.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ var ArrayOfClassObjectBridging = TestSuite("ArrayOfClassObjectBridging")
2929
ArrayOfClassObjectBridging.test("bridging class object array to NSArray") {
3030
let classes: [NSObject.Type] = [NSObject.self, NSString.self, NSArray.self]
3131

32-
let classesBridged: NSArray = classes
32+
let classesBridged: NSArray = classes as NSArray
3333

3434
expectTrue(classesBridged.count == 3)
3535
expectTrue(classesBridged[0] === NSObject.self)
@@ -39,7 +39,7 @@ ArrayOfClassObjectBridging.test("bridging class object array to NSArray") {
3939

4040
ArrayOfClassObjectBridging.test("bridging NSArray of class objects to [AnyObject]") {
4141
let classes: [NSObject.Type] = [NSObject.self, NSString.self, NSArray.self]
42-
let classesBridged: NSArray = classes
42+
let classesBridged: NSArray = classes as NSArray
4343
let classesUnbridgedAsAnyObject = classesBridged as [AnyObject]
4444

4545
expectTrue(classesUnbridgedAsAnyObject.count == 3)
@@ -50,7 +50,7 @@ ArrayOfClassObjectBridging.test("bridging NSArray of class objects to [AnyObject
5050

5151
ArrayOfClassObjectBridging.test("bridging NSArray of class objects to [AnyClass]") {
5252
let classes: [NSObject.Type] = [NSObject.self, NSString.self, NSArray.self]
53-
let classesBridged: NSArray = classes
53+
let classesBridged: NSArray = classes as NSArray
5454

5555
if let classesUnbridgedAsAnyClass = classesBridged as? [AnyClass] {
5656
expectTrue(classesUnbridgedAsAnyClass.count == 3)
@@ -64,7 +64,7 @@ ArrayOfClassObjectBridging.test("bridging NSArray of class objects to [AnyClass]
6464

6565
ArrayOfClassObjectBridging.test("bridging NSArray of class objects to [NSObject.Type]") {
6666
let classes: [NSObject.Type] = [NSObject.self, NSString.self, NSArray.self]
67-
let classesBridged: NSArray = classes
67+
let classesBridged: NSArray = classes as NSArray
6868

6969
if let classesUnbridgedAsNSObjectType = classesBridged as? [NSObject.Type] {
7070
expectTrue(classesUnbridgedAsNSObjectType.count == 3)

0 commit comments

Comments
 (0)