Skip to content

Commit 7612682

Browse files
committed
NCGenerics: update a number of tests
These tests were not updated in the transition to `REQUIRES: noncopyable_generics` and thus running them with a correctly-built stdlib that has the Copyable requirements.
1 parent 6f6ab4a commit 7612682

File tree

7 files changed

+28
-32
lines changed

7 files changed

+28
-32
lines changed

test/Generics/inverse_copyable_requirement.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -231,22 +231,22 @@ func checkCasting(_ b: any Box, _ mo: borrowing MO, _ a: Any) {
231231
// FIXME: rdar://115752211 (deal with existing Swift modules that lack Copyable requirements)
232232
// the stdlib right now is not yet being compiled with NoncopyableGenerics
233233
func checkStdlibTypes(_ mo: borrowing MO) {
234-
_ = "\(mo)" // MISSING-error {{noncopyable type 'MO' cannot be substituted for copyable generic parameter 'T' in 'appendInterpolation'}}
235-
let _: String = String(describing: mo) // MISSING-error {{noncopyable type 'MO' cannot be substituted for copyable generic parameter 'Subject' in 'init(describing:)'}}
234+
_ = "\(mo)" // expected-error {{no exact matches in call to instance method 'appendInterpolation'}}
235+
let _: String = String(describing: mo) // expected-error {{no exact matches in call to initializer}}
236236

237237
let _: [MO] = // MISSING-error {{noncopyable type 'MO' cannot be used with generic type 'Array<Element>' yet}}
238238
[MO(), MO()]
239239
let _: [MO] = // MISSING-error {{noncopyable type 'MO' cannot be used with generic type 'Array<Element>' yet}}
240240
[]
241-
let _: [String: MO] = // MISSING-error {{noncopyable type 'MO' cannot be used with generic type 'Dictionary<Key, Value>' yet}}
241+
let _: [String: MO] = // expected-error {{type 'MO' does not conform to protocol 'Copyable'}}
242242
["hello" : MO()] // expected-error{{type '(String, MO)' containing noncopyable element is not supported}}
243243

244-
_ = [MO()] // MISSING-error {{noncopyable type 'MO' cannot be substituted for copyable generic parameter 'Element' in 'Array'}}
244+
_ = [MO()] // expected-error {{noncopyable type 'MO' cannot be substituted for copyable generic parameter 'Element' in 'Array'}}
245245

246-
let _: Array<MO> = .init() // MISSING-error {{noncopyable type 'MO' cannot be used with generic type 'Array<Element>' yet}}
247-
_ = [MO]() // MISSING-error {{noncopyable type 'MO' cannot be used with generic type 'Array<Element>' yet}}
246+
let _: Array<MO> = .init() // expected-error {{type 'MO' does not conform to protocol 'Copyable'}}
247+
_ = [MO]() // expected-error {{noncopyable type 'MO' cannot be substituted for copyable generic parameter 'Element' in 'Array'}}
248248

249-
let _: String = "hello \(mo)" // MISSING-error {{noncopyable type 'MO' cannot be substituted for copyable generic parameter 'T' in 'appendInterpolation'}}
249+
let _: String = "hello \(mo)" // expected-error {{no exact matches in call to instance method 'appendInterpolation'}}
250250
}
251251

252252
func copyableExistentials(_ a: Any, _ e1: Error, _ e2: any Error, _ ah: AnyHashable) {

test/Generics/inverse_signatures.swift

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ func where1<T>(_ t: borrowing T) where T: ~Copyable {}
2727
func where2<T>(_ t: borrowing T) where T: NoCopyP, T: ~Copyable {}
2828

2929
// CHECK-LABEL: .where3@
30-
// CHECK: Generic signature: <T where T : Equatable, T : Escapable>
31-
func where3<T>(_ t: borrowing T) where T: Equatable, T: ~Copyable {}
30+
// CHECK: Generic signature: <T where T : Escapable, T : Empty>
31+
func where3<T>(_ t: borrowing T) where T: Empty, T: ~Copyable {}
3232

3333
// CHECK-LABEL: .where4@
3434
// CHECK: Generic signature: <T where T : Copyable>
@@ -39,8 +39,8 @@ func where4<T>(_ t: borrowing T) where T: ~Escapable {}
3939
func where5<T>(_ t: borrowing T) where T: Empty, T: ~Escapable {}
4040

4141
// CHECK-LABEL: .where6@
42-
// CHECK: Generic signature: <T where T : Equatable, T : Escapable>
43-
func where6<T>(_ t: borrowing T) where T: Equatable, T: ~Copyable {}
42+
// CHECK: Generic signature: <T where T : Escapable, T : Empty>
43+
func where6<T>(_ t: borrowing T) where T: Empty, T: ~Copyable {}
4444

4545
// CHECK-LABEL: .compose1@
4646
// CHECK: Generic signature: <T where T : NoCopyP>
@@ -58,9 +58,9 @@ func f1<T: NoCopyP>(_ t: T) {}
5858
// CHECK: Canonical generic signature: <τ_0_0 where τ_0_0 : Copyable, τ_0_0 : Escapable>
5959
func withSome(_ t: some Any) {}
6060

61-
// CHECK-LABEL: .withSomeEquatable@
62-
// CHECK: Canonical generic signature: <τ_0_0 where τ_0_0 : Copyable, τ_0_0 : Equatable, τ_0_0 : Escapable>
63-
func withSomeEquatable(_ t: some Equatable) {}
61+
// CHECK-LABEL: .withSomeEmpty@
62+
// CHECK: Canonical generic signature: <τ_0_0 where τ_0_0 : Copyable, τ_0_0 : Escapable, τ_0_0 : Empty>
63+
func withSomeEmpty(_ t: some Empty) {}
6464

6565
// CHECK-LABEL: .withSomeProto@
6666
// CHECK: Canonical generic signature: <τ_0_0 where τ_0_0 : Copyable, τ_0_0 : NoCopyP>
@@ -193,8 +193,10 @@ extension Cond: Copyable where T: Copyable {}
193193
// CHECK-NEXT: Canonical generic signature: <τ_0_0>
194194
struct ImplicitCond<T: ~Escapable & ~Copyable> {}
195195

196+
// FIXME: At the moment, Sendable in the stdlib requires Escapable.
196197
// CHECK-LABEL: StructDecl name=ImplicitCond
197-
// CHECK-NEXT: (normal_conformance type="ImplicitCond<T>" protocol="Sendable")
198+
// CHECK-NEXT: (normal_conformance type="ImplicitCond<T>" protocol="Sendable"
199+
// CHECK-NEXT: (assoc_conformance type="Self" proto="Escapable"
198200

199201
// CHECK-LABEL: ExtensionDecl line={{.*}} base=ImplicitCond
200202
// CHECK: Generic signature: <T>

test/Parse/inverses.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func more() {
1717
let _: ~AnyObject // expected-error {{type 'AnyObject' is not invertible}}
1818
}
1919

20-
struct S4: ~(Copyable & Equatable) {} // expected-error {{type 'Copyable & Equatable' is not invertible}}
20+
struct S4: ~(Copyable & Equatable) {} // expected-error {{type 'Equatable' is not invertible}}
2121

2222
func blah<T>(_ t: borrowing T) where T: ~Copyable,
2323
T: ~Hashable {} // expected-error@:41 {{type 'Hashable' is not invertible}}
@@ -103,5 +103,5 @@ typealias Z4 = ~Rope<Int> // expected-error {{type 'Rope<Int>' is not invertible
103103
typealias Z5 = (~Int) -> Void // expected-error {{type 'Int' is not invertible}}
104104
typealias Z6 = ~() -> () // expected-error {{single argument function types require parentheses}}
105105
// expected-error@-1 {{type '()' is not invertible}}
106-
typealias Z7 = ~(Copyable & Hashable) // expected-error {{type 'Copyable & Hashable' is not invertible}}
106+
typealias Z7 = ~(Copyable & Hashable) // expected-error {{type 'Hashable' is not invertible}}
107107
typealias Z8 = ~Copyable & Hashable

test/Parse/inverses_legacy_ifdef.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
// RUN: %swift-frontend -typecheck %s
2-
// RUN: %swift-frontend -typecheck %s -DHAVE_NCGENERICS -enable-experimental-feature NoncopyableGenerics
32
// RUN: %swift-frontend -typecheck %s -verify -DHAVE_NCGENERICS
43

5-
// REQUIRES: noncopyable_generics
6-
74
/// This test checks that you can write ~Copyable in places that were illegal
85
/// in Swift 5.9, as long as those illegal appearances are guarded within
96
/// a disabled #if block.

test/SILOptimizer/moveonly_computed_property.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33

44
// REQUIRES: noncopyable_generics
55

6-
// SIL verification failed: 'MoveOnly' types can only be copied in Raw SIL?!
7-
// REQUIRES: rdar118135397
8-
96
// Applying a computed property to a move-only field in a class should occur
107
// entirely within a formal access to the class property. rdar://105794506
118

test/Serialization/Inputs/ncgenerics.swift

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,5 @@ public protocol Either<Left, Right>: ~Copyable {
3131
associatedtype Left: ~Copyable
3232
associatedtype Right: ~Copyable
3333
}
34-
35-
#else
36-
public enum Maybe<Wrapped> {
37-
case just(Wrapped)
38-
case none
39-
}
4034
#endif
35+

test/Serialization/noncopyable_generics.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,20 @@ struct NC: ~Copyable {}
3838
struct RegularStruct {}
3939

4040
func isItCopyable<T: Copyable>(_ t: T) {}
41-
// expected-note@-1 2{{generic parameter 'T' has an implicit Copyable requirement}}
41+
// expected-note@-1 {{generic parameter 'T' has an implicit Copyable requirement}}
4242

4343
func check() {
4444
var tr = TestRequirements()
4545
advance(by: 12, &tr)
4646

4747
isItCopyable(TestRequirements())
4848
isItCopyable(RegularStruct())
49-
isItCopyable(NC()) // expected-error 2{{noncopyable type 'NC' cannot be substituted for copyable generic parameter 'T' in 'isItCopyable'}}
49+
isItCopyable(NC()) // expected-error {{noncopyable type 'NC' cannot be substituted for copyable generic parameter 'T' in 'isItCopyable'}}
5050

51-
let x: Maybe<NC> = .none // expected-error {{noncopyable type 'NC' cannot be used with generic type 'Maybe<Wrapped>' yet}}
51+
let x: Maybe<NC> = .none
52+
}
53+
54+
struct Witness: Either {
55+
typealias Left = Maybe<RegularStruct>
56+
typealias Right = Maybe<NC>
5257
}

0 commit comments

Comments
 (0)