Skip to content

Gardening: Migrate test suite to GH issues p. 12 #60812

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions test/Demangle/rdar-82252704.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// rdar://82252704 - [SR-15070]: Declaring a class inside a async throws
// function crashes compiler
// rdar://82252704
// https://github.com/apple/swift/issues/57396
// Declaring a class inside a 'async throws' function crashes compiler

// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend -c %s -o %t/test.o
Expand Down
3 changes: 2 additions & 1 deletion test/Driver/bad_tmpdir.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
//
// REQUIRES: OS=macosx

// SR-12362: This test is failing on next branch.
// (https://github.com/apple/swift/issues/54796) This test is failing on
// next branch.
// XFAIL: *

// RUN: env TMP="%t/fake/" TMPDIR="%t/fake/" not %target-build-swift -c -driver-filelist-threshold=0 %s 2>&1 | %FileCheck -check-prefix=CHECK-SOURCES %s
Expand Down
4 changes: 3 additions & 1 deletion test/Driver/vfs.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// Verifies that the driver passes the -vfsoverlay flag to the frontend (SR-12834).
// https://github.com/apple/swift/issues/55280

// Verifies that the driver passes the -vfsoverlay flag to the frontend.
// RUN: %swiftc_driver -driver-print-jobs -c -vfsoverlay overlay.yaml %s | %FileCheck --check-prefix=CHECK-ONE %s

// CHECK-ONE: bin{{/|\\\\}}swift{{(-frontend|c)?(\.exe)?"?}} -frontend{{.*}}-c{{.*}}-vfsoverlay overlay.yaml
Expand Down
67 changes: 36 additions & 31 deletions test/expr/cast/as_coerce.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,40 +113,45 @@ let s : AnyObject = C3()
s as C3 // expected-error{{'AnyObject' is not convertible to 'C3'}}
// expected-note@-1{{did you mean to use 'as!' to force downcast?}} {{3-5=as!}}

// SR-6022
func sr6022() -> Any { return 0 }
func sr6022_1() { return; }
protocol SR6022_P {}

_ = sr6022 is SR6022_P // expected-warning {{cast from '() -> Any' to unrelated type 'any SR6022_P' always fails}} // expected-note {{did you mean to call 'sr6022' with '()'?}}{{11-11=()}}
_ = sr6022 as! SR6022_P // expected-warning {{cast from '() -> Any' to unrelated type 'any SR6022_P' always fails}} // expected-note {{did you mean to call 'sr6022' with '()'?}}{{11-11=()}}
_ = sr6022 as? SR6022_P // expected-warning {{cast from '() -> Any' to unrelated type 'any SR6022_P' always fails}} // expected-note {{did you mean to call 'sr6022' with '()'}}{{11-11=()}}
_ = sr6022_1 is SR6022_P // expected-warning {{cast from '() -> ()' to unrelated type 'any SR6022_P' always fails}}
_ = sr6022_1 as! SR6022_P // expected-warning {{cast from '() -> ()' to unrelated type 'any SR6022_P' always fails}}
_ = sr6022_1 as? SR6022_P // expected-warning {{cast from '() -> ()' to unrelated type 'any SR6022_P' always fails}}

func testSR6022_P<T: SR6022_P>(_: T.Type) {
_ = sr6022 is T // expected-warning {{cast from '() -> Any' to unrelated type 'T' always fails}} // expected-note {{did you mean to call 'sr6022' with '()'?}}{{13-13=()}}
_ = sr6022 as! T // expected-warning {{cast from '() -> Any' to unrelated type 'T' always fails}} // expected-note {{did you mean to call 'sr6022' with '()'?}}{{13-13=()}}
_ = sr6022 as? T // expected-warning {{cast from '() -> Any' to unrelated type 'T' always fails}} // expected-note {{did you mean to call 'sr6022' with '()'?}}{{13-13=()}}
_ = sr6022_1 is T // expected-warning {{cast from '() -> ()' to unrelated type 'T' always fails}}
_ = sr6022_1 as! T // expected-warning {{cast from '() -> ()' to unrelated type 'T' always fails}}
_ = sr6022_1 as? T // expected-warning {{cast from '() -> ()' to unrelated type 'T' always fails}}
// https://github.com/apple/swift/issues/48579

protocol P_48579 {}
do {
func f1() -> Any {}
func f2() {}

_ = f1 is P_48579 // expected-warning {{cast from '() -> Any' to unrelated type 'any P_48579' always fails}} // expected-note {{did you mean to call 'f1' with '()'?}}{{9-9=()}}
_ = f1 as! P_48579 // expected-warning {{cast from '() -> Any' to unrelated type 'any P_48579' always fails}} // expected-note {{did you mean to call 'f1' with '()'?}}{{9-9=()}}
_ = f1 as? P_48579 // expected-warning {{cast from '() -> Any' to unrelated type 'any P_48579' always fails}} // expected-note {{did you mean to call 'f1' with '()'}}{{9-9=()}}
_ = f2 is P_48579 // expected-warning {{cast from '() -> ()' to unrelated type 'any P_48579' always fails}}
_ = f2 as! P_48579 // expected-warning {{cast from '() -> ()' to unrelated type 'any P_48579' always fails}}
_ = f2 as? P_48579 // expected-warning {{cast from '() -> ()' to unrelated type 'any P_48579' always fails}}

_ = f1 as! AnyObject // expected-warning {{forced cast from '() -> Any' to 'AnyObject' always succeeds; did you mean to use 'as'?}}
_ = f1 as? AnyObject // expected-warning {{conditional cast from '() -> Any' to 'AnyObject' always succeeds}}
_ = f2 as! Any // expected-warning {{forced cast from '() -> ()' to 'Any' always succeeds; did you mean to use 'as'?}}
_ = f2 as? Any // expected-warning {{conditional cast from '() -> ()' to 'Any' always succeeds}}


func test1<T: P_48579>(_: T.Type) {
_ = f1 is T // expected-warning {{cast from '() -> Any' to unrelated type 'T' always fails}} // expected-note {{did you mean to call 'f1' with '()'?}}{{11-11=()}}
_ = f1 as! T // expected-warning {{cast from '() -> Any' to unrelated type 'T' always fails}} // expected-note {{did you mean to call 'f1' with '()'?}}{{11-11=()}}
_ = f1 as? T // expected-warning {{cast from '() -> Any' to unrelated type 'T' always fails}} // expected-note {{did you mean to call 'f1' with '()'?}}{{11-11=()}}
_ = f2 is T // expected-warning {{cast from '() -> ()' to unrelated type 'T' always fails}}
_ = f2 as! T // expected-warning {{cast from '() -> ()' to unrelated type 'T' always fails}}
_ = f2 as? T // expected-warning {{cast from '() -> ()' to unrelated type 'T' always fails}}
}

func test2<U>(_: U.Type) {
_ = f1 as! U // Okay
_ = f1 as? U // Okay
_ = f2 as! U // Okay
_ = f2 as? U // Okay
}
}

func testSR6022_P_1<U>(_: U.Type) {
_ = sr6022 as! U // Okay
_ = sr6022 as? U // Okay
_ = sr6022_1 as! U // Okay
_ = sr6022_1 as? U // Okay
}

_ = sr6022 as! AnyObject // expected-warning {{forced cast from '() -> Any' to 'AnyObject' always succeeds; did you mean to use 'as'?}}
_ = sr6022 as? AnyObject // expected-warning {{conditional cast from '() -> Any' to 'AnyObject' always succeeds}}
_ = sr6022_1 as! Any // expected-warning {{forced cast from '() -> ()' to 'Any' always succeeds; did you mean to use 'as'?}}
_ = sr6022_1 as? Any // expected-warning {{conditional cast from '() -> ()' to 'Any' always succeeds}}
// https://github.com/apple/swift/issues/56297

// SR-13899
let any: Any = 1
if let int = any as Int { // expected-error {{'Any' is not convertible to 'Int'}}
// expected-note@-1 {{did you mean to use 'as?' to conditionally downcast?}} {{18-20=as?}}
Expand Down
12 changes: 7 additions & 5 deletions test/expr/cast/metatype_casts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ use(C.self as P.Type) // expected-error{{cannot convert value of type 'C.Type' t
use(E.self as P.Protocol) // expected-error{{cannot convert value of type 'E.Type' to type '(any P).Type' in coercion}}
use(E.self as P.Type)

// SR-12946
func SR12946<T>(_ e: T) {
_ = AnyObject.self is T.Type // OK
}
// https://github.com/apple/swift/issues/55392
do {
func f<T>(_ e: T) {
_ = AnyObject.self is T.Type // OK
}

SR12946(1 as AnyObject)
f(1 as AnyObject)
}
2 changes: 1 addition & 1 deletion test/expr/cast/optional.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func implicitCastOfLiteralToOptional() {
}

// A nil value can be cast to any other optional type.
// https://bugs.swift.org/browse/SR-3505
// https://github.com/apple/swift/issues/46093
func castUnrelatedOptionalTypes(x: Int?) {
let _ = x as String? // expected-error {{cannot convert value}}
let _ = x as? String? // no-warning
Expand Down
88 changes: 44 additions & 44 deletions test/expr/closure/closures.swift
Original file line number Diff line number Diff line change
Expand Up @@ -513,26 +513,24 @@ let closure = {
return helper
}

// SR-9839
func SR9839(_ x: @escaping @convention(block) () -> Void) {}
// https://github.com/apple/swift/issues/52253
do {
func f(_: @escaping @convention(block) () -> Void) {}

func id<T>(_ x: T) -> T {
return x
}
func id<T>(_: T) -> T {}

var qux: () -> Void = {}
let qux: () -> Void

SR9839(qux)
SR9839(id(qux)) // expected-error {{conflicting arguments to generic parameter 'T' ('() -> Void' vs. '@convention(block) () -> Void')}}
f(qux)
f(id(qux)) // expected-error {{conflicting arguments to generic parameter 'T' ('() -> Void' vs. '@convention(block) () -> Void')}}

func forceUnwrap<T>(_ x: T?) -> T {
return x!
}
func forceUnwrap<T>(_: T?) -> T {}

var qux1: (() -> Void)? = {}
let qux1: (() -> Void)?

SR9839(qux1!)
SR9839(forceUnwrap(qux1))
f(qux1!)
f(forceUnwrap(qux1))
}

// rdar://problem/65155671 - crash referencing parameter of outer closure
func rdar65155671(x: Int) {
Expand All @@ -541,21 +539,22 @@ func rdar65155671(x: Int) {
}(x)
}

func sr3186<T, U>(_ f: (@escaping (@escaping (T) -> U) -> ((T) -> U))) -> ((T) -> U) {
return { x in return f(sr3186(f))(x) }
}
// https://github.com/apple/swift/issues/45774
do {
func f<T, U>(_: (@escaping (@escaping (T) -> U) -> ((T) -> U))) -> ((T) -> U) {}

class SR3186 {
init() {
// expected-warning@+1{{capture 'self' was never used}}
let v = sr3186 { f in { [unowned self, f] x in x != 1000 ? f(x + 1) : "success" } }(0)
print("\(v)")
class C {
init() {
// expected-warning@+1{{capture 'self' was never used}}
let _ = f { fn in { [unowned self, fn] x in x != 1000 ? fn(x + 1) : "success" } }(0)
}
}
}

// https://github.com/apple/swift/issues/56501
// Apply the explicit 'self' rule even if it refers to a capture, if
// we're inside a nested closure
class SR14120 {
// we're inside a nested closure.
class C_56501 {
func operation() {}

func test1() {
Expand Down Expand Up @@ -613,24 +612,25 @@ class SR14120 {
}
}

// SR-14678
func call<T>(_ : Int, _ f: () -> (T, Int)) -> (T, Int) {
f()
}
// https://github.com/apple/swift/issues/57029
do {
func call<T>(_ : Int, _ f: () -> (T, Int)) -> (T, Int) {}

func testSR14678() -> (Int, Int) {
call(1) { // expected-error {{cannot convert return expression of type '((), Int)' to return type '(Int, Int)'}}
(print("hello"), 0)
func f() -> (Int, Int) {
call(1) { // expected-error {{cannot convert return expression of type '((), Int)' to return type '(Int, Int)'}}
((), 0)
}
}
}

func testSR14678_Optional() -> (Int, Int)? {
call(1) { // expected-error {{cannot convert return expression of type '((), Int)' to return type '(Int, Int)'}}
(print("hello"), 0)
func f_Optional() -> (Int, Int)? {
call(1) { // expected-error {{cannot convert return expression of type '((), Int)' to return type '(Int, Int)'}}
((), 0)
}
}
}

// SR-13239
// https://github.com/apple/swift/issues/55680

func callit<T>(_ f: () -> T) -> T {
f()
}
Expand All @@ -655,61 +655,61 @@ func callitVariadic<T>(_ fs: () -> T...) -> T {
fs.first!()
}

func testSR13239_Tuple() -> Int {
func test_55680_Tuple() -> Int {
// expected-error@+2{{conflicting arguments to generic parameter 'T' ('()' vs. 'Int')}}
// expected-note@+1:3{{generic parameter 'T' inferred as 'Int' from context}}
callitTuple(1) { // expected-note@:18{{generic parameter 'T' inferred as '()' from closure return expression}}
(print("hello"), 0)
}
}

func testSR13239() -> Int {
func test_55680() -> Int {
// expected-error@+2{{conflicting arguments to generic parameter 'T' ('()' vs. 'Int')}}
// expected-note@+1:3{{generic parameter 'T' inferred as 'Int' from context}}
callit { // expected-note@:10{{generic parameter 'T' inferred as '()' from closure return expression}}
print("hello")
}
}

func testSR13239_Args() -> Int {
func test_55680_Args() -> Int {
// expected-error@+2{{conflicting arguments to generic parameter 'T' ('()' vs. 'Int')}}
// expected-note@+1:3{{generic parameter 'T' inferred as 'Int' from context}}
callitArgs(1) { // expected-note@:17{{generic parameter 'T' inferred as '()' from closure return expression}}
print("hello")
}
}

func testSR13239_ArgsFn() -> Int {
func test_55680_ArgsFn() -> Int {
// expected-error@+2{{conflicting arguments to generic parameter 'T' ('()' vs. 'Int')}}
// expected-note@+1:3{{generic parameter 'T' inferred as 'Int' from context}}
callitArgsFn(1) { // expected-note@:19{{generic parameter 'T' inferred as '()' from closure return expression}}
{ print("hello") }
}
}

func testSR13239MultiExpr() -> Int {
func test_55680_MultiExpr() -> Int {
callit {
print("hello")
return print("hello") // expected-error {{cannot convert return expression of type '()' to return type 'Int'}}
}
}

func testSR13239_GenericArg() -> Int {
func test_55680_GenericArg() -> Int {
// Generic argument is inferred as Int from first argument literal, so no conflict in this case.
callitGenericArg(1) {
print("hello") // expected-error {{cannot convert value of type '()' to closure result type 'Int'}}
}
}

func testSR13239_Variadic() -> Int {
func test_55680_Variadic() -> Int {
// expected-error@+2{{conflicting arguments to generic parameter 'T' ('()' vs. 'Int')}}
// expected-note@+1:3{{generic parameter 'T' inferred as 'Int' from context}}
callitVariadic({ // expected-note@:18{{generic parameter 'T' inferred as '()' from closure return expression}}
print("hello")
})
}

func testSR13239_Variadic_Twos() -> Int {
func test_55680_Variadic_Twos() -> Int {
// expected-error@+1{{cannot convert return expression of type '()' to return type 'Int'}}
callitVariadic({
print("hello")
Expand Down
3 changes: 2 additions & 1 deletion test/expr/closure/closures_swift6.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ class ExplicitSelfRequiredTest {
}
}

class SR14120 {
// https://github.com/apple/swift/issues/56501
class C_56501 {
func operation() {}

func test1() {
Expand Down
51 changes: 25 additions & 26 deletions test/expr/closure/inference.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,43 +38,42 @@ var nestedClosuresWithBrokenInference = { f: Int in {} }
// expected-error@-2 {{expected expression}}
// expected-error@-3 {{cannot find 'f' in scope}}

// SR-11540

func SR11540<R>(action: () -> R) -> Void {}

func SR11540<T, R>(action: (T) -> R) -> Void {}
// https://github.com/apple/swift/issues/53941
do {
func f1<R>(action: () -> R) -> Void {}

func SR11540_1<T, R>(action: (T) -> R) -> Void {}
func f1<T, R>(action: (T) -> R) -> Void {}

SR11540(action: { return }) // Ok SR11540<R>(action: () -> R) was the selected overload.
func f2<T, R>(action: (T) -> R) -> Void {}

// In case that's the only possible overload, it's acceptable
SR11540_1(action: { return }) // OK
f1(action: { return }) // Ok f1<R>(action: () -> R) was the selected overload.

// SR-8563
func SR8563<A,Z>(_ f: @escaping (A) -> Z) -> (A) -> Z {
return f
// In case that's the only possible overload, it's acceptable
f2(action: { return }) // OK
}

func SR8563<A,B,Z>(_ f: @escaping (A, B) -> Z) -> (A, B) -> Z {
return f
}
// https://github.com/apple/swift/issues/51081
do {
func f1<A,Z>(_ f: @escaping (A) -> Z) -> (A) -> Z {}

func f1<A,B,Z>(_ f: @escaping (A, B) -> Z) -> (A, B) -> Z {}

let aa = SR8563 { (a: Int) in }
let bb = SR8563 { (a1: Int, a2: String) in } // expected-note {{'bb' declared here}}
let aa = f1 { (a: Int) in }
let bb = f1 { (a1: Int, a2: String) in } // expected-note {{'bb' declared here}}

aa(1) // Ok
bb(1, "2") // Ok
bb(1) // expected-error {{missing argument for parameter #2 in call}}
aa(1) // Ok
bb(1, "2") // Ok
bb(1) // expected-error {{missing argument for parameter #2 in call}}

// Tuple
let cc = SR8563 { (_: (Int)) in }
// Tuple
let cc = f1 { (_: (Int)) in }

cc((1)) // Ok
cc(1) // Ok
cc((1)) // Ok
cc(1) // Ok
}

// SR-12955
func SR12955() {
// https://github.com/apple/swift/issues/55401
do {
let f: @convention(c) (T) -> Void // expected-error {{cannot find type 'T' in scope}}
}

Expand Down
2 changes: 1 addition & 1 deletion test/expr/closure/single_expr.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ let backupPlan: () -> Int = { haltAndCatchFire() }
func missionCritical(storage: () -> String) {}
missionCritical(storage: { haltAndCatchFire() })

// <https://bugs.swift.org/browse/SR-4963>
// https://github.com/apple/swift/issues/47540
enum E { }
func takesAnotherUninhabitedType(e: () -> E) {}
takesAnotherUninhabitedType { haltAndCatchFire() }
Expand Down
Loading