Skip to content

Commit 5dbdb87

Browse files
committed
[Frontend] Allow aliasing the stdlib Swift module
1 parent ea2f222 commit 5dbdb87

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

lib/Frontend/ArgsToFrontendOptionsConverter.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -755,15 +755,12 @@ bool ModuleAliasesConverter::computeModuleAliases(std::vector<std::string> args,
755755
if (!allowModuleName) {
756756
if (value == options.ModuleName ||
757757
value == options.ModuleABIName ||
758-
value == options.ModuleLinkName) {
758+
value == options.ModuleLinkName ||
759+
value == STDLIB_NAME) {
759760
diags.diagnose(SourceLoc(), diag::error_module_alias_forbidden_name, value);
760761
return false;
761762
}
762763
}
763-
if (value == STDLIB_NAME) {
764-
diags.diagnose(SourceLoc(), diag::error_module_alias_forbidden_name, value);
765-
return false;
766-
}
767764
if (!Lexer::isIdentifier(value)) {
768765
diags.diagnose(SourceLoc(), diag::error_bad_module_name, value, false);
769766
return false;

test/Frontend/module-alias-invalid-input.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
// RUN: not %target-swift-frontend -emit-silgen -parse-as-library %s -module-name foo -module-alias Swift=Bar 2>&1 | %FileCheck -check-prefix=INVALID_MODULE_ALIAS1 %s
77
// INVALID_MODULE_ALIAS1: error: invalid module alias "Swift"; make sure the alias differs from the module name, module ABI name, module link name, and a standard library name
8+
// RUN: %target-swift-frontend -emit-silgen -parse-as-library %s -module-name foo -module-alias Bar=Swift -verify
89

910
// RUN: not %target-swift-frontend -emit-silgen -parse-as-library %s -module-name foo -module-alias bar=bar 2>&1 | %FileCheck -check-prefix=INVALID_MODULE_ALIAS2 %s
1011
// INVALID_MODULE_ALIAS2: error: duplicate module alias; the name "bar" is already used for a module alias or an underlying name

0 commit comments

Comments
 (0)