You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
func testCombinedConstraints<T:ProtoA&ProtoBwhere T:ProtoC>(x:T)where T:ProtoD{} // expected-error {{'where' clause next to generic parameters is obsoleted}} {{48-64=}} {{72-77=where T: ProtoC,}}
77
77
78
78
func testCombinedConstraintsOld<T:protocol<ProtoA,ProtoB>where T:ProtoC>(x:T){} // expected-error {{'where' clause next to generic parameters is obsoleted}} {{60-76=}} {{83-83= where T: ProtoC}}
79
-
// expected-warning@-1 {{'protocol<...>' composition syntax is deprecated}}
79
+
// expected-error@-1 {{'protocol<...>' composition syntax has been removed}}
80
80
func testCombinedConstraintsOld<T:protocol<ProtoA,ProtoB>where T:ProtoC>(x:T)where T:ProtoD{} // expected-error {{'where' clause next to generic parameters is obsoleted}} {{60-76=}} {{84-89=where T: ProtoC,}}
81
-
// expected-warning@-1 {{'protocol<...>' composition syntax is deprecated}}
81
+
// expected-error@-1 {{'protocol<...>' composition syntax has been removed}}
Copy file name to clipboardExpand all lines: test/type/protocol_composition.swift
+28-28Lines changed: 28 additions & 28 deletions
Original file line number
Diff line number
Diff line change
@@ -22,12 +22,12 @@ protocol P4 : P3 {
22
22
func f(_:Double)->Double
23
23
}
24
24
25
-
typealiasAny1=protocol<> // expected-warning {{'protocol<>' syntax is deprecated; use 'Any' instead}}
26
-
typealiasAny2=protocol<> // expected-warning {{'protocol<>' syntax is deprecated; use 'Any' instead}}
25
+
typealiasAny1=protocol<> // expected-error {{'protocol<>' syntax has been removed; use 'Any' instead}}
26
+
typealiasAny2=protocol<> // expected-error {{'protocol<>' syntax has been removed; use 'Any' instead}}
27
27
28
28
// Okay to inherit a typealias for Any type.
29
29
protocolP5:Any{}
30
-
protocolP6:protocol<>{} // expected-warning {{'protocol<>' syntax is deprecated; use 'Any' instead}}
30
+
protocolP6:protocol<>{} // expected-error {{'protocol<>' syntax has been removed; use 'Any' instead}}
31
31
// expected-error@-1 {{protocol-constrained type is neither allowed nor needed here}}
32
32
typealiasP7=Any&Any1
33
33
@@ -111,45 +111,45 @@ func testConversion() {
111
111
accept_manyPrintable(sp)
112
112
113
113
// Conversions among existential types.
114
-
varx2:protocol<SuperREPLPrintable,FooProtocol> // expected-warning {{'protocol<...>' composition syntax is deprecated; join the protocols using '&'}} {{12-53=SuperREPLPrintable & FooProtocol}}
114
+
varx2:protocol<SuperREPLPrintable,FooProtocol> // expected-error {{'protocol<...>' composition syntax has been removed; join the protocols using '&'}} {{12-53=SuperREPLPrintable & FooProtocol}}
115
115
x2 = x // expected-error{{value of type 'FooProtocol & REPLPrintable' does not conform to 'FooProtocol & SuperREPLPrintable' in assignment}}
116
116
x = x2
117
117
118
118
// Subtyping
119
119
var _ :()->FooProtocol&SuperREPLPrintable= return_superPrintable
120
120
121
121
// FIXME: closures make ABI conversions explicit. rdar://problem/19517003
122
-
var _ :()->protocol<FooProtocol,REPLPrintable>={return_superPrintable()} // expected-warning {{'protocol<...>' composition syntax is deprecated; join the protocols using '&'}} {{17-53=FooProtocol & REPLPrintable}}
122
+
var _ :()->protocol<FooProtocol,REPLPrintable>={return_superPrintable()} // expected-error {{'protocol<...>' composition syntax has been removed; join the protocols using '&'}} {{17-53=FooProtocol & REPLPrintable}}
123
123
}
124
124
125
125
// Test the parser's splitting of >= into > and =.
126
-
varx:protocol<P5>=17 // expected-warning {{'protocol<...>' composition syntax is deprecated and not needed here}} {{9-22=P5=}} expected-error {{'=' must have consistent whitespace on both sides}}
127
-
vary:protocol<P5,P7>=17 // expected-warning {{'protocol<...>' composition syntax is deprecated; join the protocols using '&'}} {{9-26=P5 & P7=}} expected-error {{'=' must have consistent whitespace on both sides}}
128
-
varz:protocol<P5,P7>?=17 // expected-warning {{'protocol<...>' composition syntax is deprecated; join the protocols using '&'}} {{9-27=(P5 & P7)?=}}
129
-
130
-
typealiasA1=protocol<> // expected-warning {{'protocol<>' syntax is deprecated; use 'Any' instead}} {{16-26=Any}}
131
-
typealiasA2=protocol<>? // expected-warning {{'protocol<>' syntax is deprecated; use 'Any' instead}} {{16-27=Any?}}
132
-
typealiasB1=protocol<P1,P2> // expected-warning {{'protocol<...>' composition syntax is deprecated; join the protocols using '&'}} {{16-31=P1 & P2}}
133
-
typealiasB2=protocol<P1,P2> // expected-warning {{'protocol<...>' composition syntax is deprecated; join the protocols using '&'}} {{16-32=P1 & P2}}
134
-
typealiasB3=protocol<P1,P2> // expected-warning {{'protocol<...>' composition syntax is deprecated; join the protocols using '&'}} {{16-32=P1 & P2}}
135
-
typealiasB4=protocol<P1,P2> // expected-warning {{'protocol<...>' composition syntax is deprecated; join the protocols using '&'}} {{16-33=P1 & P2}}
136
-
typealiasC1=protocol<Any,P1> // expected-warning {{'protocol<...>' composition syntax is deprecated and not needed here}} {{16-33=P1}}
137
-
typealiasC2=protocol<P1,Any> // expected-warning {{'protocol<...>' composition syntax is deprecated and not needed here}} {{16-33=P1}}
138
-
typealiasD=protocol<P1> // expected-warning {{'protocol<...>' composition syntax is deprecated and not needed here}} {{15-27=P1}}
139
-
typealiasE=protocol<Any> // expected-warning {{'protocol<...>' composition syntax is deprecated and not needed here}} {{15-28=Any}}
140
-
typealiasF=protocol<Any,Any> // expected-warning {{'protocol<...>' composition syntax is deprecated and not needed here}} {{15-33=Any}}
141
-
typealiasG=protocol<P1>.Type // expected-warning {{'protocol<...>' composition syntax is deprecated and not needed here}} {{15-27=P1}}
142
-
typealiasH=protocol<P1>! // expected-warning {{'protocol<...>' composition syntax is deprecated and not needed here}} {{15-28=P1!}}
143
-
typealiasJ=protocol<P1,P2>.Protocol // expected-warning {{'protocol<...>' composition syntax is deprecated; join the protocols using '&'}} {{15-31=(P1 & P2)}}
144
-
typealiasK=protocol<P1,P2>? // expected-warning {{'protocol<...>' composition syntax is deprecated; join the protocols using '&'}} {{15-32=(P1 & P2)?}}
126
+
varx:protocol<P5>=17 // expected-error {{'protocol<...>' composition syntax has been removed and is not needed here}} {{9-22=P5=}} expected-error {{'=' must have consistent whitespace on both sides}}
127
+
vary:protocol<P5,P7>=17 // expected-error {{'protocol<...>' composition syntax has been removed; join the protocols using '&'}} {{9-26=P5 & P7=}} expected-error {{'=' must have consistent whitespace on both sides}}
128
+
varz:protocol<P5,P7>?=17 // expected-error {{'protocol<...>' composition syntax has been removed; join the protocols using '&'}} {{9-27=(P5 & P7)?=}}
129
+
130
+
typealiasA1=protocol<> // expected-error {{'protocol<>' syntax has been removed; use 'Any' instead}} {{16-26=Any}}
131
+
typealiasA2=protocol<>? // expected-error {{'protocol<>' syntax has been removed; use 'Any' instead}} {{16-27=Any?}}
132
+
typealiasB1=protocol<P1,P2> // expected-error {{'protocol<...>' composition syntax has been removed; join the protocols using '&'}} {{16-31=P1 & P2}}
133
+
typealiasB2=protocol<P1,P2> // expected-error {{'protocol<...>' composition syntax has been removed; join the protocols using '&'}} {{16-32=P1 & P2}}
134
+
typealiasB3=protocol<P1,P2> // expected-error {{'protocol<...>' composition syntax has been removed; join the protocols using '&'}} {{16-32=P1 & P2}}
135
+
typealiasB4=protocol<P1,P2> // expected-error {{'protocol<...>' composition syntax has been removed; join the protocols using '&'}} {{16-33=P1 & P2}}
136
+
typealiasC1=protocol<Any,P1> // expected-error {{'protocol<...>' composition syntax has been removed and is not needed here}} {{16-33=P1}}
137
+
typealiasC2=protocol<P1,Any> // expected-error {{'protocol<...>' composition syntax has been removed and is not needed here}} {{16-33=P1}}
138
+
typealiasD=protocol<P1> // expected-error {{'protocol<...>' composition syntax has been removed and is not needed here}} {{15-27=P1}}
139
+
typealiasE=protocol<Any> // expected-error {{'protocol<...>' composition syntax has been removed and is not needed here}} {{15-28=Any}}
140
+
typealiasF=protocol<Any,Any> // expected-error {{'protocol<...>' composition syntax has been removed and is not needed here}} {{15-33=Any}}
141
+
typealiasG=protocol<P1>.Type // expected-error {{'protocol<...>' composition syntax has been removed and is not needed here}} {{15-27=P1}}
142
+
typealiasH=protocol<P1>! // expected-error {{'protocol<...>' composition syntax has been removed and is not needed here}} {{15-28=P1!}}
143
+
typealiasJ=protocol<P1,P2>.Protocol // expected-error {{'protocol<...>' composition syntax has been removed; join the protocols using '&'}} {{15-31=(P1 & P2)}}
144
+
typealiasK=protocol<P1,P2>? // expected-error {{'protocol<...>' composition syntax has been removed; join the protocols using '&'}} {{15-32=(P1 & P2)?}}
145
145
146
146
typealiasT01=P1.Protocol&P2 // expected-error {{non-protocol, non-class type 'P1.Protocol' cannot be used within a protocol-constrained type}}
147
147
typealiasT02=P1.Type&P2 // expected-error {{non-protocol, non-class type 'P1.Type' cannot be used within a protocol-constrained type}}
148
148
typealiasT03=P1?&P2 // expected-error {{non-protocol, non-class type 'P1?' cannot be used within a protocol-constrained type}}
149
149
typealiasT04=P1&P2! // expected-error {{non-protocol, non-class type 'P2!' cannot be used within a protocol-constrained type}} expected-error {{implicitly unwrapped optionals}} {{24-25=?}}
typealiasT07=P1&protocol<P2,P3> // expected-warning {{protocol<...>' composition syntax is deprecated; join the protocols using '&'}} {{22-38=P2 & P3}}
152
+
typealiasT07=P1&protocol<P2,P3> // expected-error {{protocol<...>' composition syntax has been removed; join the protocols using '&'}} {{22-38=P2 & P3}}
153
153
func fT07(x:T07)->P1&P2&P3{return x } // OK, 'P1 & protocol<P2, P3>' is parsed as 'P1 & P2 & P3'.
154
154
let _:P1&P2&P3->P1&P2&P3= fT07 // expected-error {{single argument function types require parentheses}} {{8-8=(}} {{20-20=)}}
155
155
@@ -160,9 +160,9 @@ struct S04<T : P5 & (P6)> {} // expected-error {{inheritance from non-named type
160
160
structS05<T>where T :P5?&P6{} // expected-error {{inheritance from non-named type 'P5?'}}
161
161
162
162
// SR-3124 - Protocol Composition Often Migrated Incorrectly
163
-
structS3124<T:protocol<P1,P3>>{} // expected-warning {{'protocol<...>' composition syntax is deprecated; join the protocols using '&'}} {{17-34=P1 & P3>}}
164
-
func f3124_1<U where U:protocol<P1,P3>>(x:U){} // expected-warning {{'protocol<...>' composition syntax is deprecated; join the protocols using '&'}} {{25-42=P1 & P3>}} // expected-error {{'where' clause}}
165
-
func f3124_2<U :protocol<P1>>(x:U){} // expected-warning {{'protocol<...>' composition syntax is deprecated and not needed here}} {{18-31=P1>}}
163
+
structS3124<T:protocol<P1,P3>>{} // expected-error {{'protocol<...>' composition syntax has been removed; join the protocols using '&'}} {{17-34=P1 & P3>}}
164
+
func f3124_1<U where U:protocol<P1,P3>>(x:U){} // expected-error {{'protocol<...>' composition syntax has been removed; join the protocols using '&'}} {{25-42=P1 & P3>}} // expected-error {{'where' clause}}
165
+
func f3124_2<U :protocol<P1>>(x:U){} // expected-error {{'protocol<...>' composition syntax has been removed and is not needed here}} {{18-31=P1>}}
166
166
167
167
// Make sure we correctly form compositions in expression context
0 commit comments