Skip to content

Commit bdf8502

Browse files
[tests] Fixing tests under test/Sema and test/decl
1 parent 64f707e commit bdf8502

File tree

7 files changed

+17
-17
lines changed

7 files changed

+17
-17
lines changed

test/Sema/diag_unintended_optional_behavior.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ func warnOptionalInStringInterpolationSegment(_ o : Int?) {
212212
// expected-note@-2 {{use 'String(describing:)' to silence this warning}} {{51-51=String(describing: }} {{67-67=)}}
213213
// expected-note@-3 {{provide a default value to avoid this warning}} {{67-67= ?? <#default value#>}}
214214

215-
print("Always some, Always some, Always some: \(o as Int?)") // No warning
215+
print("Always some, Always some, Always some: \(o as Int?)") // expected-warning {{redundant cast to 'Int?' has no effect}} {{53-60=}}
216216
print("Always some, Always some, Always some: \(o.debugDescription)") // No warning.
217217

218218
let oST = Optional(SpecialType())

test/Sema/diag_unowned_immediate_deallocation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-typecheck-verify-swift -module-name ModuleName
1+
// RUN: %target-typecheck-verify-swift -module-name ModuleName -disable-redundant-coercion-warning
22

33
protocol ClassProtocol : class {
44
init()

test/Sema/suppress-argument-labels-in-types.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,18 +207,18 @@ let _ = min(Int(3), Float(2.5)) // expected-error{{cannot convert value of type
207207

208208
// SR-11429
209209
func testIntermediateCoercions() {
210-
_ = (f1 as (Int, Int) -> Int)(a: 0, b: 1) // expected-error {{extraneous argument labels 'a:b:' in call}}
211-
_ = (f1 as (Int, Int) -> Int)(0, 1)
210+
_ = (f1 as (Int, Int) -> Int)(a: 0, b: 1) // expected-error {{extraneous argument labels 'a:b:' in call}} expected-warning {{redundant cast to '(Int, Int) -> Int' has no effect}}
211+
_ = (f1 as (Int, Int) -> Int)(0, 1) // expected-warning {{redundant cast to '(Int, Int) -> Int' has no effect}}
212212

213213
typealias Magic<T> = T
214-
_ = (f1 as Magic)(a: 0, b: 1) // expected-error {{extraneous argument labels 'a:b:' in call}}
215-
_ = (f1 as Magic)(0, 1)
214+
_ = (f1 as Magic)(a: 0, b: 1) // expected-error {{extraneous argument labels 'a:b:' in call}} expected-warning {{redundant cast to 'Magic' has no effect}} {{11-19=}}
215+
_ = (f1 as Magic)(0, 1) // expected-warning {{redundant cast to 'Magic' has no effect}} {{11-19=}}
216216

217217
_ = (f4 as (Int, Int) -> Int)(0, 0)
218218
_ = (f4 as (Double, Double) -> Double)(0, 0)
219219

220220
func iuoReturning() -> Int! {}
221-
_ = (iuoReturning as () -> Int?)()
222-
_ = (iuoReturning as Magic)()
221+
_ = (iuoReturning as () -> Int?)() // expected-warning {{redundant cast to '() -> Int?' has no effect}}
222+
_ = (iuoReturning as Magic)() // expected-warning {{redundant cast to 'Magic' has no effect}} {{21-29=}}
223223
_ = (iuoReturning as () -> Int)() // expected-error {{cannot convert value of type '() -> Int?' to type '() -> Int' in coercion}}
224224
}

test/decl/class/classes.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ extension A {
4343
}
4444
func f() {
4545
let x = B()
46-
_ = x.f() as ()
47-
_ = x[10] as Int
46+
_ = x.f() as () // expected-warning {{redundant cast to '()' has no effect}} {{13-19=}}
47+
_ = x[10] as Int // expected-warning {{redundant cast to 'Int' has no effect}} {{13-20=}}
4848
}
4949

5050
class C<T> {

test/decl/protocol/protocols.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ struct Circle {
118118
func testCircular(_ circle: Circle) {
119119
// FIXME: It would be nice if this failure were suppressed because the protocols
120120
// have circular definitions.
121-
_ = circle as CircleStart // expected-error{{'Circle' is not convertible to 'CircleStart'; did you mean to use 'as!' to force downcast?}} {{14-16=as!}}
121+
_ = circle as CircleStart // expected-error{{value of type 'Circle' does not conform to 'CircleStart' in coercion}}
122122
}
123123

124124
// <rdar://problem/14750346>
@@ -482,7 +482,7 @@ func f<T : C1>(_ x : T) {
482482

483483
class C2 {}
484484
func g<T : C2>(_ x : T) {
485-
x as P2 // expected-error{{'T' is not convertible to 'P2'; did you mean to use 'as!' to force downcast?}} {{5-7=as!}}
485+
x as P2 // expected-error {{value of type 'T' does not conform to 'P2' in coercion}}
486486
}
487487

488488
class C3 : P1 {} // expected-error{{type 'C3' does not conform to protocol 'P1'}}

test/decl/protocol/req/optional.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func optionalPropertyGeneric<T : P1>(_ t: T) {
144144

145145
// ... and that we can use it
146146
let i = propertyRef!
147-
_ = i as Int
147+
_ = i as Int // expected-warning {{redundant cast to 'Int' has no effect}} {{9-16=}}
148148
}
149149

150150
// Optional subscript references in generics.
@@ -157,7 +157,7 @@ func optionalSubscriptGeneric<T : P1>(_ t: T) {
157157

158158
// ... and that we can use it
159159
let i = subscriptRef!
160-
_ = i as ObjCClass?
160+
_ = i as ObjCClass? // expected-warning {{redundant cast to 'ObjCClass?' has no effect}} {{9-23=}}
161161
}
162162

163163
// Optional method references in existentials.
@@ -182,7 +182,7 @@ func optionalPropertyExistential(_ t: P1) {
182182

183183
// ... and that we can use it
184184
let i = propertyRef!
185-
_ = i as Int
185+
_ = i as Int // expected-warning {{redundant cast to 'Int' has no effect}} {{9-16=}}
186186
}
187187

188188
// Optional subscript references in existentials.
@@ -195,7 +195,7 @@ func optionalSubscriptExistential(_ t: P1) {
195195

196196
// ... and that we can use it
197197
let i = subscriptRef!
198-
_ = i as ObjCClass?
198+
_ = i as ObjCClass? // expected-warning {{redundant cast to 'ObjCClass?' has no effect}} {{9-23=}}
199199
}
200200

201201
// -----------------------------------------------------------------------

test/decl/var/variables.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ var arrayOfEmptyTuples = [""].map { print($0) } // expected-warning {{variable '
6767
var maybeEmpty = Optional(arrayOfEmptyTuples) // expected-warning {{variable 'maybeEmpty' inferred to have type '[()]?'}} \
6868
// expected-note {{add an explicit type annotation to silence this warning}} {{15-15=: [()]?}}
6969

70-
var shouldWarnWithoutSugar = (arrayOfEmptyTuples as Array<()>) // expected-warning {{variable 'shouldWarnWithoutSugar' inferred to have type 'Array<()>'}} \
70+
var shouldWarnWithoutSugar = (arrayOfEmptyTuples as Array<()>) // expected-warning {{redundant cast to 'Array<()>' has no effect}} {{50-62=}} expected-warning {{variable 'shouldWarnWithoutSugar' inferred to have type 'Array<()>'}} \
7171
// expected-note {{add an explicit type annotation to silence this warning}} {{27-27=: Array<()>}}
7272

7373
class SomeClass {}

0 commit comments

Comments
 (0)