Skip to content

Commit 17ce779

Browse files
committed
Cannot open existentials passed to variadic parameters.
1 parent 76d1ba7 commit 17ce779

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/Constraints/opened_existentials.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,18 @@ func doNotOpenOuter(p: any P) {
140140
// expected-note@-1{{only concrete types such as structs, enums and classes can conform to protocols}}
141141
}
142142

143+
func takesVariadic<T: P>(_ args: T...) { }
144+
// expected-note@-1 2{{required by global function 'takesVariadic' where 'T' = 'P'}}
145+
// expected-note@-2{{in call to function 'takesVariadic'}}
146+
147+
func callVariadic(p1: any P, p2: any P) {
148+
takesVariadic() // expected-error{{generic parameter 'T' could not be inferred}}
149+
takesVariadic(p1) // expected-error{{protocol 'P' as a type cannot conform to the protocol itself}}
150+
// expected-note@-1{{only concrete types such as structs, enums and classes can conform to protocols}}
151+
takesVariadic(p1, p2) // expected-error{{protocol 'P' as a type cannot conform to the protocol itself}}
152+
// expected-note@-1{{only concrete types such as structs, enums and classes can conform to protocols}}
153+
}
154+
143155
@available(SwiftStdlib 5.1, *)
144156
func testReturningOpaqueTypes(p: any P) {
145157
let q = p.getQ()

0 commit comments

Comments
 (0)