Skip to content

Commit 47676b2

Browse files
committed
Test: fix a number of NCGenerics-specific tests
1 parent 102ccbc commit 47676b2

File tree

7 files changed

+74
-90
lines changed

7 files changed

+74
-90
lines changed

test/Generics/inverse_generics.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -470,11 +470,9 @@ struct UnethicalPointer<Pointee: ~Copyable> {}
470470
extension UnethicalPointer: Arbitrary {}
471471
extension UnethicalPointer: AnotherOne where Pointee: Copyable {}
472472

473-
struct StillIllegal1<Pointee: ~Escapable> {}
474-
extension StillIllegal1: Arbitrary {}
475-
// expected-error@-1 {{conditional conformance to non-marker protocol 'Arbitrary' cannot depend on conformance of 'Pointee' to marker protocol 'Escapable'}}
476-
extension StillIllegal1: AnotherOne where Pointee: Escapable {}
477-
// expected-error@-1 {{conditional conformance to non-marker protocol 'AnotherOne' cannot depend on conformance of 'Pointee' to marker protocol 'Escapable'}}
473+
struct AlsoLegal1<Pointee: ~Escapable> {}
474+
extension AlsoLegal1: Arbitrary {}
475+
extension AlsoLegal1: AnotherOne where Pointee: Escapable {}
478476

479477
struct SillIllegal2<Pointee> {}
480478
extension SillIllegal2: Arbitrary where Pointee: Sendable {}

test/Parse/inverses_legacy.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22

33
// XFAIL: noncopyable_generics
44

5-
protocol Sando { func make() } // expected-note 2{{protocol requires function 'make()'}}
5+
protocol Sando { func make() } // expected-note {{protocol requires function 'make()'}}
6+
// expected-note@-1 {{type 'U' does not conform to inherited protocol 'Copyable'}}
67

78
struct BuggerView: ~Escapable {} // expected-error {{can only suppress 'Copyable'}}
89

910
struct S: ~U, // expected-error {{can only suppress 'Copyable'}}
1011
// expected-error@-1 {{inheritance from non-protocol type 'U'}}
1112
~Copyable {}
1213

13-
struct U: // expected-error {{noncopyable struct 'U' cannot conform to 'Sando'}}
14-
// expected-error@-1 {{type 'U' does not conform to protocol 'Sando'}}
14+
struct U: // expected-error {{type 'U' does not conform to protocol 'Copyable'}}
1515
~Copyable,
1616
Sando,
1717
~Copyable // expected-error {{duplicate suppression of 'Copyable'}}
@@ -34,8 +34,7 @@ protocol Rope<Element>: ~Copyable { // expected-error {{cannot suppress conforma
3434
}
3535

3636
extension S: ~Copyable {} // expected-error {{cannot suppress conformances here}}
37-
// expected-error@-1 {{noncopyable struct 'S' cannot conform to 'Copyable'}}
38-
// expected-error@-2 {{struct 'S' required to be 'Copyable' but is marked with '~Copyable'}}
37+
// expected-error@-1 {{struct 'S' required to be 'Copyable' but is marked with '~Copyable'}}
3938

4039
func takeNoncopyableGeneric<T: ~Copyable>(_ t: T) {} // expected-error {{cannot suppress conformances here}}
4140

test/Parse/inverses_legacy_ifdef.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,28 @@ struct Blah: ~Copyable, ~Copyable {}
2525
// expected-error@-1 {{duplicate suppression of 'Copyable'}}
2626

2727
protocol Compare where Self: ~Copyable { // expected-error {{cannot suppress conformances here}}
28+
// expected-note@-1 {{type 'NC' does not conform to inherited protocol 'Copyable'}}
2829
func lessThan(_ other: borrowing Self) -> Bool
2930
}
3031

3132
protocol Sortable<Element>: ~Copyable { // expected-error {{cannot suppress conformances here}}
32-
associatedtype Element: ~Copyable, Compare // expected-error {{cannot suppress conformances here}} // expected-note {{protocol requires nested type 'Element'; add nested type 'Element' for conformance}}
33+
// expected-note@-1 {{type 'NC' does not conform to inherited protocol 'Copyable'}}
34+
associatedtype Element: ~Copyable, Compare // expected-error {{cannot suppress conformances here}}
3335

3436
mutating func sort()
3537
}
3638

37-
extension NC: Compare { // expected-error {{noncopyable struct 'NC' cannot conform to 'Compare'}}
39+
extension NC: Compare { // expected-error {{type 'NC' does not conform to protocol 'Copyable'}}
3840
func lessThan(_ other: borrowing Self) -> Bool { false }
3941
}
4042

41-
extension NC: Sortable { // expected-error {{noncopyable struct 'NC' cannot conform to 'Sortable'}}
42-
// expected-error@-1 {{type 'NC' does not conform to protocol 'Sortable'}}
43-
// expected-error@-2 {{struct 'NC' required to be 'Copyable' but is marked with '~Copyable'}}
44-
typealias Element = NC // expected-note {{possibly intended match 'NC.Element' (aka 'NC') does not conform to 'Copyable'}}
43+
extension NC: Sortable { // expected-error {{type 'NC' does not conform to protocol 'Copyable'}}
44+
typealias Element = NC
4545

4646
mutating func sort() { }
4747
}
4848

49-
func f<T>(_ t: inout T) // expected-note {{where 'T.Element' = 'NC.Element'}}
49+
func f<T>(_ t: inout T) // expected-error {{no type for 'T.Element' can satisfy both 'T.Element == NC' and 'T.Element : Copyable'}}
5050
where T: ~Copyable, // expected-error {{cannot suppress conformances here}}
5151
T: Sortable,
5252
T.Element == NC {
@@ -55,7 +55,7 @@ func f<T>(_ t: inout T) // expected-note {{where 'T.Element' = 'NC.Element'}}
5555

5656
do {
5757
var x = NC()
58-
f(&x) // expected-error {{global function 'f' requires the types 'NC.Element' and 'NC' be equivalent}}
58+
f(&x)
5959
}
6060

6161
#endif

test/Sema/copyable.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// RUN: %target-typecheck-verify-swift
22

3-
// XFAIL: noncopyable_generics
4-
53
protocol P: Copyable {}
64
struct S: P {}
75

@@ -11,8 +9,7 @@ typealias WhatIfIQualify = Swift.Copyable
119
class C: Copyable {}
1210

1311
@_moveOnly struct MOStruct: Copyable {}
14-
// expected-error@-1 {{noncopyable struct 'MOStruct' cannot conform to 'Copyable'}}
15-
// expected-error@-2 {{struct 'MOStruct' required to be 'Copyable' but is marked with '~Copyable'}}
12+
// expected-error@-1 {{struct 'MOStruct' required to be 'Copyable' but is marked with '~Copyable'}}
1613

1714

1815
func whatever<T>(_ t: T) where T: Copyable {}

test/Sema/moveonly_illegal_types.swift

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// RUN: %target-typecheck-verify-swift
22

3-
// XFAIL: noncopyable_generics
4-
53
// This test focuses on the prevention of users from _writing_ types where
64
// a move-only type is substituted for a generic parameter.
75
//
@@ -52,30 +50,30 @@ struct CerebralValley<T> {
5250
func basic_vararg(_ va: MO...) {} // expected-error {{noncopyable type 'MO' cannot be used within a variadic type yet}}
5351

5452
func illegalTypes<T>(_ t: T) {
55-
let _: Array<MO> // expected-error {{noncopyable type 'MO' cannot be used with generic type 'Array<Element>' yet}}
56-
let _: Maybe<MO> // expected-error {{noncopyable type 'MO' cannot be used with generic type 'Maybe<T>' yet}}
57-
let _: Dictionary<MO, String> // expected-error {{noncopyable type 'MO' cannot be used with generic type 'Dictionary<Key, Value>' yet}}
58-
let _: [MO] // expected-error {{noncopyable type 'MO' cannot be used with generic type 'Array<Element>' yet}}
59-
let _: [String : MO] // expected-error {{noncopyable type 'MO' cannot be used with generic type 'Dictionary<Key, Value>' yet}}
60-
let _: [MO : MO] // expected-error 2{{noncopyable type 'MO' cannot be used with generic type 'Dictionary<Key, Value>' yet}}
61-
let _: [MO : T] // expected-error {{noncopyable type 'MO' cannot be used with generic type 'Dictionary<Key, Value>' yet}}
62-
63-
_ = t as! ValBox<MO> // expected-error {{noncopyable type 'MO' cannot be used with generic type 'ValBox<T>' yet}}
64-
65-
let _: Optional<MO> // expected-error {{noncopyable type 'MO' cannot be used with generic type 'Optional<Wrapped>' yet}}
66-
let _: MO? // expected-error {{noncopyable type 'MO' cannot be used with generic type 'Optional<Wrapped>' yet}}
67-
let _: MO?? // expected-error {{noncopyable type 'MO' cannot be used with generic type 'Optional<Wrapped>' yet}}
68-
let _: MO! // expected-error {{noncopyable type 'MO' cannot be used with generic type 'Optional<Wrapped>' yet}}
69-
let _: MO?! // expected-error {{noncopyable type 'MO' cannot be used with generic type 'Optional<Wrapped>' yet}}
53+
let _: Array<MO> // expected-error {{type 'MO' does not conform to protocol 'Copyable'}}
54+
let _: Maybe<MO> // expected-error {{type 'MO' does not conform to protocol 'Copyable'}}
55+
let _: Dictionary<MO, String> // expected-error {{type 'MO' does not conform to protocol 'Hashable'}}
56+
let _: [MO] // expected-error {{type 'MO' does not conform to protocol 'Copyable'}}
57+
let _: [String : MO] // expected-error {{type 'MO' does not conform to protocol 'Copyable'}}
58+
let _: [MO : MO] // expected-error {{type 'MO' does not conform to protocol 'Hashable'}}
59+
let _: [MO : T] // expected-error {{type 'MO' does not conform to protocol 'Hashable'}}
60+
61+
_ = t as! ValBox<MO> // expected-error {{type 'MO' does not conform to protocol 'Copyable'}}
62+
63+
let _: Optional<MO> // expected-error {{type 'MO' does not conform to protocol 'Copyable'}}
64+
let _: MO? // expected-error {{type 'MO' does not conform to protocol 'Copyable'}}
65+
let _: MO?? // expected-error {{type 'MO' does not conform to protocol 'Copyable'}}
66+
let _: MO! // expected-error {{type 'MO' does not conform to protocol 'Copyable'}}
67+
let _: MO?! // expected-error {{type 'MO' does not conform to protocol 'Copyable'}}
7068

7169
let _: Klass & MO // expected-error {{non-protocol, non-class type 'MO' cannot be used within a protocol-constrained type}}
7270
let _: any MO // expected-error {{'any' has no effect on concrete type 'MO'}}
7371
let _: any GenericMO<T> // expected-error {{'any' has no effect on concrete type 'GenericMO<T>'}}
7472

75-
let _: CerebralValley<MO>.TechBro // expected-error {{noncopyable type 'MO' cannot be used with generic type 'CerebralValley<T>' yet}}
76-
let _: CerebralValley<Int>.GenericBro<MO> // expected-error {{noncopyable type 'MO' cannot be used with generic type 'CerebralValley<T>.GenericBro<U>' yet}}
73+
let _: CerebralValley<MO>.TechBro // expected-error {{type 'MO' does not conform to protocol 'Copyable'}}
74+
let _: CerebralValley<Int>.GenericBro<MO> // expected-error {{type 'MO' does not conform to protocol 'Copyable'}}
7775

78-
let _: GenericMO<MO> // expected-error {{noncopyable type 'MO' cannot be used with generic type 'GenericMO<T>' yet}}
76+
let _: GenericMO<MO> // expected-error {{type 'MO' does not conform to protocol 'Copyable'}}
7977
}
8078

8179
func illegalInExpr() {

0 commit comments

Comments
 (0)