[ModuleInterfaces] Escape Type and Protocol when module-qualifying

If we see `MyModule.Type`, the parser thinks this is a metatype type.
Escape the name `Type` so the parser can recognize it's a type name.

Fixes [SR-11422](https://bugs.swift.org/browse/SR-11422) rdar://55094784
This commit is contained in:
Harlan Haskins
2019-09-05 18:16:24 -07:00
parent 568f615a09
commit 2893d96927
8 changed files with 105 additions and 69 deletions

View File

@@ -57,11 +57,13 @@ public:
:XMLEscapingPrinter(OS) { }
private:
void printTypeRef(Type T, const TypeDecl *TD, Identifier Name) override {
void printTypeRef(
Type T, const TypeDecl *TD, Identifier Name,
PrintNameContext NameContext = PrintNameContext::Normal) override {
printXML("<Type usr=\"");
SwiftLangSupport::printUSR(TD, OS);
printXML("\">");
StreamPrinter::printTypeRef(T, TD, Name);
StreamPrinter::printTypeRef(T, TD, Name, NameContext);
printXML("</Type>");
}
};
@@ -272,11 +274,13 @@ private:
closeTag(tag);
}
void printTypeRef(Type T, const TypeDecl *TD, Identifier name) override {
void printTypeRef(
Type T, const TypeDecl *TD, Identifier name,
PrintNameContext NameContext = PrintNameContext::Normal) override {
auto tag = getTagForDecl(TD, /*isRef=*/true);
openTagWithUSRForDecl(tag, TD);
insideRef = true;
XMLEscapingPrinter::printTypeRef(T, TD, name);
XMLEscapingPrinter::printTypeRef(T, TD, name, NameContext);
insideRef = false;
closeTag(tag);
}