File tree Expand file tree Collapse file tree 3 files changed +9
-5
lines changed Expand file tree Collapse file tree 3 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -468,8 +468,10 @@ ParserResult<TypeRepr> Parser::parseTypeIdentifierOrTypeComposition() {
468468 StringRef TrailingContent = L->getTokenAt (RAngleLoc).getRange ().str ().
469469 substr (1 );
470470 if (!TrailingContent.empty ()) {
471- replacement.insert (replacement.begin (), ' (' );
472- replacement += " )" ;
471+ if (Protocols.size () > 1 ) {
472+ replacement.insert (replacement.begin (), ' (' );
473+ replacement += " )" ;
474+ }
473475 replacement += TrailingContent;
474476 }
475477
Original file line number Diff line number Diff line change @@ -308,4 +308,4 @@ func testBoolValue(a : BoolFoo) {
308308protocol P1 {}
309309protocol P2 {}
310310var a : (P1 & P2)?
311- var a2 : (P1) = 17 as! P1
311+ var a2 : P1 = 17 as! P1
Original file line number Diff line number Diff line change @@ -123,9 +123,11 @@ func testConversion() {
123123}
124124
125125// Test the parser's splitting of >= into > and =.
126- var x : protocol < P5 > = 17 // expected-warning {{'protocol<...>' composition syntax is deprecated and not needed here}} {{9-22=(P5)=}}
126+ var x : protocol < P5 > = 17 // expected-warning {{'protocol<...>' composition syntax is deprecated and not needed here}} {{9-22=P5=}}
127+ var y : protocol < P5 , P7 > = 17 // expected-warning {{'protocol<...>' composition syntax is deprecated; join the protocols using '&'}} {{9-26=(P5 & P7)=}}
127128
128- typealias A = protocol < > // expected-warning {{'protocol<>' syntax is deprecated; use 'Any' instead}} {{15-25=Any}}
129+ typealias A1 = protocol < > // expected-warning {{'protocol<>' syntax is deprecated; use 'Any' instead}} {{16-26=Any}}
130+ typealias A2 = protocol < > ? // expected-warning {{'protocol<>' syntax is deprecated; use 'Any' instead}} {{16-27=Any?}}
129131typealias B1 = protocol < P1 , P2 > // expected-warning {{'protocol<...>' composition syntax is deprecated; join the protocols using '&'}} {{16-31=P1 & P2}}
130132typealias B2 = protocol < P1 , P2 > // expected-warning {{'protocol<...>' composition syntax is deprecated; join the protocols using '&'}} {{16-32=P1 & P2}}
131133typealias B3 = protocol < P1 , P2 > // expected-warning {{'protocol<...>' composition syntax is deprecated; join the protocols using '&'}} {{16-32=P1 & P2}}
You can’t perform that action at this time.
0 commit comments