File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -1215,8 +1215,11 @@ extension Parser {
1215
1215
let unexpectedAfterIdentifier : RawUnexpectedNodesSyntax ?
1216
1216
let identifier : RawTokenSyntax
1217
1217
if self . at ( anyIn: Operator . self) != nil || self . at ( . exclamationMark, . prefixAmpersand) {
1218
+ // If the name is an operator token that ends in '<' followed by an identifier or 'let',
1219
+ // leave the '<' so it's parsed as a generic parameter clause. This allows things like
1220
+ // 'func ==<T>(x:T, y:T) {}'.
1218
1221
var name = self . currentToken. tokenText
1219
- if !currentToken. isEditorPlaceholder && name. hasSuffix ( " < " ) && self . peek ( isAt: . identifier) {
1222
+ if !currentToken. isEditorPlaceholder && name. hasSuffix ( " < " ) && self . peek ( isAt: . identifier, . keyword ( . let ) ) {
1220
1223
name = SyntaxText ( rebasing: name. dropLast ( ) )
1221
1224
}
1222
1225
unexpectedBeforeIdentifier = nil
Original file line number Diff line number Diff line change @@ -287,4 +287,12 @@ final class ValueGenericsTests: ParserTestCase {
287
287
fixedSource: " func foo() -> (<#type#>-1) X "
288
288
)
289
289
}
290
+
291
+ func testOperatorFunc( ) {
292
+ assertParse (
293
+ """
294
+ func *<let X: Int, let Y: Int>(l: A<X>, r: A<Y>) -> Int { l.int * r.int }
295
+ """
296
+ )
297
+ }
290
298
}
You can’t perform that action at this time.
0 commit comments