@@ -2035,10 +2035,18 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
2035
2035
2036
2036
override func visit( _ node: DifferentiableAttributeArgumentsSyntax ) -> SyntaxVisitorContinueKind {
2037
2037
// This node encapsulates the entire list of arguments in a `@differentiable(...)` attribute.
2038
- after ( node. diffParamsComma, tokens: . break( . same) )
2039
-
2040
2038
var needsBreakBeforeWhereClause = false
2041
2039
2040
+ if let diffParamsComma = node. diffParamsComma {
2041
+ after ( diffParamsComma, tokens: . break( . same) )
2042
+ } else if node. diffParams != nil {
2043
+ // If there were diff params but no comma following them, then we have "wrt: foo where ..."
2044
+ // and we need a break before the where clause.
2045
+ needsBreakBeforeWhereClause = true
2046
+ }
2047
+
2048
+ // TODO: These properties will likely go away in a future version since the parser no longer
2049
+ // reads the `vjp:` and `jvp:` arguments to `@differentiable`.
2042
2050
if let vjp = node. maybeVJP {
2043
2051
before ( vjp. firstToken, tokens: . open)
2044
2052
after ( vjp. lastToken, tokens: . close)
@@ -2051,6 +2059,7 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
2051
2059
after ( jvp. trailingComma, tokens: . break( . same) )
2052
2060
needsBreakBeforeWhereClause = true
2053
2061
}
2062
+
2054
2063
if let whereClause = node. whereClause {
2055
2064
if needsBreakBeforeWhereClause {
2056
2065
before ( whereClause. firstToken, tokens: . break( . same) )
@@ -2066,6 +2075,8 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
2066
2075
{
2067
2076
// This node encapsulates the `vjp:` or `jvp:` label and decl name in a `@differentiable`
2068
2077
// attribute.
2078
+ // TODO: This node will likely go away in a future version since the parser no longer reads the
2079
+ // `vjp:` and `jvp:` arguments to `@differentiable`.
2069
2080
after ( node. colon, tokens: . break( . continue, newlines: . elective( ignoresDiscretionary: true ) ) )
2070
2081
return . visitChildren
2071
2082
}
0 commit comments