Skip to content

Commit 8f096bf

Browse files
Merge pull request #60617 from AnthonyLatsis/migrate-test-suite-to-gh-issues-6
Gardening: Migrate test suite to GH issues p. 6
2 parents a159636 + 06be026 commit 8f096bf

File tree

5 files changed

+204
-167
lines changed

5 files changed

+204
-167
lines changed

test/Constraints/function.swift

Lines changed: 41 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -75,34 +75,40 @@ func r22451001() -> AnyObject {}
7575
print(r22451001(5)) // expected-error {{argument passed to call that takes no arguments}}
7676

7777

78-
// SR-590 Passing two parameters to a function that takes one argument of type Any crashes the compiler
79-
// SR-1028: Segmentation Fault: 11 when superclass init takes parameter of type 'Any'
80-
func sr590(_ x: Any) {} // expected-note {{'sr590' declared here}}
81-
sr590(3,4) // expected-error {{extra argument in call}}
82-
sr590() // expected-error {{missing argument for parameter #1 in call}}
83-
// Make sure calling with structural tuples still works.
84-
sr590(())
85-
sr590((1, 2))
86-
87-
// SR-2657: Poor diagnostics when function arguments should be '@escaping'.
88-
private class SR2657BlockClass<T> { // expected-note 4 {{generic parameters are always considered '@escaping'}}
89-
let f: T
90-
init(f: T) { self.f = f }
78+
/// https://github.com/apple/swift/issues/43207
79+
/// Passing two parameters to a function that takes one argument of type `Any`
80+
/// crashes the compiler
81+
do {
82+
func f(_ x: Any) {} // expected-note {{'f' declared here}}
83+
84+
f(3,4) // expected-error {{extra argument in call}}
85+
f() // expected-error {{missing argument for parameter #1 in call}}
86+
// Make sure calling with structural tuples still works.
87+
f(())
88+
f((1, 2))
9189
}
9290

93-
func takesAny(_: Any) {}
91+
/// https://github.com/apple/swift/issues/45262
92+
/// Poor diagnostics when function arguments should be `@escaping`
93+
func f_45262(block: () -> (), other: () -> Int) {
9494

95-
func foo(block: () -> (), other: () -> Int) {
96-
let _ = SR2657BlockClass(f: block)
95+
class C<T> { // expected-note 4 {{generic parameters are always considered '@escaping'}}
96+
let f: T
97+
init(f: T) { self.f = f }
98+
}
99+
100+
func takesAny(_: Any) {}
101+
102+
let _ = C(f: block)
97103
// expected-error@-1 {{converting non-escaping parameter 'block' to generic parameter 'T' may allow it to escape}}
98-
let _ = SR2657BlockClass<()->()>(f: block)
104+
let _ = C<()->()>(f: block)
99105
// expected-error@-1 {{converting non-escaping parameter 'block' to generic parameter 'T' may allow it to escape}}
100-
let _: SR2657BlockClass<()->()> = SR2657BlockClass(f: block)
106+
let _: C<()->()> = C(f: block)
101107
// expected-error@-1 {{converting non-escaping parameter 'block' to generic parameter 'T' may allow it to escape}}
102-
let _: SR2657BlockClass<()->()> = SR2657BlockClass<()->()>(f: block)
108+
let _: C<()->()> = C<()->()>(f: block)
103109
// expected-error@-1 {{converting non-escaping parameter 'block' to generic parameter 'T' may allow it to escape}}
104-
_ = SR2657BlockClass<Any>(f: block) // expected-error {{converting non-escaping value to 'Any' may allow it to escape}}
105-
_ = SR2657BlockClass<Any>(f: other) // expected-error {{converting non-escaping value to 'Any' may allow it to escape}}
110+
_ = C<Any>(f: block) // expected-error {{converting non-escaping value to 'Any' may allow it to escape}}
111+
_ = C<Any>(f: other) // expected-error {{converting non-escaping value to 'Any' may allow it to escape}}
106112
takesAny(block) // expected-error {{converting non-escaping value to 'Any' may allow it to escape}}
107113
takesAny(other) // expected-error {{converting non-escaping value to 'Any' may allow it to escape}}
108114
}
@@ -140,7 +146,8 @@ protocol Q {
140146
associatedtype U : P
141147
}
142148

143-
func sr10811(_ fn: () -> Int) {
149+
// https://github.com/apple/swift/issues/53201
150+
func f_53201(_ fn: () -> Int) {
144151
struct S1 : P {
145152
typealias U = () -> Int
146153
}
@@ -246,8 +253,8 @@ func test_passing_noescape_function_ref_to_generic_parameter() {
246253
}
247254
}
248255

249-
// SR-14784
250-
func SR14784<T>(_ fs: () -> T..., a _ : Int) -> T {
256+
// https://github.com/apple/swift/issues/57133
257+
func f_57133<T>(_ fs: () -> T..., a _ : Int) -> T {
251258
fs.first! // expected-error{{function produces expected type 'T'; did you mean to call it with '()'?}} {{11-11=()}}
252259
}
253260

@@ -264,11 +271,14 @@ func testInvalidTupleImplosions() {
264271
tuplify(takesInout) // expected-error {{cannot convert value of type '(Int, inout String) -> ()' to expected argument type '(Int) -> Void'}}
265272
}
266273

267-
// SR-15179
268-
func SR15179<Ts>(_ fn: @escaping (Ts) -> Void) {} // expected-note {{in call to function 'SR15179'}}
269-
func fn1(x: Int..., y: Int...) {}
270-
SR15179(fn1) // expected-error {{cannot convert value of type '(Int..., Int...) -> ()' to expected argument type '(Ts) -> Void'}}
271-
// expected-error@-1{{generic parameter 'Ts' could not be inferred}}
274+
// https://github.com/apple/swift/issues/57502
275+
do {
276+
func f<Ts>(_ fn: @escaping (Ts) -> Void) {} // expected-note {{in call to function 'f'}}
272277

273-
func fn(_ x: inout Int, _ y: inout Int) {}
274-
SR15179(fn) // expected-error {{cannot convert value of type '(inout Int, inout Int) -> ()' to expected argument type '(Int) -> Void'}}
278+
func g1(x: Int..., y: Int...) {}
279+
f(g1) // expected-error {{cannot convert value of type '(Int..., Int...) -> ()' to expected argument type '(Ts) -> Void'}}
280+
// expected-error@-1{{generic parameter 'Ts' could not be inferred}}
281+
282+
func g2(_ x: inout Int, _ y: inout Int) {}
283+
f(g2) // expected-error {{cannot convert value of type '(inout Int, inout Int) -> ()' to expected argument type '(Int) -> Void'}}
284+
}

test/Constraints/generics.swift

Lines changed: 57 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,9 @@ struct R24267414<T> { // expected-note {{'T' declared as parameter to type 'R24
205205
var _ : Int = R24267414.foo() // expected-error {{generic parameter 'T' could not be inferred}} expected-note {{explicitly specify the generic arguments to fix this issue}} {{24-24=<Any>}}
206206

207207

208-
// https://bugs.swift.org/browse/SR-599
209-
func SR599<T: FixedWidthInteger>() -> T.Type { return T.self } // expected-note {{in call to function 'SR599()'}}
210-
_ = SR599() // expected-error {{generic parameter 'T' could not be inferred}}
211-
212-
208+
// https://github.com/apple/swift/issues/43216
209+
func f_43216<T: FixedWidthInteger>() -> T.Type { return T.self } // expected-note {{in call to function 'f_43216()'}}
210+
_ = f_43216() // expected-error {{generic parameter 'T' could not be inferred}}
213211

214212

215213
// <rdar://problem/19215114> QoI: Poor diagnostic when we are unable to infer type
@@ -456,17 +454,20 @@ func genericFunc<T>(t: T) {
456454
// expected-note@-1 {{explicitly specify the generic arguments to fix this issue}}
457455
}
458456

459-
struct SR_3525<T> {}
460-
func sr3525_arg_int(_: inout SR_3525<Int>) {}
461-
func sr3525_arg_gen<T>(_: inout SR_3525<T>) {}
462-
func sr3525_1(t: SR_3525<Int>) {
463-
let _ = sr3525_arg_int(&t) // expected-error {{cannot pass immutable value as inout argument: 't' is a 'let' constant}}
464-
}
465-
func sr3525_2(t: SR_3525<Int>) {
466-
let _ = sr3525_arg_gen(&t) // expected-error {{cannot pass immutable value as inout argument: 't' is a 'let' constant}}
467-
}
468-
func sr3525_3<T>(t: SR_3525<T>) {
469-
let _ = sr3525_arg_gen(&t) // expected-error {{cannot pass immutable value as inout argument: 't' is a 'let' constant}}
457+
// https://github.com/apple/swift/issues/46113
458+
do {
459+
struct S<T> {}
460+
461+
func arg_int(_: inout S<Int>) {}
462+
func arg_gen<T>(_: inout S<T>) {}
463+
464+
func f1(t: S<Int>) {
465+
let _ = arg_int(&t) // expected-error {{cannot pass immutable value as inout argument: 't' is a 'let' constant}}
466+
let _ = arg_gen(&t) // expected-error {{cannot pass immutable value as inout argument: 't' is a 'let' constant}}
467+
}
468+
func f2<T>(t: S<T>) {
469+
let _ = arg_gen(&t) // expected-error {{cannot pass immutable value as inout argument: 't' is a 'let' constant}}
470+
}
470471
}
471472

472473
class testStdlibType {
@@ -566,7 +567,9 @@ func rdar35541153() {
566567
bar(y, "ultimate question", 42) // Ok
567568
}
568569

569-
// rdar://problem/38159133 - [SR-7125]: Swift 4.1 Xcode 9.3b4 regression
570+
// rdar://problem/38159133
571+
// https://github.com/apple/swift/issues/49673
572+
// Swift 4.1 Xcode 9.3b4 regression
570573

571574
protocol P_38159133 {}
572575

@@ -601,9 +604,8 @@ func rdar39616039() {
601604
c += 1 // ok
602605
}
603606

604-
// https://bugs.swift.org/browse/SR-8075
605-
606-
func sr8075() {
607+
// https://github.com/apple/swift/issues/50608
608+
do {
607609
struct UIFont {
608610
init(ofSize: Float) {}
609611
}
@@ -640,7 +642,7 @@ func rdar40537858() {
640642
let _: E = .bar([s]) // expected-error {{generic enum 'E' requires that 'S' conform to 'P'}}
641643
}
642644

643-
// https://bugs.swift.org/browse/SR-8934
645+
// https://github.com/apple/swift/issues/51439
644646
struct BottleLayout {
645647
let count : Int
646648
}
@@ -650,40 +652,38 @@ let ix = arr.firstIndex(of:layout) // expected-error {{referencing instance meth
650652

651653
let _: () -> UInt8 = { .init("a" as Unicode.Scalar) } // expected-error {{missing argument label 'ascii:' in call}}
652654

653-
// https://bugs.swift.org/browse/SR-9068
655+
// https://github.com/apple/swift/issues/51569
654656
func compare<C: Collection, Key: Hashable, Value: Equatable>(c: C)
655657
-> Bool where C.Element == (key: Key, value: Value)
656658
{
657659
_ = Dictionary(uniqueKeysWithValues: Array(c))
658660
}
659661

660-
// https://bugs.swift.org/browse/SR-7984
661-
struct SR_7984<Bar> {
662+
// https://github.com/apple/swift/issues/50517
663+
664+
struct S1_50517<Bar> {
662665
func doSomething() {}
663666
}
667+
extension S1_50517 where Bar: String {} // expected-error {{type 'Bar' constrained to non-protocol, non-class type 'String'}} expected-note {{use 'Bar == String' to require 'Bar' to be 'String'}} {{29-30= ==}}
664668

665-
extension SR_7984 where Bar: String {} // expected-error {{type 'Bar' constrained to non-protocol, non-class type 'String'}} expected-note {{use 'Bar == String' to require 'Bar' to be 'String'}} {{28-29= ==}}
666-
667-
protocol SR_7984_Proto {
669+
protocol P1_50517 {
668670
associatedtype Bar
669671
}
672+
extension P1_50517 where Bar: String {} // expected-error {{type 'Self.Bar' constrained to non-protocol, non-class type 'String'}} expected-note {{use 'Bar == String' to require 'Bar' to be 'String'}} {{29-30= ==}}
670673

671-
extension SR_7984_Proto where Bar: String {} // expected-error {{type 'Self.Bar' constrained to non-protocol, non-class type 'String'}} expected-note {{use 'Bar == String' to require 'Bar' to be 'String'}} {{34-35= ==}}
672-
673-
protocol SR_7984_HasFoo {
674+
protocol P2_50517 {
674675
associatedtype Foo
675676
}
676-
protocol SR_7984_HasAssoc {
677-
associatedtype Assoc: SR_7984_HasFoo
677+
protocol P3_50517 {
678+
associatedtype Assoc: P2_50517
678679
}
680+
struct S2_50517<T: P3_50517> {}
681+
extension S2_50517 where T.Assoc.Foo: String {} // expected-error {{type 'T.Assoc.Foo' constrained to non-protocol, non-class type 'String'}} expected-note {{use 'T.Assoc.Foo == String' to require 'T.Assoc.Foo' to be 'String'}} {{37-38= ==}}
679682

680-
struct SR_7984_X<T: SR_7984_HasAssoc> {}
681-
extension SR_7984_X where T.Assoc.Foo: String {} // expected-error {{type 'T.Assoc.Foo' constrained to non-protocol, non-class type 'String'}} expected-note {{use 'T.Assoc.Foo == String' to require 'T.Assoc.Foo' to be 'String'}} {{38-39= ==}}
682-
683-
struct SR_7984_S<T: Sequence> where T.Element: String {} // expected-error {{type 'T.Element' constrained to non-protocol, non-class type 'String'}} expected-note {{use 'T.Element == String' to require 'T.Element' to be 'String'}} {{46-47= ==}}
684-
func SR_7984_F<T: Sequence>(foo: T) where T.Element: String {} // expected-error {{type 'T.Element' constrained to non-protocol, non-class type 'String'}} expected-note {{use 'T.Element == String' to require 'T.Element' to be 'String'}} {{52-53= ==}}
683+
struct S3_50517<T: Sequence> where T.Element: String {} // expected-error {{type 'T.Element' constrained to non-protocol, non-class type 'String'}} expected-note {{use 'T.Element == String' to require 'T.Element' to be 'String'}} {{45-46= ==}}
684+
func f_50517<T: Sequence>(foo: T) where T.Element: String {} // expected-error {{type 'T.Element' constrained to non-protocol, non-class type 'String'}} expected-note {{use 'T.Element == String' to require 'T.Element' to be 'String'}} {{50-51= ==}}
685685

686-
protocol SR_7984_P {
686+
protocol P4_50517 {
687687
func S<T : Sequence>(bar: T) where T.Element: String // expected-error {{type 'T.Element' constrained to non-protocol, non-class type 'String'}} expected-note {{use 'T.Element == String' to require 'T.Element' to be 'String'}} {{47-48= ==}}
688688
}
689689

@@ -710,10 +710,11 @@ protocol Q {
710710
init<T : P>(_ x: T) // expected-note 2{{where 'T' = 'T'}}
711711
}
712712

713-
struct SR10694 {
713+
// https://github.com/apple/swift/issues/53091
714+
struct S_53091 {
714715
init<T : P>(_ x: T) {} // expected-note 3{{where 'T' = 'T'}}
715-
func bar<T>(_ x: T, _ s: SR10694, _ q: Q) {
716-
SR10694.self(x) // expected-error {{initializer 'init(_:)' requires that 'T' conform to 'P'}}
716+
func bar<T>(_ x: T, _ s: S_53091, _ q: Q) {
717+
S_53091.self(x) // expected-error {{initializer 'init(_:)' requires that 'T' conform to 'P'}}
717718

718719
type(of: s)(x) // expected-error {{initializer 'init(_:)' requires that 'T' conform to 'P'}}
719720
// expected-error@-1 {{initializing from a metatype value must reference 'init' explicitly}}
@@ -724,14 +725,17 @@ struct SR10694 {
724725
type(of: q)(x) // expected-error {{initializer 'init(_:)' requires that 'T' conform to 'P'}}
725726
// expected-error@-1 {{initializing from a metatype value must reference 'init' explicitly}}
726727

727-
var srTy = SR10694.self
728-
srTy(x) // expected-error {{initializer 'init(_:)' requires that 'T' conform to 'P'}}
728+
var ty = S_53091.self
729+
ty(x) // expected-error {{initializer 'init(_:)' requires that 'T' conform to 'P'}}
729730
// expected-error@-1 {{initializing from a metatype value must reference 'init' explicitly}}
730731
}
731732
}
732733

733-
// SR-7003 (rdar://problem/51203824) - Poor diagnostics when attempting to access members on unfulfilled generic type
734-
func sr_7003() {
734+
// rdar://problem/51203824
735+
// https://github.com/apple/swift/issues/49551
736+
// Poor diagnostics when attempting to access members on unfulfilled
737+
// generic type
738+
func f_49551() {
735739
struct E<T> { // expected-note 4 {{'T' declared as parameter to type 'E'}}
736740
static var foo: String { return "" }
737741
var bar: String { return "" }
@@ -817,20 +821,22 @@ func test_correct_identification_of_requirement_source() {
817821
// expected-error@-1 {{initializer 'init(_:_:)' requires that 'Int' conform to 'P'}}
818822
}
819823

820-
struct SR11435<T> {
824+
// https://github.com/apple/swift/issues/53836
825+
826+
struct S_53836<T> {
821827
subscript<U : P & Hashable>(x x: U) -> U { x } // expected-note {{where 'U' = 'Int'}}
822828
}
823-
824-
extension SR11435 where T : P { // expected-note {{where 'T' = 'Int'}}
829+
extension S_53836 where T : P { // expected-note {{where 'T' = 'Int'}}
825830
var foo: Int { 0 }
826831
}
827832

828833
func test_identification_of_key_path_component_callees() {
829-
_ = \SR11435<Int>.foo // expected-error {{property 'foo' requires that 'Int' conform to 'P'}}
830-
_ = \SR11435<Int>.[x: 5] // expected-error {{subscript 'subscript(x:)' requires that 'Int' conform to 'P'}}
834+
_ = \S_53836<Int>.foo // expected-error {{property 'foo' requires that 'Int' conform to 'P'}}
835+
_ = \S_53836<Int>.[x: 5] // expected-error {{subscript 'subscript(x:)' requires that 'Int' conform to 'P'}}
831836
}
832837

833-
func sr_11491(_ value: [String]) {
838+
// https://github.com/apple/swift/issues/53891
839+
func f_53891(_ value: [String]) {
834840
var arr: Set<String> = []
835841
arr.insert(value)
836842
// expected-error@-1 {{cannot convert value of type '[String]' to expected argument type 'String'}}

0 commit comments

Comments
 (0)