|
11 | 11 | //===----------------------------------------------------------------------===//
|
12 | 12 |
|
13 | 13 | #if compiler(>=6)
|
14 |
| -public import SwiftSyntax |
| 14 | +@_spi(ExperimentalLanguageFeatures) public import SwiftSyntax |
15 | 15 | #else
|
16 |
| -import SwiftSyntax |
| 16 | +@_spi(ExperimentalLanguageFeatures) import SwiftSyntax |
17 | 17 | #endif
|
18 | 18 |
|
19 | 19 | extension ExprSyntax {
|
@@ -104,8 +104,8 @@ extension OperatorTable {
|
104 | 104 | op: ExprSyntax,
|
105 | 105 | rhs: ExprSyntax
|
106 | 106 | ) -> ExprSyntax {
|
107 |
| - // If the left-hand side is a "try" or "await", hoist it up to encompass |
108 |
| - // the right-hand side as well. |
| 107 | + // If the left-hand side is a "try", "await", or "unsafe", hoist it up to |
| 108 | + // encompass the right-hand side as well. |
109 | 109 | if let tryExpr = lhs.as(TryExprSyntax.self) {
|
110 | 110 | return ExprSyntax(
|
111 | 111 | TryExprSyntax(
|
@@ -138,6 +138,24 @@ extension OperatorTable {
|
138 | 138 | )
|
139 | 139 | }
|
140 | 140 |
|
| 141 | + if let unsafeExpr = lhs.as(UnsafeExprSyntax.self) { |
| 142 | + return ExprSyntax( |
| 143 | + UnsafeExprSyntax( |
| 144 | + leadingTrivia: unsafeExpr.leadingTrivia, |
| 145 | + unsafeExpr.unexpectedBeforeUnsafeKeyword, |
| 146 | + unsafeKeyword: unsafeExpr.unsafeKeyword, |
| 147 | + unsafeExpr.unexpectedBetweenUnsafeKeywordAndExpression, |
| 148 | + expression: makeBinaryOperationExpr( |
| 149 | + lhs: unsafeExpr.expression, |
| 150 | + op: op, |
| 151 | + rhs: rhs |
| 152 | + ), |
| 153 | + unsafeExpr.unexpectedAfterExpression, |
| 154 | + trailingTrivia: unsafeExpr.trailingTrivia |
| 155 | + ) |
| 156 | + ) |
| 157 | + } |
| 158 | + |
141 | 159 | // The form of the binary operation depends on the operator itself,
|
142 | 160 | // which will be one of the unresolved infix operators.
|
143 | 161 |
|
|
0 commit comments