@@ -734,7 +734,7 @@ extension Parser {
734
734
// If we can parse trailing closures, do so.
735
735
let trailingClosure : RawClosureExprSyntax ?
736
736
let additionalTrailingClosures : RawMultipleTrailingClosureElementListSyntax ?
737
- if case . trailingClosure = flavor, self . at ( . leftBrace) , self . withLookahead ( { $0. isValidTrailingClosure ( flavor) } ) {
737
+ if case . trailingClosure = flavor, self . at ( . leftBrace) , self . withLookahead ( { $0. atValidTrailingClosure ( flavor) } ) {
738
738
( trailingClosure, additionalTrailingClosures) = self . parseTrailingClosures ( flavor)
739
739
} else {
740
740
trailingClosure = nil
@@ -770,7 +770,7 @@ extension Parser {
770
770
// If we can parse trailing closures, do so.
771
771
let trailingClosure : RawClosureExprSyntax ?
772
772
let additionalTrailingClosures : RawMultipleTrailingClosureElementListSyntax ?
773
- if case . trailingClosure = flavor, self . at ( . leftBrace) , self . withLookahead ( { $0. isValidTrailingClosure ( flavor) } ) {
773
+ if case . trailingClosure = flavor, self . at ( . leftBrace) , self . withLookahead ( { $0. atValidTrailingClosure ( flavor) } ) {
774
774
( trailingClosure, additionalTrailingClosures) = self . parseTrailingClosures ( flavor)
775
775
} else {
776
776
trailingClosure = nil
@@ -793,7 +793,7 @@ extension Parser {
793
793
}
794
794
795
795
// Check for a trailing closure, if allowed.
796
- if self . at ( . leftBrace) && self . withLookahead ( { $0. isValidTrailingClosure ( flavor) } ) {
796
+ if self . at ( . leftBrace) && self . withLookahead ( { $0. atValidTrailingClosure ( flavor) } ) {
797
797
// FIXME: if Result has a trailing closure, break out.
798
798
// Add dummy blank argument list to the call expression syntax.
799
799
let list = RawLabeledExprListSyntax ( elements: [ ] , arena: self . arena)
@@ -1321,7 +1321,7 @@ extension Parser {
1321
1321
// Parse the optional trailing closures.
1322
1322
let trailingClosure : RawClosureExprSyntax ?
1323
1323
let additionalTrailingClosures : RawMultipleTrailingClosureElementListSyntax ?
1324
- if case . trailingClosure = flavor, self . at ( . leftBrace) , self . withLookahead ( { $0. isValidTrailingClosure ( flavor) } ) {
1324
+ if case . trailingClosure = flavor, self . at ( . leftBrace) , self . withLookahead ( { $0. atValidTrailingClosure ( flavor) } ) {
1325
1325
( trailingClosure, additionalTrailingClosures) = self . parseTrailingClosures ( flavor)
1326
1326
} else {
1327
1327
trailingClosure = nil
@@ -1915,7 +1915,7 @@ extension Parser {
1915
1915
// Parse labeled trailing closures.
1916
1916
var elements = [ RawMultipleTrailingClosureElementSyntax] ( )
1917
1917
var loopProgress = LoopProgressCondition ( )
1918
- while self . withLookahead ( { $0. isStartOfLabelledTrailingClosure ( ) } ) && self . hasProgressed ( & loopProgress) {
1918
+ while self . withLookahead ( { $0. atStartOfLabelledTrailingClosure ( ) } ) && self . hasProgressed ( & loopProgress) {
1919
1919
let ( unexpectedBeforeLabel, label) = self . parseArgumentLabel ( )
1920
1920
let ( unexpectedBeforeColon, colon) = self . expect ( . colon)
1921
1921
let closure = self . parseClosureExpression ( )
@@ -1937,7 +1937,7 @@ extension Parser {
1937
1937
}
1938
1938
1939
1939
extension Parser . Lookahead {
1940
- mutating func isStartOfLabelledTrailingClosure ( ) -> Bool {
1940
+ mutating func atStartOfLabelledTrailingClosure ( ) -> Bool {
1941
1941
// Fast path: the next two tokens must be a label and a colon.
1942
1942
// But 'default:' is ambiguous with switch cases and we disallow it
1943
1943
// (unless escaped) even outside of switches.
@@ -1967,12 +1967,12 @@ extension Parser.Lookahead {
1967
1967
/// where the parser requires an expr-basic (which does not allow them). We
1968
1968
/// handle this by doing some lookahead in common situations. And later, Sema
1969
1969
/// will emit a diagnostic with a fixit to add wrapping parens.
1970
- mutating func isValidTrailingClosure ( _ flavor: Parser . ExprFlavor ) -> Bool {
1970
+ mutating func atValidTrailingClosure ( _ flavor: Parser . ExprFlavor ) -> Bool {
1971
1971
precondition ( self . at ( . leftBrace) , " Couldn't be a trailing closure " )
1972
1972
1973
1973
// If this is the start of a get/set accessor, then it isn't a trailing
1974
1974
// closure.
1975
- guard !self . withLookahead ( { $0. isStartOfGetSetAccessor ( ) } ) else {
1975
+ guard !self . withLookahead ( { $0. atStartOfGetSetAccessor ( ) } ) else {
1976
1976
return false
1977
1977
}
1978
1978
@@ -2149,7 +2149,7 @@ extension Parser {
2149
2149
while !self . at ( . endOfFile, . rightBrace) && !self . at ( . poundEndif, . poundElseif, . poundElse)
2150
2150
&& self . hasProgressed ( & elementsProgress)
2151
2151
{
2152
- if self . withLookahead ( { $0. isAtStartOfSwitchCase ( allowRecovery: false ) } ) {
2152
+ if self . withLookahead ( { $0. atStartOfSwitchCase ( allowRecovery: false ) } ) {
2153
2153
elements. append ( . switchCase( self . parseSwitchCase ( ) ) )
2154
2154
} else if self . canRecoverTo ( . poundIf) != nil {
2155
2155
// '#if' in 'case' position can enclose zero or more 'case' or 'default'
@@ -2206,7 +2206,7 @@ extension Parser {
2206
2206
)
2207
2207
)
2208
2208
)
2209
- } else if self . withLookahead ( { $0. isAtStartOfSwitchCase ( allowRecovery: true ) } ) {
2209
+ } else if self . withLookahead ( { $0. atStartOfSwitchCase ( allowRecovery: true ) } ) {
2210
2210
elements. append ( . switchCase( self . parseSwitchCase ( ) ) )
2211
2211
} else {
2212
2212
break
@@ -2217,7 +2217,7 @@ extension Parser {
2217
2217
2218
2218
mutating func parseSwitchCaseBody( ) -> RawCodeBlockItemListSyntax {
2219
2219
parseCodeBlockItemList ( until: {
2220
- $0. at ( . rightBrace) || $0. at ( . poundEndif, . poundElseif, . poundElse) || $0. withLookahead ( { $0. isStartOfConditionalSwitchCases ( ) } )
2220
+ $0. at ( . rightBrace) || $0. at ( . poundEndif, . poundElseif, . poundElse) || $0. withLookahead ( { $0. atStartOfConditionalSwitchCases ( ) } )
2221
2221
} )
2222
2222
}
2223
2223
0 commit comments