Skip to content

Commit 19727f2

Browse files
[Sema][test] Adjusting all missing downcast diagnostics failures
1 parent 1479c00 commit 19727f2

18 files changed

+84
-45
lines changed

test/ClangImporter/Dispatch_test.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ func test2(_ queue: DispatchQueue) {
1515

1616
// Make sure the dispatch types are actually distinct types!
1717
let _ = queue as DispatchSource // expected-error {{cannot convert value of type 'DispatchQueue' to type 'DispatchSource' in coercion}}
18-
let _ = base as DispatchSource // expected-error {{'NSObjectProtocol' is not convertible to 'DispatchSource'; did you mean to use 'as!' to force downcast?}}
18+
let _ = base as DispatchSource // expected-error {{'NSObjectProtocol' is not convertible to 'DispatchSource'}}
19+
// expected-note@-1 {{did you mean to use 'as!' to force downcast?}} {{16-18=as!}}
1920
}
2021

2122
extension dispatch_queue_t {} // expected-error {{'dispatch_queue_t' is unavailable}}

test/ClangImporter/Security_test.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import Security
66

77
_ = kSecClass as CFString
88
_ = kSecClassGenericPassword as CFString
9-
_ = kSecClassGenericPassword as CFDictionary // expected-error {{'CFString?' is not convertible to 'CFDictionary'}} {{30-32=as!}}
9+
_ = kSecClassGenericPassword as CFDictionary // expected-error {{'CFString?' is not convertible to 'CFDictionary'}}
10+
// expected-note@-1 {{did you mean to use 'as!' to force downcast?}} {{30-32=as!}}
1011

1112
func testIntegration() {
1213
// Based on code in <rdar://problem/17162475>.

test/ClangImporter/objc_bridging_custom.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,11 +218,16 @@ func testExplicitConversion(objc: APPManufacturerInfo<NSString>,
218218
swift: ManufacturerInfo<NSString>) {
219219
// Bridging to Swift
220220
let _ = objc as ManufacturerInfo<NSString>
221-
let _ = objc as ManufacturerInfo<NSNumber> // expected-error{{'APPManufacturerInfo<NSString>' is not convertible to 'ManufacturerInfo<NSNumber>'; did you mean to use 'as!' to force downcast?}}
222-
let _ = objc as ManufacturerInfo<NSObject> // expected-error{{'APPManufacturerInfo<NSString>' is not convertible to 'ManufacturerInfo<NSObject>'; did you mean to use 'as!' to force downcast?}}
221+
let _ = objc as ManufacturerInfo<NSNumber> // expected-error{{'APPManufacturerInfo<NSString>' is not convertible to 'ManufacturerInfo<NSNumber>'}}
222+
// expected-note@-1 {{did you mean to use 'as!' to force downcast?}} {{16-18=as!}}
223+
let _ = objc as ManufacturerInfo<NSObject> // expected-error{{'APPManufacturerInfo<NSString>' is not convertible to 'ManufacturerInfo<NSObject>'}}
224+
// expected-note@-1 {{did you mean to use 'as!' to force downcast?}} {{16-18=as!}}
223225

224226
// Bridging to Objective-C
225227
let _ = swift as APPManufacturerInfo<NSString>
226-
let _ = swift as APPManufacturerInfo<NSNumber> // expected-error{{'ManufacturerInfo<NSString>' is not convertible to 'APPManufacturerInfo<NSNumber>'; did you mean to use 'as!' to force downcast?}}
227-
let _ = swift as APPManufacturerInfo<NSObject> // expected-error{{'ManufacturerInfo<NSString>' is not convertible to 'APPManufacturerInfo<NSObject>'; did you mean to use 'as!' to force downcast?}}
228+
let _ = swift as APPManufacturerInfo<NSNumber> // expected-error{{'ManufacturerInfo<NSString>' is not convertible to 'APPManufacturerInfo<NSNumber>'}}
229+
// expected-note@-1 {{did you mean to use 'as!' to force downcast?}} {{17-19=as!}}
230+
let _ = swift as APPManufacturerInfo<NSObject> // expected-error{{'ManufacturerInfo<NSString>' is not convertible to 'APPManufacturerInfo<NSObject>'}}
231+
// expected-note@-1 {{did you mean to use 'as!' to force downcast?}} {{17-19=as!}}
232+
228233
}

test/ClangImporter/objc_parse.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,10 +540,12 @@ func testStrangeSelectors(obj: StrangeSelectors) {
540540

541541
func testProtocolQualified(_ obj: CopyableNSObject, cell: CopyableSomeCell,
542542
plainObj: NSObject, plainCell: SomeCell) {
543-
_ = obj as NSObject // expected-error {{'CopyableNSObject' (aka 'NSCopying & NSObjectProtocol') is not convertible to 'NSObject'; did you mean to use 'as!' to force downcast?}} {{11-13=as!}}
543+
_ = obj as NSObject // expected-error {{'CopyableNSObject' (aka 'NSCopying & NSObjectProtocol') is not convertible to 'NSObject'}}
544+
// expected-note@-1 {{did you mean to use 'as!' to force downcast?}} {{11-13=as!}}
544545
_ = obj as NSObjectProtocol
545546
_ = obj as NSCopying
546-
_ = obj as SomeCell // expected-error {{'CopyableNSObject' (aka 'NSCopying & NSObjectProtocol') is not convertible to 'SomeCell'; did you mean to use 'as!' to force downcast?}} {{11-13=as!}}
547+
_ = obj as SomeCell // expected-error {{'CopyableNSObject' (aka 'NSCopying & NSObjectProtocol') is not convertible to 'SomeCell'}}
548+
// expected-note@-1 {{did you mean to use 'as!' to force downcast?}} {{11-13=as!}}
547549

548550
_ = cell as NSObject
549551
_ = cell as NSObjectProtocol

test/Constraints/ErrorBridging.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ var ns4 = compo as NSError
3737
ns4 = compo // expected-error{{cannot assign value of type 'HairyError & Runcible' to type 'NSError'}}
3838

3939
let e1 = ns1 as? FooError
40-
let e1fix = ns1 as FooError // expected-error{{did you mean to use 'as!'}} {{17-19=as!}}
40+
let e1fix = ns1 as FooError // expected-error {{'NSError' is not convertible to 'FooError'}}
41+
// expected-note@-1{{did you mean to use 'as!' to force downcast?}} {{17-19=as!}}
4142

4243
let esub = ns1 as Error
4344
let esub2 = ns1 as? Error // expected-warning{{conditional cast from 'NSError' to 'Error' always succeeds}}

test/Constraints/bridging-nsnumber-and-nsvalue.swift.gyb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,17 @@ func bridgeNSNumberBackToSpecificType(object: ${ObjectType},
5757
dictBoth: [${ObjectType}: ${ObjectType}],
5858
set: Set<${ObjectType}>) {
5959
% for Type in ValueTypes:
60-
_ = object as ${Type} // expected-error{{use 'as!'}}
60+
_ = object as ${Type} // expected-error{{is not convertible to}} expected-note {{use 'as!'}}
6161
_ = object is ${Type}
6262
_ = object as? ${Type}
6363
_ = object as! ${Type}
6464

65-
_ = optional as ${Type}? // expected-error{{use 'as!'}}
65+
_ = optional as ${Type}? // expected-error{{is not convertible to}} expected-note {{use 'as!'}}
6666
_ = optional is ${Type}?
6767
_ = optional as? ${Type}?
6868
_ = optional as! ${Type}?
6969

70-
_ = optional as ${Type} // expected-error{{use 'as!'}}
70+
_ = optional as ${Type} // expected-error{{is not convertible to}} expected-note {{use 'as!'}}
7171
_ = optional is ${Type}
7272
_ = optional as? ${Type}
7373
_ = optional as! ${Type}
@@ -82,7 +82,7 @@ func bridgeNSNumberBackToSpecificType(object: ${ObjectType},
8282
_ = dictKeys as? [${Type}: Any]
8383
_ = dictKeys as! [${Type}: Any]
8484

85-
_ = dictKeys as [${Type}: AnyObject] // expected-error{{use 'as!'}}
85+
_ = dictKeys as [${Type}: AnyObject] // expected-error{{is not convertible to}} expected-note {{use 'as!'}}
8686
_ = dictKeys is [${Type}: AnyObject]
8787
_ = dictKeys as? [${Type}: AnyObject]
8888
_ = dictKeys as! [${Type}: AnyObject]
@@ -92,7 +92,7 @@ func bridgeNSNumberBackToSpecificType(object: ${ObjectType},
9292
_ = dictValues as? [AnyHashable: ${Type}]
9393
_ = dictValues as! [AnyHashable: ${Type}]
9494

95-
_ = dictValues as [NSObject: ${Type}] // expected-error{{use 'as!'}}
95+
_ = dictValues as [NSObject: ${Type}] // expected-error{{is not convertible to}} expected-note {{use 'as!'}}
9696
_ = dictValues is [NSObject: ${Type}]
9797
_ = dictValues as? [NSObject: ${Type}]
9898
_ = dictValues as! [NSObject: ${Type}]
@@ -107,7 +107,7 @@ func bridgeNSNumberBackToSpecificType(object: ${ObjectType},
107107
_ = dictBoth as? [${Type}: ${ObjectType}]
108108
_ = dictBoth as! [${Type}: ${ObjectType}]
109109

110-
_ = dictBoth as [${Type}: ${Type}] // expected-error{{use 'as!'}}
110+
_ = dictBoth as [${Type}: ${Type}] // expected-error{{is not convertible to}} expected-note {{use 'as!'}}
111111
_ = dictBoth is [${Type}: ${Type}]
112112
_ = dictBoth as? [${Type}: ${Type}]
113113
_ = dictBoth as! [${Type}: ${Type}]

test/Constraints/bridging.swift

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,16 +124,24 @@ func arrayToNSArray() {
124124
// NSArray -> Array
125125
func nsArrayToArray(_ nsa: NSArray) {
126126
var arr1: [AnyObject] = nsa // expected-error{{'NSArray' is not implicitly convertible to '[AnyObject]'; did you mean to use 'as' to explicitly convert?}} {{30-30= as [AnyObject]}}
127-
var _: [BridgedClass] = nsa // expected-error{{'NSArray' is not convertible to '[BridgedClass]'}} {{30-30= as! [BridgedClass]}}
128-
var _: [OtherClass] = nsa // expected-error{{'NSArray' is not convertible to '[OtherClass]'}} {{28-28= as! [OtherClass]}}
129-
var _: [BridgedStruct] = nsa // expected-error{{'NSArray' is not convertible to '[BridgedStruct]'}} {{31-31= as! [BridgedStruct]}}
130-
var _: [NotBridgedStruct] = nsa // expected-error{{use 'as!' to force downcast}}
127+
var _: [BridgedClass] = nsa // expected-error{{'NSArray' is not convertible to '[BridgedClass]'}}
128+
// expected-note@-1{{did you mean to use 'as!' to force downcast?}} {{30-30= as! [BridgedClass]}}
129+
var _: [OtherClass] = nsa // expected-error{{'NSArray' is not convertible to '[OtherClass]'}}
130+
// expected-note@-1{{did you mean to use 'as!' to force downcast?}} {{28-28= as! [OtherClass]}}
131+
var _: [BridgedStruct] = nsa // expected-error{{'NSArray' is not convertible to '[BridgedStruct]'}}
132+
// expected-note@-1{{did you mean to use 'as!' to force downcast?}} {{31-31= as! [BridgedStruct]}}
133+
var _: [NotBridgedStruct] = nsa // expected-error{{'NSArray' is not convertible to '[NotBridgedStruct]'}}
134+
// expected-note@-1{{did you mean to use 'as!' to force downcast?}} {{34-34= as! [NotBridgedStruct]}}
131135

132136
var _: [AnyObject] = nsa as [AnyObject]
133-
var _: [BridgedClass] = nsa as [BridgedClass] // expected-error{{'NSArray' is not convertible to '[BridgedClass]'; did you mean to use 'as!' to force downcast?}} {{31-33=as!}}
134-
var _: [OtherClass] = nsa as [OtherClass] // expected-error{{'NSArray' is not convertible to '[OtherClass]'; did you mean to use 'as!' to force downcast?}} {{29-31=as!}}
135-
var _: [BridgedStruct] = nsa as [BridgedStruct] // expected-error{{'NSArray' is not convertible to '[BridgedStruct]'; did you mean to use 'as!' to force downcast?}} {{32-34=as!}}
136-
var _: [NotBridgedStruct] = nsa as [NotBridgedStruct] // expected-error{{use 'as!' to force downcast}}
137+
var _: [BridgedClass] = nsa as [BridgedClass] // expected-error{{'NSArray' is not convertible to '[BridgedClass]'}}
138+
// expected-note@-1{{did you mean to use 'as!' to force downcast?}} {{31-33=as!}}
139+
var _: [OtherClass] = nsa as [OtherClass] // expected-error{{'NSArray' is not convertible to '[OtherClass]'}}
140+
// expected-note@-1{{did you mean to use 'as!' to force downcast?}} {{29-31=as!}}
141+
var _: [BridgedStruct] = nsa as [BridgedStruct] // expected-error{{'NSArray' is not convertible to '[BridgedStruct]'}}
142+
// expected-note@-1{{did you mean to use 'as!' to force downcast?}} {{32-34=as!}}
143+
var _: [NotBridgedStruct] = nsa as [NotBridgedStruct] // expected-error{{'NSArray' is not convertible to '[NotBridgedStruct]'}}
144+
// expected-note@-1{{did you mean to use 'as!' to force downcast?}} {{35-37=as!}}
137145

138146
var arr6: Array = nsa as Array
139147
arr6 = arr1
@@ -211,7 +219,8 @@ func rdar18330319(_ s: String, d: [String : AnyObject]) {
211219
func rdar19551164a(_ s: String, _ a: [String]) {}
212220
func rdar19551164b(_ s: NSString, _ a: NSArray) {
213221
rdar19551164a(s, a) // expected-error{{'NSString' is not implicitly convertible to 'String'; did you mean to use 'as' to explicitly convert?}}{{18-18= as String}}
214-
// expected-error@-1{{'NSArray' is not convertible to '[String]'; did you mean to use 'as!' to force downcast?}}{{21-21= as! [String]}}
222+
// expected-error@-1{{'NSArray' is not convertible to '[String]'}}
223+
// expected-note@-2 {{did you mean to use 'as!' to force downcast?}}{{21-21= as! [String]}}
215224
}
216225

217226
// rdar://problem/19695671

test/Constraints/casts.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,13 @@ func test_coercions_with_overloaded_operator(str: String, optStr: String?, veryO
252252

253253
_ = (str ?? "") as Int // expected-error {{cannot convert value of type 'String' to type 'Int' in coercion}}
254254
_ = (optStr ?? "") as Int // expected-error {{cannot convert value of type 'String' to type 'Int' in coercion}}
255-
_ = (optStr ?? "") as Int? // expected-error {{'String' is not convertible to 'Int?'; did you mean to use 'as!' to force downcast?}}
255+
_ = (optStr ?? "") as Int? // expected-error {{'String' is not convertible to 'Int?'}}
256+
// expected-note@-1 {{did you mean to use 'as!' to force downcast?}} {{22-24=as!}}
256257

257258
_ = (str ^^^ "") as Int // expected-error {{cannot convert value of type 'String' to type 'Int' in coercion}}
258259
_ = (optStr ^^^ "") as Int // expected-error {{cannot convert value of type 'String' to type 'Int' in coercion}}
259-
_ = (optStr ^^^ "") as Int? // expected-error {{'String' is not convertible to 'Int?'; did you mean to use 'as!' to force downcast?}}
260+
_ = (optStr ^^^ "") as Int? // expected-error {{'String' is not convertible to 'Int?'}}
261+
// expected-note@-1 {{did you mean to use 'as!' to force downcast?}} {{23-25=as!}}
260262

261263
_ = ([] ?? []) as String // expected-error {{cannot convert value of type '[Any]' to type 'String' in coercion}}
262264
_ = ([""] ?? []) as [Int: Int] // expected-error {{cannot convert value of type '[String]' to type '[Int : Int]' in coercion}}
@@ -290,7 +292,8 @@ func test_compatibility_coercions(_ arr: [Int], _ optArr: [Int]?, _ dict: [Strin
290292
// expected-note@-1 {{arguments to generic parameter 'Element' ('Int' and 'String') are expected to be equal}}
291293
_ = dict as [String: String] // expected-error {{cannot convert value of type '[String : Int]' to type '[String : String]' in coercion}}
292294
// expected-note@-1 {{arguments to generic parameter 'Value' ('Int' and 'String') are expected to be equal}}
293-
_ = dict as [String: String]? // expected-error {{'[String : Int]' is not convertible to '[String : String]?'; did you mean to use 'as!' to force downcast?}}
295+
_ = dict as [String: String]? // expected-error {{'[String : Int]' is not convertible to '[String : String]?'}}
296+
// expected-note@-1 {{did you mean to use 'as!' to force downcast?}} {{12-14=as!}}
294297
_ = (dict as [String: Int]?) as [String: Int] // expected-error {{value of optional type '[String : Int]?' must be unwrapped to a value of type '[String : Int]'}}
295298
// expected-note@-1 {{coalesce using '??' to provide a default when the optional value contains 'nil'}}
296299
// expected-note@-2 {{force-unwrap using '!' to abort execution if the optional value contains 'nil'}}

test/Constraints/casts_objc.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ func optionalityMismatchingCasts(f: CGFloat, n: NSNumber, fooo: CGFloat???,
8181
nooo: NSNumber???) {
8282
_ = f as NSNumber?
8383
_ = f as NSNumber??
84-
let _ = fooo as NSNumber?? // expected-error{{'CGFloat???' is not convertible to 'NSNumber??'; did you mean to use 'as!' to force downcast?}}
84+
let _ = fooo as NSNumber?? // expected-error{{'CGFloat???' is not convertible to 'NSNumber??'}}
85+
//expected-note@-1 {{did you mean to use 'as!' to force downcast?}} {{16-18=as!}}
8586
let _ = fooo as NSNumber???? // okay: injects extra optionals
8687
}
8788

test/Constraints/fixes.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ func forgotOptionalBang(_ a: A, obj: AnyObject) {
7777

7878
func forgotAnyObjectBang(_ obj: AnyObject) {
7979
var a = A()
80-
a = obj // expected-error{{'AnyObject' is not convertible to 'A'; did you mean to use 'as!' to force downcast?}}{{10-10= as! A}}
80+
a = obj // expected-error{{'AnyObject' is not convertible to 'A'}}
81+
//expected-note@-1 {{did you mean to use 'as!' to force downcast?}} {{10-10= as! A}}
8182
_ = a
8283
}
8384

test/Constraints/rdar45511837.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ class Foo<Bar: NSObject> {
1818

1919
lazy var foo: () -> Void = {
2020
// TODO: improve diagnostic message
21-
_ = self.foobar + nil // expected-error {{'Bar' is not convertible to 'String'; did you mean to use 'as!' to force downcast?}}
22-
// expected-error@-1 {{'nil' is not compatible with expected argument type 'String'}}
21+
_ = self.foobar + nil // expected-error {{'Bar' is not convertible to 'String'}}
22+
// expected-note@-1 {{did you mean to use 'as!' to force downcast?}}
23+
// expected-error@-2 {{'nil' is not compatible with expected argument type 'String'}}
2324
}
2425
}

test/Parse/try.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,8 @@ let _: Int = try? foo() // expected-error {{value of optional type 'Int?' not un
182182
class X {}
183183
func test(_: X) {}
184184
func producesObject() throws -> AnyObject { return X() }
185-
test(try producesObject()) // expected-error {{'AnyObject' is not convertible to 'X'; did you mean to use 'as!' to force downcast?}} {{26-26= as! X}}
185+
test(try producesObject()) // expected-error {{'AnyObject' is not convertible to 'X'}}
186+
// expected-note@-1{{did you mean to use 'as!' to force downcast?}} {{26-26= as! X}}
186187

187188
_ = "a\(try maybeThrow())b"
188189
_ = try "a\(maybeThrow())b"

test/Parse/try_swift5.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ let _: Int = try? foo() // expected-error {{value of optional type 'Int?' not un
183183
class X {}
184184
func test(_: X) {}
185185
func producesObject() throws -> AnyObject { return X() }
186-
test(try producesObject()) // expected-error {{'AnyObject' is not convertible to 'X'; did you mean to use 'as!' to force downcast?}} {{26-26= as! X}}
186+
test(try producesObject()) // expected-error {{'AnyObject' is not convertible to 'X'}}
187+
// expected-note@-1{{did you mean to use 'as!' to force downcast?}} {{26-26= as! X}}
187188

188189
_ = "a\(try maybeThrow())b"
189190
_ = try "a\(maybeThrow())b"

test/decl/func/dynamic_self.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ class C1 {
8585
var x: Int = self // expected-error{{cannot convert value of type 'Self.Type' to specified type 'Int'}}
8686

8787
// Can't utter Self within the body of a method.
88-
var c1 = C1(int: 5) as Self // expected-error{{'C1' is not convertible to 'Self'; did you mean to use 'as!' to force downcast?}}
88+
var c1 = C1(int: 5) as Self // expected-error{{'C1' is not convertible to 'Self'}}
89+
// expected-note@-1{{did you mean to use 'as!' to force downcast?}} {{25-27=as!}}
8990

9091
if b { return self.init(int: 5) }
9192

test/decl/nested/type_in_function.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ class OuterGenericClass<T> {
9898
func f5<T, U>(x: T, y: U) {
9999
struct Local { // expected-error {{type 'Local' cannot be nested in generic function 'f5(x:y:)'}}
100100
func f() {
101-
_ = 17 as T // expected-error{{'Int' is not convertible to 'T'}} {{14-16=as!}}
101+
_ = 17 as T // expected-error{{'Int' is not convertible to 'T'}}
102+
// expected-note@-1{{did you mean to use 'as!' to force downcast?}} {{14-16=as!}}
102103
_ = 17 as U // okay: refers to 'U' declared within the local class
103104
}
104105
typealias U = Int

test/expr/cast/as_coerce.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,15 @@ var c: AnyObject = C3()
7272
//if let castX = c as! C4? {}
7373

7474
// XXX TODO: Only suggest replacing 'as' with 'as!' if it would fix the error.
75-
C3() as C4 // expected-error {{'C3' is not convertible to 'C4'; did you mean to use 'as!' to force downcast?}} {{6-8=as!}}
75+
C3() as C4 // expected-error {{'C3' is not convertible to 'C4'}}
76+
// expected-note@-1 {{did you mean to use 'as!' to force downcast?}} {{6-8=as!}}
7677
C3() as C5 // expected-error {{cannot convert value of type 'C3' to type 'C5' in coercion}}
7778

7879
// Diagnostic shouldn't include @lvalue in type of c3.
7980
var c3 = C3()
8081
// XXX TODO: This should not suggest `as!`
81-
c3 as C4 // expected-error {{'C3' is not convertible to 'C4'; did you mean to use 'as!' to force downcast?}} {{4-6=as!}}
82+
c3 as C4 // expected-error {{'C3' is not convertible to 'C4'}}
83+
// expected-note@-1{{did you mean to use 'as!' to force downcast?}} {{4-6=as!}}
8284

8385
// <rdar://problem/19495142> Various incorrect diagnostics for explicit type conversions
8486
1 as Double as Float // expected-error{{cannot convert value of type 'Double' to type 'Float' in coercion}}
@@ -102,12 +104,14 @@ _ = "hello" as! String // expected-warning{{forced cast of 'String' to same type
102104

103105
// <rdar://problem/19499340> QoI: Nimble as -> as! changes not covered by Fix-Its
104106
func f(_ x : String) {}
105-
f("what" as Any as String) // expected-error {{'Any' is not convertible to 'String'; did you mean to use 'as!' to force downcast?}} {{17-19=as!}}
107+
f("what" as Any as String) // expected-error {{'Any' is not convertible to 'String'}}
108+
// expected-note@-1{{did you mean to use 'as!' to force downcast?}} {{17-19=as!}}
106109
f(1 as String) // expected-error{{cannot convert value of type 'Int' to type 'String' in coercion}}
107110

108111
// <rdar://problem/19650402> Swift compiler segfaults while running the annotation tests
109112
let s : AnyObject = C3()
110-
s as C3 // expected-error{{'AnyObject' is not convertible to 'C3'; did you mean to use 'as!' to force downcast?}} {{3-5=as!}}
113+
s as C3 // expected-error{{'AnyObject' is not convertible to 'C3'}}
114+
// expected-note@-1{{did you mean to use 'as!' to force downcast?}} {{3-5=as!}}
111115

112116
// SR-6022
113117
func sr6022() -> Any { return 0 }

0 commit comments

Comments
 (0)