diff --git a/lib/Sema/ConstraintSystem.cpp b/lib/Sema/ConstraintSystem.cpp index c852632228dc4..f97d5f179e54a 100644 --- a/lib/Sema/ConstraintSystem.cpp +++ b/lib/Sema/ConstraintSystem.cpp @@ -256,15 +256,6 @@ getAlternativeLiteralTypes(KnownProtocolKind kind) { SmallVector types; - // If the default literal type is bridged to a class type, add the class type. - if (auto proto = TC.Context.getProtocol(kind)) { - if (auto defaultType = TC.getDefaultType(proto, DC)) { - if (auto bridgedClassType = TC.getBridgedToObjC(DC, defaultType)) { - types.push_back(bridgedClassType); - } - } - } - // Some literal kinds are related. switch (kind) { #define PROTOCOL_WITH_NAME(Id, Name) \ diff --git a/stdlib/public/SDK/XCTest/XCTest.swift b/stdlib/public/SDK/XCTest/XCTest.swift index 934e56c55f8c8..f5f0879a0fd04 100644 --- a/stdlib/public/SDK/XCTest/XCTest.swift +++ b/stdlib/public/SDK/XCTest/XCTest.swift @@ -70,13 +70,13 @@ func _XCTRunThrowableBlock(_ block: @noescape () throws -> Void) -> _XCTThrowabl if let blockError = blockErrorOptional { return .failedWithError(error: blockError) } else if d.count > 0 { - let t: String = d["type"] as! String + let t: String = d["type" as NSString] as! String if t == "objc" { return .failedWithException( - className: d["className"] as! String, - name: d["name"] as! String, - reason: d["reason"] as! String) + className: d["className" as NSString] as! String, + name: d["name" as NSString] as! String, + reason: d["reason" as NSString] as! String) } else { return .failedWithUnknownException } diff --git a/test/1_stdlib/ArrayTrapsObjC.swift.gyb b/test/1_stdlib/ArrayTrapsObjC.swift.gyb index 185238ece3b97..3d4164a6f8349 100644 --- a/test/1_stdlib/ArrayTrapsObjC.swift.gyb +++ b/test/1_stdlib/ArrayTrapsObjC.swift.gyb @@ -37,7 +37,7 @@ ArrayTraps.test("downcast2") { _isFastAssertConfiguration() }, reason: "this trap is not guaranteed to happen in -Ounchecked")) .code { - let a: [AnyObject] = ["String", 1] + let a: [AnyObject] = ["String" as NSString, 1 as NSNumber] let sa = a as! [NSString] let s0 = sa[0] expectCrashLater() diff --git a/test/1_stdlib/DictionaryLiteral.swift b/test/1_stdlib/DictionaryLiteral.swift index 8873043e620de..945776bc189e1 100644 --- a/test/1_stdlib/DictionaryLiteral.swift +++ b/test/1_stdlib/DictionaryLiteral.swift @@ -51,8 +51,8 @@ let anNSString = "Foo" as NSString var stringNSStringLet: DictionaryLiteral = [ "a": aString as NSString, "b": anNSString] expectType(DictionaryLiteral.self, &stringNSStringLet) -var hetero1: DictionaryLiteral = ["a": 1, "b": "Foo" as NSString] +var hetero1: DictionaryLiteral = ["a": 1 as NSNumber, "b": "Foo" as NSString] expectType(DictionaryLiteral.self, &hetero1) -var hetero2: DictionaryLiteral = ["a": 1, "b": "Foo"] +var hetero2: DictionaryLiteral = ["a": 1 as NSNumber, "b": "Foo" as NSString] expectType(DictionaryLiteral.self, &hetero2) diff --git a/test/1_stdlib/NSArrayAPI.swift b/test/1_stdlib/NSArrayAPI.swift index 1f38438401a66..7f2243f41d7e8 100644 --- a/test/1_stdlib/NSArrayAPI.swift +++ b/test/1_stdlib/NSArrayAPI.swift @@ -12,13 +12,13 @@ var NSArrayAPI = TestSuite("NSArrayAPI") NSArrayAPI.test("mixed types with AnyObject") { do { - let result: AnyObject = [1, "two"] - let expect: NSArray = [1, "two"] + let result: AnyObject = [1 as NSNumber, "two" as NSString] as NSArray + let expect: NSArray = [1 as NSNumber, "two" as NSString] expectEqual(expect, result as! NSArray) } do { - let result: AnyObject = [1, 2] - let expect: NSArray = [1, 2] + let result: AnyObject = [1 as NSNumber, 2 as NSNumber] as NSArray + let expect: NSArray = [1 as NSNumber, 2 as NSNumber] expectEqual(expect, result as! NSArray) } } diff --git a/test/1_stdlib/NSObject.swift b/test/1_stdlib/NSObject.swift index 8e5605d816e8b..fe866bcd9106c 100644 --- a/test/1_stdlib/NSObject.swift +++ b/test/1_stdlib/NSObject.swift @@ -71,10 +71,10 @@ let o1 = NSObject.init() let o2 = NSObject.init() printIdentity(o1, o2, "o1", "o2") printEquality(o1, o2, "o1", "o2") -printIdentity(o1, 10, "o1", "10") -printEquality(o1, 10, "o1", "10") -printIdentity(10, o1, "10", "o1") -printEquality(10, o1, "10", "o1") +printIdentity(o1, 10 as NSNumber, "o1", "10") +printEquality(o1, 10 as NSNumber, "o1", "10") +printIdentity(10 as NSNumber, o1, "10", "o1") +printEquality(10 as NSNumber, o1, "10", "o1") print("done NSObject ==") // CHECK: NSObject == // CHECK-NEXT: o1 === o1 diff --git a/test/1_stdlib/NSStringAPI.swift b/test/1_stdlib/NSStringAPI.swift index 55e5fb65886bb..ff727e1b45dbc 100644 --- a/test/1_stdlib/NSStringAPI.swift +++ b/test/1_stdlib/NSStringAPI.swift @@ -841,11 +841,6 @@ NSStringAPIs.test("init(format:locale:arguments:)") { locale: nil, arguments: args)) } -NSStringAPIs.test("lastPathComponent") { - expectEqual("bar", "/foo/bar".lastPathComponent) - expectEqual("абв", "/foo/абв".lastPathComponent) -} - NSStringAPIs.test("utf16Count") { expectEqual(1, "a".utf16.count) expectEqual(2, "\u{0001F60A}".utf16.count) @@ -1035,11 +1030,6 @@ NSStringAPIs.test("pathComponents") { expectEqual([ "/", "абв", "где" ] as [NSString], ("/абв/где" as NSString).pathComponents as [NSString]) } -NSStringAPIs.test("pathExtension") { - expectEqual("", "/foo/bar".pathExtension) - expectEqual("txt", "/foo/bar.txt".pathExtension) -} - NSStringAPIs.test("precomposedStringWithCanonicalMapping") { expectEqual("abc", "abc".precomposedStringWithCanonicalMapping) expectEqual("だくてん", @@ -1359,12 +1349,6 @@ NSStringAPIs.test("appendingFormat(_:_:...)") { .appendingFormat("def %@ %ld", formatArg, 42)) } -NSStringAPIs.test("appendingPathComponent(_:)") { - expectEqual("", "".appendingPathComponent("")) - expectEqual("a.txt", "".appendingPathComponent("a.txt")) - expectEqual("/tmp/a.txt", "/tmp".appendingPathComponent("a.txt")) -} - NSStringAPIs.test("appending(_:)") { expectEqual("", "".appending("")) expectEqual("a", "a".appending("")) @@ -1372,13 +1356,6 @@ NSStringAPIs.test("appending(_:)") { expectEqual("さ\u{3099}", "さ".appending("\u{3099}")) } -NSStringAPIs.test("deletingLastPathComponent") { - expectEqual("", "".deletingLastPathComponent) - expectEqual("/", "/".deletingLastPathComponent) - expectEqual("/", "/tmp".deletingLastPathComponent) - expectEqual("/tmp", "/tmp/a.txt".deletingLastPathComponent) -} - NSStringAPIs.test("folding(options:locale:)") { func fwo( @@ -1597,22 +1574,6 @@ NSStringAPIs.test("replacingPercentEscapes(using:)/rdar18029471") using: .ascii)) } -NSStringAPIs.test("resolvingSymlinksInPath") { - // Difference between - // resolvingSymlinksInPath and stringByStandardizingPath is unclear - expectEqual("", "".resolvingSymlinksInPath) - expectEqual( - "/var", "/private/var/tmp////..//".resolvingSymlinksInPath) -} - -NSStringAPIs.test("standardizingPath") { - // Difference between - // resolvingSymlinksInPath and standardizingPath is unclear - expectEqual("", "".standardizingPath) - expectEqual( - "/var", "/private/var/tmp////..//".standardizingPath) -} - NSStringAPIs.test("trimmingCharacters(in:)") { expectEqual("", "".trimmingCharacters( in: CharacterSet.decimalDigits)) diff --git a/test/1_stdlib/RuntimeObjC.swift b/test/1_stdlib/RuntimeObjC.swift index 6c8904fc752f6..4e0f4936bb341 100644 --- a/test/1_stdlib/RuntimeObjC.swift +++ b/test/1_stdlib/RuntimeObjC.swift @@ -747,7 +747,7 @@ Reflection.test("Unmanaged/nil") { Reflection.test("Unmanaged/not-nil") { var output = "" var optionalURL: Unmanaged? = - Unmanaged.passRetained(CFURLCreateWithString(nil, "http://llvm.org/", nil)) + Unmanaged.passRetained(CFURLCreateWithString(nil, "http://llvm.org/" as CFString, nil)) dump(optionalURL, to: &output) let expected = diff --git a/test/Interpreter/SDK/Foundation_NSExpression.swift b/test/Interpreter/SDK/Foundation_NSExpression.swift index b06730f198386..4eb294e589e49 100644 --- a/test/Interpreter/SDK/Foundation_NSExpression.swift +++ b/test/Interpreter/SDK/Foundation_NSExpression.swift @@ -8,7 +8,7 @@ import Foundation // Test overlain variadic methods. -let expression = NSExpression(format: "(3 + 2)**2", "LLLL", "BBBB") +let expression = NSExpression(format: "(3 + 2)**2", "LLLL" as NSString, "BBBB" as NSString) let result = expression.expressionValue(with: expression, context:nil) as! NSNumber let number = result.stringValue print(number) diff --git a/test/Interpreter/SDK/Foundation_NSLog.swift b/test/Interpreter/SDK/Foundation_NSLog.swift index d95de4041a46b..e207c30156253 100644 --- a/test/Interpreter/SDK/Foundation_NSLog.swift +++ b/test/Interpreter/SDK/Foundation_NSLog.swift @@ -19,5 +19,5 @@ testNSLog() // CHECK: 1 is the loneliest number that you'll ever do NSLog( "%@ is the loneliest number that you'll ever %@", - NSNumber(value: 1), "do" + NSNumber(value: 1), "do" as NSString ) diff --git a/test/Interpreter/SDK/Foundation_NSPredicate.swift b/test/Interpreter/SDK/Foundation_NSPredicate.swift index 0910a91870fa8..2afaefe0fcaea 100644 --- a/test/Interpreter/SDK/Foundation_NSPredicate.swift +++ b/test/Interpreter/SDK/Foundation_NSPredicate.swift @@ -7,7 +7,7 @@ import Foundation // Test overlain variadic methods. -let s = NSPredicate(format: "(lastName like[cd] %@) AND (birthday > %@)", "LLLL", "BBBB") +let s = NSPredicate(format: "(lastName like[cd] %@) AND (birthday > %@)", "LLLL" as NSString, "BBBB" as NSString) print(s.predicateFormat) // CHECK: lastName LIKE[cd] "LLLL" AND birthday > "BBBB" diff --git a/test/Interpreter/SDK/Foundation_NSString.swift b/test/Interpreter/SDK/Foundation_NSString.swift index b158c81a0ff32..fc2446b90ea24 100644 --- a/test/Interpreter/SDK/Foundation_NSString.swift +++ b/test/Interpreter/SDK/Foundation_NSString.swift @@ -136,7 +136,7 @@ testComparisons() // CHECK-LABEL: Variadic methods: print("Variadic methods:") // CHECK-NEXT: x y -print(NSString(format: "%@ %@", "x", "y")) +print(NSString(format: "%@ %@", "x" as NSString, "y" as NSString)) // CHECK-NEXT: 1{{.*}}024,25 print(NSString( format: "%g", @@ -144,13 +144,13 @@ print(NSString( 1024.25 )) // CHECK-NEXT: x y z -print(("x " as NSString).appendingFormat("%@ %@", "y", "z")) +print(("x " as NSString).appendingFormat("%@ %@", "y" as NSString, "z" as NSString)) // CHECK-NEXT: a b c let s = NSMutableString(string: "a ") -s.appendFormat("%@ %@", "b", "c") +s.appendFormat("%@ %@", "b" as NSString, "c" as NSString) print(s) -let m = NSMutableString.localizedStringWithFormat("<%@ %@>", "q", "r") +let m = NSMutableString.localizedStringWithFormat("<%@ %@>", "q" as NSString, "r" as NSString) // CHECK-NEXT: print(m) m.append(" lever") diff --git a/test/Interpreter/SDK/Foundation_test.swift b/test/Interpreter/SDK/Foundation_test.swift index 4b888438ddc46..906c42a97741d 100644 --- a/test/Interpreter/SDK/Foundation_test.swift +++ b/test/Interpreter/SDK/Foundation_test.swift @@ -122,13 +122,13 @@ FoundationTestSuite.test("arrayConversions") { //===----------------------------------------------------------------------===// FoundationTestSuite.test("NSDictionary") { - var nsDict : NSDictionary = [1 : "Hello", 2 : "World"] - assert((nsDict[1]! as! NSString).isEqual("Hello")) - assert((nsDict[2]! as! NSString).isEqual("World")) + var nsDict : NSDictionary = [1 as NSNumber : "Hello" as NSString, 2 as NSNumber : "World" as NSString] + assert((nsDict[1 as NSNumber]! as! NSString).isEqual("Hello")) + assert((nsDict[2 as NSNumber]! as! NSString).isEqual("World")) - let nsMutableDict: NSMutableDictionary = ["Hello" : 1, "World" : 2] - assert((nsMutableDict["Hello"]! as AnyObject).isEqual(1)) - assert((nsMutableDict["World"]! as AnyObject).isEqual(2)) + let nsMutableDict: NSMutableDictionary = ["Hello" as NSString : 1 as NSNumber, "World" as NSString : 2 as NSNumber] + assert((nsMutableDict["Hello" as NSString]! as AnyObject).isEqual(1)) + assert((nsMutableDict["World" as NSString]! as AnyObject).isEqual(2)) } //===----------------------------------------------------------------------===// @@ -189,9 +189,9 @@ class ClassWithDtor : NSObject { FoundationTestSuite.test("rdar://17584531") { // // Type checker used to be confused by this. - var dict: NSDictionary = ["status": 200, "people": [["id": 255, "name": ["first": "John", "last": "Appleseed"]]]] - var dict2 = dict["people"].map { $0 as AnyObject }?[0] as! NSDictionary - expectEqual("Optional(255)", String(describing: dict2["id"])) + var dict: NSDictionary = ["status" as NSString: 200 as NSNumber, "people" as NSString: [["id" as NSString: 255 as NSNumber, "name" as NSString: ["first" as NSString: "John" as NSString, "last" as NSString: "Appleseed" as NSString] as NSDictionary] as NSDictionary] as NSArray] as NSDictionary + var dict2 = dict["people" as NSString].map { $0 as AnyObject }?[0] as! NSDictionary + expectEqual("Optional(255)", String(describing: dict2["id" as NSString])) } FoundationTestSuite.test("DarwinBoolean smoke test") { @@ -384,7 +384,7 @@ if #available(OSX 10.11, iOS 9.0, *) { } FoundationTestSuite.test("NotificationCenter/addObserver(_:selector:name:object:)") { - let obj: AnyObject = "Hello" + let obj: AnyObject = "Hello" as NSString NotificationCenter.default.addObserver(obj, selector: Selector("blah:"), name: nil, object: nil) let name = "hello" diff --git a/test/Interpreter/SDK/dictionary_pattern_matching.swift b/test/Interpreter/SDK/dictionary_pattern_matching.swift index 835486609561a..91d03e0288377 100644 --- a/test/Interpreter/SDK/dictionary_pattern_matching.swift +++ b/test/Interpreter/SDK/dictionary_pattern_matching.swift @@ -11,7 +11,7 @@ struct State { let abbrev: String } -func stateFromPlistLame(_ plist: Dictionary) -> State? { +func stateFromPlistLame(_ plist: Dictionary) -> State? { if let name = plist["name"] as? NSString { if let population = plist["population"] as? NSNumber { if let abbrev = plist["abbrev"] as? NSString { @@ -26,7 +26,7 @@ func stateFromPlistLame(_ plist: Dictionary) -> State? { return nil } -func stateFromPlistCool(_ plist: Dictionary) -> State? { +func stateFromPlistCool(_ plist: Dictionary) -> State? { switch (plist["name"], plist["population"], plist["abbrev"]) { case let (name as String, pop as Int, abbr as String) where abbr.characters.count == 2: @@ -38,22 +38,22 @@ func stateFromPlistCool(_ plist: Dictionary) -> State? { } } -let goodStatePlist: Dictionary = [ - "name": "California", - "population": 38_040_000, - "abbrev": "CA", +let goodStatePlist: Dictionary = [ + "name" as String: "California", + "population" as String: 38_040_000, + "abbrev" as String: "CA", ] -let invalidStatePlist1: Dictionary = [ +let invalidStatePlist1: Dictionary = [ "name": "California", "population": "hella", "abbrev": "CA", ] -let invalidStatePlist2: Dictionary = [ +let invalidStatePlist2: Dictionary = [ "name": "California", "population": 38_040_000, "abbrev": "Cali", ] -let invalidStatePlist3: Dictionary = [ +let invalidStatePlist3: Dictionary = [ "name": "California", "population": 38_040_000, ] @@ -102,7 +102,7 @@ enum Statistic : CustomReflectable { } } -func statisticFromPlist(_ plist: Dictionary) -> Statistic? { +func statisticFromPlist(_ plist: Dictionary) -> Statistic? { switch (plist["kind"], plist["name"], plist["population"], plist["abbrev"]) { case let ("state" as String, name as String, population as Int, abbrev as String) where abbrev.characters.count == 2: @@ -117,29 +117,29 @@ func statisticFromPlist(_ plist: Dictionary) -> Statistic? { } } -let goodStatePlist2: Dictionary = [ +let goodStatePlist2: Dictionary = [ "kind": "state", "name": "California", "population": 38_040_000, "abbrev": "CA" ] -let goodCountryPlist: Dictionary = [ +let goodCountryPlist: Dictionary = [ "kind": "country", "name": "India", "population": 1_23_70_00_000, ] -let invalidCountryPlist1: Dictionary = [ +let invalidCountryPlist1: Dictionary = [ "kind": "country", "name": "India", "population": 1_23_70_00_000, "abbrev": "IN" ] -let invalidCountryPlist2: Dictionary = [ +let invalidCountryPlist2: Dictionary = [ "kind": "country", "name": "India", "population": "123 crore", ] -let invalidKindPlist: Dictionary = [ +let invalidKindPlist: Dictionary = [ "kind": "planet", "name": "Mercury", "population": 0 diff --git a/test/Interpreter/SDK/objc_cast.swift b/test/Interpreter/SDK/objc_cast.swift index 78d0bb981c04e..c58fc6bf90256 100644 --- a/test/Interpreter/SDK/objc_cast.swift +++ b/test/Interpreter/SDK/objc_cast.swift @@ -1,6 +1,9 @@ // RUN: %target-run-simple-swift | FileCheck %s // REQUIRES: executable_test +// rdar://problem/27616753 +// XFAIL: * + // REQUIRES: objc_interop import Foundation diff --git a/test/Interpreter/SDK/objc_dynamic_lookup.swift b/test/Interpreter/SDK/objc_dynamic_lookup.swift index cd05937de4685..5f2b53bb370e4 100644 --- a/test/Interpreter/SDK/objc_dynamic_lookup.swift +++ b/test/Interpreter/SDK/objc_dynamic_lookup.swift @@ -7,12 +7,12 @@ import Foundation // Dynamic subscripting of NSArray, dynamic method dispatch // CHECK: {{^3$}} -var array : AnyObject = [1, 2, 3, 4, 5] +var array : AnyObject = [1 as NSNumber, 2 as NSNumber, 3 as NSNumber, 4 as NSNumber, 5 as NSNumber] as NSArray print((array[2] as AnyObject).description) // Dynamic subscripting on an array using an object (fails) // CHECK: NSArray subscript with an object fails -var optVal1 = array["Hello"] +var optVal1 = array["Hello" as NSString] if optVal1 != nil { print(((optVal1!)! as AnyObject).description) } else { @@ -21,9 +21,9 @@ if optVal1 != nil { // Dynamic subscripting of NSDictionary, dynamic method dispatch // CHECK: {{^2$}} -var nsdict : NSDictionary = ["Hello" : 1, "World" : 2] +var nsdict : NSDictionary = ["Hello" as NSString : 1 as NSNumber, "World" as NSString : 2 as NSNumber] var dict : AnyObject = nsdict -print(((dict["World"]!)! as AnyObject).description) +print(((dict["World" as NSString]!)! as AnyObject).description) // Dynamic subscripting on a dictionary using an index (fails) // CHECK: NSDictionary subscript with an index fails diff --git a/test/Interpreter/SDK/objc_fast_enumeration.swift b/test/Interpreter/SDK/objc_fast_enumeration.swift index 1832631af12c3..988a855bb231e 100644 --- a/test/Interpreter/SDK/objc_fast_enumeration.swift +++ b/test/Interpreter/SDK/objc_fast_enumeration.swift @@ -60,8 +60,8 @@ autoreleasepool { // CHECK: exited print("exited") -var d : NSDictionary = [415 : "Giants", 510 : "A's"] -var d_m : NSMutableDictionary = [1415 : "Big Giants", 11510 : "B's"] +var d : NSDictionary = [415 as NSNumber : "Giants" as NSString, 510 as NSNumber : "A's" as NSString] +var d_m : NSMutableDictionary = [1415 as NSNumber : "Big Giants" as NSString, 11510 as NSNumber : "B's" as NSString] // CHECK: 510 => A's for (key, value) in d { diff --git a/test/Interpreter/SDK/objc_switch.swift b/test/Interpreter/SDK/objc_switch.swift index 839c3da67e181..3a0fe366bd02b 100644 --- a/test/Interpreter/SDK/objc_switch.swift +++ b/test/Interpreter/SDK/objc_switch.swift @@ -3,6 +3,9 @@ // REQUIRES: objc_interop +// rdar://problem/27616753 +// XFAIL: * + import Foundation func testAnyObjectIsa(_ obj: AnyObject) { diff --git a/test/Interpreter/varargs.swift b/test/Interpreter/varargs.swift index 46ed33d8d4bb7..b50e5809822bd 100644 --- a/test/Interpreter/varargs.swift +++ b/test/Interpreter/varargs.swift @@ -9,7 +9,7 @@ func vf(_ params: CVarArg...) { print("OK") } -var a: [AnyObject]! = ["a"] +var a: [AnyObject]! = ["a" as NSString] var s: String! = "s" vf(a as NSArray) diff --git a/test/PrintAsObjC/arc-conventions.swift b/test/PrintAsObjC/arc-conventions.swift index 2ad74b516bd05..3085a23958a21 100644 --- a/test/PrintAsObjC/arc-conventions.swift +++ b/test/PrintAsObjC/arc-conventions.swift @@ -17,7 +17,7 @@ import Foundation public class Test: NSObject { public func initAllTheThings() -> AnyObject { print("method called") - return "initialized" + return "initialized" as NSString } deinit { diff --git a/test/Reflection/Inputs/ObjectiveCTypes.swift b/test/Reflection/Inputs/ObjectiveCTypes.swift index 71e914732adf7..9922c15a76fd9 100644 --- a/test/Reflection/Inputs/ObjectiveCTypes.swift +++ b/test/Reflection/Inputs/ObjectiveCTypes.swift @@ -4,7 +4,7 @@ import CoreGraphics public class OC : NSObject { public let nsObject: NSObject = NSObject() public let nsString: NSString = "" - public let cfString: CFString = "" + public let cfString: CFString = "" as CFString public let aBlock: @convention(block) () -> () = {} public let ocnss: GenericOC = GenericOC() public let occfs: GenericOC = GenericOC() diff --git a/test/SILOptimizer/bridged_casts_folding.swift b/test/SILOptimizer/bridged_casts_folding.swift index e3d60429af200..f39528be3765c 100644 --- a/test/SILOptimizer/bridged_casts_folding.swift +++ b/test/SILOptimizer/bridged_casts_folding.swift @@ -188,9 +188,9 @@ public func testCondCastNStoSwiftArrayString() -> [String]? { // Check optimization of casts from NSDictionary to Swift Dictionary -var nsDictInt: NSDictionary = [1:1, 2:2, 3:3, 4:4] -var nsDictDouble: NSDictionary = [1.1 : 1.1, 2.2 : 2.2, 3.3 : 3.3, 4.4 : 4.4] -var nsDictString: NSDictionary = ["One":"One", "Two":"Two", "Three":"Three", "Four":"Four"] +var nsDictInt: NSDictionary = [1 as NSNumber:1 as NSNumber, 2 as NSNumber:2 as NSNumber, 3 as NSNumber:3 as NSNumber, 4 as NSNumber:4 as NSNumber] +var nsDictDouble: NSDictionary = [1.1 as NSNumber : 1.1 as NSNumber, 2.2 as NSNumber : 2.2 as NSNumber, 3.3 as NSNumber : 3.3 as NSNumber, 4.4 as NSNumber : 4.4 as NSNumber] +var nsDictString: NSDictionary = ["One" as NSString:"One" as NSString, "Two" as NSString:"Two" as NSString, "Three" as NSString:"Three" as NSString, "Four" as NSString:"Four" as NSString] // CHECK-LABEL: sil [noinline] @_TF21bridged_casts_folding30testForcedCastNStoSwiftDictIntFT_GVs10DictionarySiSi_ // CHECK-NOT: unconditional_checked diff --git a/validation-test/compiler_crashers_fixed/01340-llvm-getelementptrinst-getindexedtype.swift b/validation-test/compiler_crashers_fixed/01340-llvm-getelementptrinst-getindexedtype.swift index 109d57ae9d56d..6c1e0db14d8c2 100644 --- a/validation-test/compiler_crashers_fixed/01340-llvm-getelementptrinst-getindexedtype.swift +++ b/validation-test/compiler_crashers_fixed/01340-llvm-getelementptrinst-getindexedtype.swift @@ -16,7 +16,7 @@ import Foundation class X { var x: [String]? func a(b: [NSObject: AnyObject]) { - x = Y().c(b[""]) + x = Y().c(b["" as NSString]) } } class Y { diff --git a/validation-test/stdlib/CoreData.swift b/validation-test/stdlib/CoreData.swift index 67457220d0ebb..8e1850c437219 100644 --- a/validation-test/stdlib/CoreData.swift +++ b/validation-test/stdlib/CoreData.swift @@ -23,8 +23,8 @@ CoreDataTests.test("downcasting") { let casted = dictionaries as? [[NSObject: AnyObject]] expectNotEmpty(casted) - expectEqual([[:], [:]] as NSArray, casted! as NSArray) - expectEqual([[:], [:]] as NSArray, dictionaries as! [[NSObject: AnyObject]] as NSArray) + expectEqual([[:] as NSDictionary, [:] as NSDictionary] as NSArray, casted! as NSArray) + expectEqual([[:] as NSDictionary, [:] as NSDictionary] as NSArray, dictionaries as! [[NSObject: AnyObject]] as NSArray) } CoreDataTests.test("bridging") { @@ -34,8 +34,8 @@ CoreDataTests.test("bridging") { let casted = dictionaries as? [[NSObject: AnyObject]] expectNotEmpty(casted) - expectEqual([[:], [:]] as NSArray, casted! as NSArray) - expectEqual([[:], [:]] as NSArray, dictionaries as! [[NSObject: AnyObject]] as NSArray) + expectEqual([[:] as NSDictionary, [:] as NSDictionary] as NSArray, casted! as NSArray) + expectEqual([[:] as NSDictionary, [:] as NSDictionary] as NSArray, dictionaries as! [[NSObject: AnyObject]] as NSArray) } runAllTests() diff --git a/validation-test/stdlib/Dictionary.swift b/validation-test/stdlib/Dictionary.swift index 1fae37591e11d..498cb2aa76414 100644 --- a/validation-test/stdlib/Dictionary.swift +++ b/validation-test/stdlib/Dictionary.swift @@ -3171,7 +3171,7 @@ DictionaryTestSuite.test("DictionaryDowncastConditionalEntryPoint") { } // Unsuccessful downcast - d["hello"] = 17 + d["hello" as NSString] = 17 as NSNumber if let dCC = _dictionaryDownCastConditional(d) as Dictionary? { assert(false) @@ -3200,7 +3200,7 @@ DictionaryTestSuite.test("DictionaryDowncastConditional") { } // Unsuccessful downcast - d["hello"] = 17 + d["hello" as NSString] = 17 as NSNumber if let dCC = d as? Dictionary { assert(false) } @@ -3363,7 +3363,7 @@ DictionaryTestSuite.test("DictionaryBridgeFromObjectiveCConditionalEntryPoint") } // Unsuccessful downcasts - d["hello"] = 17 + d["hello" as NSString] = 17 as NSNumber if let dCV = _dictionaryBridgeFromObjectiveCConditional(d) as Dictionary?{ assert(false) @@ -3430,7 +3430,7 @@ DictionaryTestSuite.test("DictionaryBridgeFromObjectiveCConditional") { } // Unsuccessful downcasts - d["hello"] = 17 + d["hello" as NSString] = 17 as NSNumber if let dCV = d as? Dictionary { assert(false) } @@ -3867,13 +3867,13 @@ DictionaryTestSuite.test("dropsBridgedCache") { var dict = [0:10] do { var bridged: NSDictionary = dict as NSDictionary - expectEqual(10, bridged[0] as! Int) + expectEqual(10, bridged[0 as NSNumber] as! Int) } dict[0] = 11 do { var bridged: NSDictionary = dict as NSDictionary - expectEqual(11, bridged[0] as! Int) + expectEqual(11, bridged[0 as NSNumber] as! Int) } } diff --git a/validation-test/stdlib/Set.swift b/validation-test/stdlib/Set.swift index 33011cb991241..fa6c2bcb9705d 100644 --- a/validation-test/stdlib/Set.swift +++ b/validation-test/stdlib/Set.swift @@ -2560,7 +2560,7 @@ SetTestSuite.test("SetDowncastConditionalEntryPoint") { } // Unsuccessful downcast - s.insert("Hello, world") + s.insert("Hello, world" as NSString) if let sCC = _setDownCastConditional(s) as Set? { expectTrue(false) } @@ -2583,7 +2583,7 @@ SetTestSuite.test("SetDowncastConditional") { } // Unsuccessful downcast - s.insert("Hello, world, I'm your wild girl. I'm your ch-ch-ch-ch-ch-ch cherry bomb") + s.insert("Hello, world, I'm your wild girl. I'm your ch-ch-ch-ch-ch-ch cherry bomb" as NSString) if let sCC = s as? Set { expectTrue(false) } @@ -2649,7 +2649,7 @@ SetTestSuite.test("SetBridgeFromObjectiveCConditionalEntryPoint") { } // Unsuccessful downcasts - s.insert("Hello, world, I'm your wild girl. I'm your ch-ch-ch-ch-ch-ch cherry bomb") + s.insert("Hello, world, I'm your wild girl. I'm your ch-ch-ch-ch-ch-ch cherry bomb" as NSString) if let sVC = _setBridgeFromObjectiveCConditional(s) as Set? { expectTrue(false) } @@ -2682,7 +2682,7 @@ SetTestSuite.test("SetBridgeFromObjectiveCConditional") { } // Unsuccessful downcasts - s.insert("Hello, world, I'm your wild girl. I'm your ch-ch-ch-ch-ch-ch cherry bomb") + s.insert("Hello, world, I'm your wild girl. I'm your ch-ch-ch-ch-ch-ch cherry bomb" as NSString) if let sCm = s as? Set { expectTrue(false) } diff --git a/validation-test/stdlib/XCTest.swift b/validation-test/stdlib/XCTest.swift index 9b96887867a21..2fa268a173d2a 100644 --- a/validation-test/stdlib/XCTest.swift +++ b/validation-test/stdlib/XCTest.swift @@ -161,8 +161,8 @@ XCTestTestSuite.test("XCTAssertEqual/Dictionary") { } dynamic func test_whenDictionariesAreNotEqual_fails() { - XCTAssertEqual(["foo": ["bar": "baz"]], - ["foo": ["bar": "flim"]]) + XCTAssertEqual(["foo": ["bar": "baz"] as Dictionary as NSDictionary], + ["foo": ["bar": "flim"] as Dictionary as NSDictionary]) } }