Skip to content

Commit 6f58cd6

Browse files
committed
Gardening: Migrate test suite to GH issues: stmt
1 parent 04f1cde commit 6f58cd6

File tree

5 files changed

+67
-77
lines changed

5 files changed

+67
-77
lines changed

test/stmt/errors.swift

Lines changed: 55 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -174,95 +174,79 @@ func thirteen() {
174174
}
175175
}
176176

177-
// SR 6400
178-
179-
enum SR_6400_E: Error {
180-
case castError
181-
}
177+
// https://github.com/apple/swift/issues/48950
178+
protocol ClassProto: AnyObject {}
179+
do {
180+
enum E: Error {
181+
case castError
182+
}
182183

183-
struct SR_6400_S_1 {}
184-
struct SR_6400_S_2: Error {}
184+
do {
185+
struct S1 {}
186+
struct S2: Error {}
185187

186-
protocol SR_6400_FakeApplicationDelegate: AnyObject {}
187-
class SR_6400_FakeViewController {}
188+
do {
189+
throw E.castError
190+
} catch is S1 {} // expected-warning {{cast from 'any Error' to unrelated type 'S1' always fails}}
188191

189-
func sr_6400() throws {
190-
do {
191-
throw SR_6400_E.castError
192-
} catch is SR_6400_S_1 { // expected-warning {{cast from 'any Error' to unrelated type 'SR_6400_S_1' always fails}}
193-
print("Caught error")
194-
}
195-
196-
do {
197-
throw SR_6400_E.castError
198-
} catch is SR_6400_S_2 {
199-
print("Caught error") // Ok
192+
do {
193+
throw E.castError
194+
} catch is S2 {} // Ok
200195
}
201-
}
202196

203-
func sr_6400_1<T>(error: Error, as type: T.Type) -> Bool {
204-
return (error as? T) != nil // Ok
205-
}
206-
207-
func sr_6400_2(error: Error) {
208-
_ = error as? (SR_6400_FakeViewController & Error) // Ok
209-
}
210-
func sr_6400_3(error: Error) {
211-
_ = error as? (Error & SR_6400_FakeApplicationDelegate) // Ok
212-
}
197+
do {
198+
class C1 {}
199+
class C2: ClassProto & Error {}
213200

214-
class SR_6400_A {}
215-
class SR_6400_B: SR_6400_FakeApplicationDelegate & Error {}
201+
do {
202+
throw E.castError
203+
} catch let error as C1 { // Okay
204+
print(error)
205+
} catch {}
216206

217-
func sr_6400_4() {
218-
do {
219-
throw SR_6400_E.castError
220-
} catch let error as SR_6400_A { // Okay
221-
print(error)
222-
} catch {
223-
print("Bar")
207+
do {
208+
throw E.castError
209+
} catch let error as C2 { // Okay
210+
print(error)
211+
} catch {}
212+
213+
let err: Error
214+
_ = err as? (C1 & Error) // Ok
215+
_ = err as? (Error & ClassProto) // Ok
224216
}
225-
226-
do {
227-
throw SR_6400_E.castError
228-
} catch let error as SR_6400_B { // Okay
229-
print(error)
230-
} catch {
231-
print("Bar")
217+
218+
func f<T>(error: Error, as type: T.Type) -> Bool {
219+
return (error as? T) != nil // Ok
232220
}
233221
}
234222

235-
// SR-11402
223+
// https://github.com/apple/swift/issues/53803
224+
protocol P {}
225+
do {
226+
class Super {}
227+
class Sub: Super, P {}
228+
final class Final {}
236229

237-
protocol SR_11402_P {}
238-
class SR_11402_Superclass {}
239-
class SR_11402_Subclass: SR_11402_Superclass, SR_11402_P {}
230+
let x: any P
240231

241-
func sr_11402_func1(_ x: SR_11402_P) {
242-
if let y = x as? SR_11402_Superclass { // Okay
243-
print(y)
244-
}
245-
}
246-
247-
final class SR_11402_Final {}
232+
if let _ = x as? Super {} // Okay
248233

249-
func sr_11402_func2(_ x: SR_11402_P) {
250-
if let y = x as? SR_11402_Final { // expected-warning {{cast from 'any SR_11402_P' to unrelated type 'SR_11402_Final' always fails}}
251-
print(y)
252-
}
234+
if let _ = x as? Final {} // expected-warning {{cast from 'any P' to unrelated type 'Final' always fails}}
253235
}
254236

255-
// https://bugs.swift.org/browse/SR-13654
237+
// https://github.com/apple/swift/issues/56091
238+
do {
239+
func f() throws -> String {}
256240

257-
func sr_13654_func() throws -> String {}
241+
func invalid_interpolation() {
242+
_ = try "\(f())" // expected-error {{errors thrown from here are not handled}}
243+
_ = "\(try f())" // expected-error {{errors thrown from here are not handled}}
244+
}
258245

259-
func sr_13654_invalid_interpolation() {
260-
_ = try "\(sr_13654_func())" // expected-error {{errors thrown from here are not handled}}
261-
_ = "\(try sr_13654_func())" // expected-error {{errors thrown from here are not handled}}
262-
}
263-
func sr_13654_valid_interpolation() throws {
264-
_ = try "\(sr_13654_func())"
265-
_ = "\(try sr_13654_func())"
246+
func valid_interpolation() throws {
247+
_ = try "\(f())"
248+
_ = "\(try f())"
249+
}
266250
}
267251

268252
// rdar://problem/72748150

test/stmt/foreach.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,12 @@ func testRepeated(ri: RepeatedSequence<Int>) {
227227
for x in ri { _ = x }
228228
}
229229

230-
// SR-12398: Poor pattern matching diagnostic: "for-in loop requires '[Int]' to conform to 'Sequence'"
231-
func sr_12398(arr1: [Int], arr2: [(a: Int, b: String)]) {
230+
// https://github.com/apple/swift/issues/54836
231+
// Poor pattern matching diagnostic: for-in loop requires '[Int]' to conform to 'Sequence'
232+
do {
233+
let arr1: [Int]
234+
let arr2: [(a: Int, b: String)]
235+
232236
for (x, y) in arr1 {}
233237
// expected-error@-1 {{tuple pattern cannot match values of non-tuple type 'Int'}}
234238

@@ -245,7 +249,8 @@ func testForEachWhereWithClosure(_ x: [Int]) {
245249
for i in x where x.contains(where: { $0.byteSwapped == i }) {}
246250
}
247251

248-
// https://github.com/apple/swift/issues/59522 - use of `prefix` with generic base causes ambiguity in for-in statement
252+
// https://github.com/apple/swift/issues/59522
253+
// Use of 'prefix' with generic base causes ambiguity in for-in statement
249254
func test_no_ambiguity_with_prefix_iterator<C: Collection>(c: C) {
250255
for _ in c.prefix(1) { // Ok
251256
}

test/stmt/if_while_var.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,8 @@ class UsesPayload {
291291
}
292292
}
293293

294-
func sr_13258() {
294+
// https://github.com/apple/swift/issues/55698
295+
do {
295296
let a = 1
296297
let b = Int?.none
297298
if let c = b ?? a { _ = c } // expected-error {{initializer for conditional binding must have Optional type, not 'Int'}}

test/stmt/statements.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ func test_guard(_ x : Int, y : Int??, z: Int?, cond : Bool) {
381381

382382
guard case _ = x else {} // expected-warning {{'guard' condition is always true, body is unreachable}}
383383

384-
// SR-7567
384+
// https://github.com/apple/swift/issues/50109
385385
guard let outer = y else {
386386
// FIXME: Bring back the tailored diagnostic
387387
guard true else {

test/stmt/yield.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ struct YieldInDefer {
9393
}
9494
}
9595

96-
// SR-15066
96+
// https://github.com/apple/swift/issues/57393
9797
struct InvalidYieldParsing {
9898
var property: String {
9999
_read {

0 commit comments

Comments
 (0)