Skip to content

Commit abe00a8

Browse files
committed
Test active code regions with postfix #if
1 parent e07f68a commit abe00a8

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

Sources/SwiftIfConfig/IfConfigRewriter.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,6 @@ class ActiveSyntaxRewriter<Configuration: BuildConfiguration>: SyntaxRewriter {
287287
return applyBaseToPostfixExpression(base: base, postfix: postfixExpr)
288288
}
289289

290-
// FIXME: PostfixIfConfigExprSyntax has a different form that doesn't work
291-
// well with the way dropInactive is written. We essentially need to
292-
// thread a the "base" into the active clause.
293290
override func visit(_ node: PostfixIfConfigExprSyntax) -> ExprSyntax {
294291
let rewrittenNode = dropInactive(outerBase: nil, postfixIfConfig: node)
295292
if rewrittenNode == ExprSyntax(node) {

Tests/SwiftIfConfigTest/ActiveRegionTests.swift

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,33 @@ public class ActiveRegionTests: XCTestCase {
5151
]
5252
)
5353
}
54+
55+
func testActiveRegionsInPostfix() throws {
56+
try assertActiveCode(
57+
"""
58+
4️⃣a.b()
59+
#if DEBUG
60+
0️⃣.c()
61+
#elseif ASSERTS
62+
1️⃣.d()
63+
#if compiler(>=8.0)
64+
2️⃣.e()
65+
#else
66+
3️⃣.f()
67+
#endif
68+
#endif
69+
5️⃣.g()
70+
""",
71+
configuration: linuxBuildConfig,
72+
states: [
73+
"0️⃣": .active,
74+
"1️⃣": .inactive,
75+
"2️⃣": .unparsed,
76+
"3️⃣": .inactive,
77+
"4️⃣": .active,
78+
"5️⃣": .active,
79+
]
80+
)
81+
82+
}
5483
}

0 commit comments

Comments
 (0)