-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[Sema][os_log] Allow wrapping os_log strings within constant evaluable functions #32908
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
[Sema][os_log] Allow wrapping os_log strings within constant evaluable functions #32908
Conversation
@swift-ci Please test |
Build failed |
This failure looks like some noise. |
@swift-ci Please test macOS Platform |
Build failed |
This time the error is different and is in LLDB test suite: Swift/astcontext_error.test. This is also noise. |
@swift-ci Please smoke test |
@swift-ci Please test macOS platform |
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.
Looks good to me!
…e functions. As of now, the sema checks for os_log allow only string interpolations to be passed to the log calls. E.g. logger.log(foo("message")) would not be allowed. This PR relaxes this requirement and allows it as long as foo is annotated as @_semantics("constant_evaluable"). <rdar://problem/65842243>
3578d68
to
d827f58
Compare
Update the commit message to use the rdar problem for release/5.3 |
@swift-ci please test |
Build failed |
Build failed |
As of now, the sema checks for os_log allow only string interpolations to be passed to the log calls. E.g.
logger.log(foo("message"))
would not be allowed. This PR relaxes this requirement and allows it as long asfoo
is annotated as@_semantics("constant_evaluable")
.However, as a special case, this PR still prevents calling the initializer of
OSLogMessage
, which is annotated constant_evaluable, to create the log message. E.g.logger.log(OSLogMessage(stringLiteral: "message"))
would still be prevented. This is done to ensure that users who are new to the APIs do not reach out for theOSLogMessage
initializer to construct a message (by looking at the type of the argument).OSLogMessage
should be automatically created when passing string interpolations. So this condition is checked for and a diagnostic is emitted.rdar://problem/65842243