Skip to content

Commit 4b64dc9

Browse files
committed
[test] Add tests
1 parent 6be15e2 commit 4b64dc9

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

test/type/explicit_existential_swift6.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,16 @@ protocol Collection<T> {
145145
associatedtype T
146146
}
147147

148+
struct TestParameterizedProtocol<T> : Collection {
149+
typealias T = T
150+
151+
let x : Collection<T> // expected-error {{use of protocol 'Collection<T>' as a type must be written 'any Collection<T>'}}
152+
}
153+
148154
func acceptAny(_: Collection<Int>) {}
149-
// expected-error@-1 {{use of protocol 'Collection' as a type must be written 'any Collection'}}
155+
// expected-error@-1 {{use of protocol 'Collection<Int>' as a type must be written 'any Collection<Int>'}}
150156
func returnsAny() -> Collection<Int> {}
151-
// expected-error@-1 {{use of protocol 'Collection' as a type must be written 'any Collection'}}
157+
// expected-error@-1 {{use of protocol 'Collection<Int>' as a type must be written 'any Collection<Int>'}}
152158

153159
func testInvalidAny() {
154160
struct S: HasAssoc {

test/type/parameterized_existential.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ protocol Sequence<Element> { // expected-note {{'Sequence' declared here}}
77
// 'any' is required here
88

99
func takesSequenceOfInt1(_: Sequence<Int>) {}
10-
// expected-error@-1 {{use of protocol 'Sequence' as a type must be written 'any Sequence'}}
10+
// expected-error@-1 {{use of protocol 'Sequence<Int>' as a type must be written 'any Sequence<Int>'}}
1111

1212
func returnsSequenceOfInt1() -> Sequence<Int> {}
13-
// expected-error@-1 {{use of protocol 'Sequence' as a type must be written 'any Sequence'}}
13+
// expected-error@-1 {{use of protocol 'Sequence<Int>' as a type must be written 'any Sequence<Int>'}}
1414

1515
struct ConcreteSequence<Element> : Sequence {}
1616

@@ -74,7 +74,7 @@ func saturation(_ dry: any Sponge, _ wet: any Sponge<Int, Int>) {
7474

7575
func typeExpr() {
7676
_ = Sequence<Int>.self
77-
// expected-error@-1 {{use of protocol 'Sequence' as a type must be written 'any Sequence'}}
77+
// expected-error@-1 {{use of protocol 'Sequence<Int>' as a type must be written 'any Sequence<Int>'}}
7878

7979
_ = any Sequence<Int>.self
8080
// expected-error@-1 {{'self' is not a member type of protocol 'parameterized_existential.Sequence<Swift.Int>'}}

0 commit comments

Comments
 (0)