Fix SR-13490: Fix LT operator and add tests for ImportPath

This commit is contained in:
Alexey Komnin
2020-09-26 02:35:27 +03:00
parent 163d47ec90
commit f18f3daba8
4 changed files with 79 additions and 11 deletions

View File

@@ -374,15 +374,7 @@ static bool printModuleInterfaceDecl(Decl *D,
/// Sorts import declarations for display.
static bool compareImports(ImportDecl *LHS, ImportDecl *RHS) {
// TODO(SR-13490): Probably buggy--thinks "import Foo" == "import Foo.Bar".
// ImportPathBase should provide universal comparison functions to avoid this.
auto LHSPath = LHS->getImportPath();
auto RHSPath = RHS->getImportPath();
for (unsigned i: range(std::min(LHSPath.size(), RHSPath.size()))) {
if (int Ret = LHSPath[i].Item.str().compare(RHSPath[i].Item.str()))
return Ret < 0;
}
return false;
return LHS->getImportPath() < RHS->getImportPath();
};
/// Sorts Swift declarations for display.