@@ -783,9 +783,9 @@ static ApplyInst *getAsOSLogMessageInit(SILInstruction *inst) {
783
783
return nullptr ;
784
784
}
785
785
786
- // / Return true iff this function is a protocol witness for
787
- // / ExpressibleByStringInterpolation.init(stringInterpolation:) in OSLogMessage .
788
- bool isAutoGeneratedInitOfOSLogMessage (SILFunction &fun) {
786
+ // / Return true iff the SIL function \c fun is a method of the \c OSLogMessage
787
+ // / type .
788
+ bool isMethodOfOSLogMessage (SILFunction &fun) {
789
789
DeclContext *declContext = fun.getDeclContext ();
790
790
if (!declContext)
791
791
return false ;
@@ -818,11 +818,15 @@ class OSLogOptimization : public SILFunctionTransform {
818
818
return ;
819
819
}
820
820
821
- // Skip the auto-generated (transparent) witness method of OSLogMessage,
822
- // which ends up invoking the OSLogMessage initializer:
823
- // "oslog.message.init_interpolation" but without an interpolated
824
- // string literal.
825
- if (isAutoGeneratedInitOfOSLogMessage (fun)) {
821
+ // Skip methods of OSLogMessage type. This avoid unnecessary work and also
822
+ // avoids falsely diagnosing the auto-generated (transparent) witness method
823
+ // of OSLogMessage, which ends up invoking the OSLogMessage initializer:
824
+ // "oslog.message.init_interpolation" without an interpolated string
825
+ // literal that is expected by this pass.
826
+ // TODO: this check can be eliminated if there is a separate pass for
827
+ // diagnosing errors in the use of the OSLogMessage type, and this pass
828
+ // bails out when a use of the type is not optimizable.
829
+ if (isMethodOfOSLogMessage (fun)) {
826
830
return ;
827
831
}
828
832
0 commit comments