[interop] SourceKit should retry generating module interface with C++ interop enabled

Sometimes the request might not have it enabled explicitly
This commit is contained in:
Alex Lorenz
2023-02-01 16:05:14 -08:00
parent 07ccee2b76
commit 72050c5385
2 changed files with 64 additions and 2 deletions

View File

@@ -694,8 +694,26 @@ void SwiftLangSupport::editorOpenInterface(EditorConsumer &Consumer,
SynthesizedExtensions,
InterestedUSR);
if (!IFaceGenRef) {
Consumer.handleRequestError(ErrMsg.c_str());
return;
// Retry to generate a module interface with C++ interop enabled,
// if the first attempt failed.
bool retryWithCxxEnabled = true;
for (const auto &arg: Args) {
if (StringRef(arg).startswith("-cxx-interoperability-mode=") ||
StringRef(arg).startswith("-enable-experimental-cxx-interop")) {
retryWithCxxEnabled = false;
break;
}
}
if (retryWithCxxEnabled) {
std::vector<const char *> AdjustedArgs(Args.begin(), Args.end());
AdjustedArgs.push_back("-cxx-interoperability-mode=swift-5.9");
return editorOpenInterface(Consumer, Name, ModuleName, Group, AdjustedArgs,
SynthesizedExtensions, InterestedUSR);
}
else {
Consumer.handleRequestError(ErrMsg.c_str());
return;
}
}
IFaceGenRef->reportEditorInfo(Consumer);