-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[InlinableText] Handle multiline #if conditions #19675
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
ce1a473
to
f499ecd
Compare
// CHECK-NOT: #if ( | ||
// CHECK-NOT: false && !true | ||
// CHECK-NOT: ) | ||
// CHECK-NOT: print("should not appear") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I think this test case it not testing the code change.
The change affects only for getActiveClause()
, but this block is not active...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code we have actually looks for inactive ranges, but I think you're right that we should see what happens with a multi-line active range too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant this test case should pass even without the change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rintaro You're right, I pushed before testing locally 😅 They should pass now.
// CHECK: print("should appear") | ||
// CHECK-NOT: #endif | ||
// CHECK-NEXT: }) | ||
public func hasClosureDefaultArgWithMultilinePoundIfCondition(_ x: () -> Void) = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe )
after () -> Void
is not intentional.
Previously, a #if of the form: ```swift #if ( false ) print("x") #endif ``` Would be emitted after #if-stripping as ```swift false ) print("x") ``` Because the old logic assumed conditions will always appear on one line. Instead, for active clauses that have conditions, skip to the next line after the end of the condition instead.
f499ecd
to
735eead
Compare
@swift-ci please smoke test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Previously, a #if of the form: ```swift #if ( false ) print("x") #endif ``` Would be emitted after #if-stripping as ```swift false ) print("x") ``` Because the old logic assumed conditions will always appear on one line. Instead, for active clauses that have conditions, skip to the next line after the end of the condition instead.
Previously, a #if of the form:
Would be emitted after #if-stripping as
Because the old logic assumed conditions will always appear on one line.
Instead, for active clauses that have conditions, skip to the next line
after the end of the condition instead.