Skip to content

Commit 6f1a774

Browse files
committed
[ModuleInterface] Always ignore export-as in private swiftinterfaces
Always print the real module name for references in private swiftinterfaces, ignoring export-as declarations. Keep using the export-as name for the public swiftinterface only. The flag `ModuleInterfaceExportAs` used to enable this behavior and we're removing it to make it the default. rdar://115922907
1 parent 042ccdd commit 6f1a774

File tree

5 files changed

+20
-49
lines changed

5 files changed

+20
-49
lines changed

include/swift/Basic/Features.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ EXPERIMENTAL_FEATURE(OneWayClosureParameters, false)
147147
EXPERIMENTAL_FEATURE(TypeWitnessSystemInference, false)
148148
EXPERIMENTAL_FEATURE(LayoutPrespecialization, true)
149149

150-
EXPERIMENTAL_FEATURE(ModuleInterfaceExportAs, true)
151150
EXPERIMENTAL_FEATURE(AccessLevelOnImport, true)
152151

153152
/// Whether to enable experimental layout string value witnesses

lib/AST/ASTPrinter.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3312,10 +3312,6 @@ static bool usesFeatureLayoutStringValueWitnessesInstantiation(Decl *decl) {
33123312
return false;
33133313
}
33143314

3315-
static bool usesFeatureModuleInterfaceExportAs(Decl *decl) {
3316-
return false;
3317-
}
3318-
33193315
static bool usesFeatureAccessLevelOnImport(Decl *decl) {
33203316
return false;
33213317
}

lib/Frontend/ModuleInterfaceSupport.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -821,13 +821,7 @@ bool swift::emitSwiftInterface(raw_ostream &out,
821821

822822
printImports(out, Opts, M, aliasModuleNamesTargets);
823823

824-
static bool forceUseExportedModuleNameInPublicOnly =
825-
getenv("SWIFT_DEBUG_USE_EXPORTED_MODULE_NAME_IN_PUBLIC_ONLY");
826-
bool useExportedModuleNameInPublicOnly =
827-
M->getASTContext().LangOpts.hasFeature(Feature::ModuleInterfaceExportAs) ||
828-
forceUseExportedModuleNameInPublicOnly;
829-
bool useExportedModuleNames = !(useExportedModuleNameInPublicOnly &&
830-
Opts.PrintPrivateInterfaceContent);
824+
bool useExportedModuleNames = !Opts.PrintPrivateInterfaceContent;
831825

832826
const PrintOptions printOptions = PrintOptions::printSwiftInterfaceFile(
833827
M, Opts.PreserveTypesAsWritten, Opts.PrintFullConvention,

test/ModuleInterface/export-as-in-swiftinterfaces.swift

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
// RUN: %target-swift-typecheck-module-from-interface(%t/Exported.swiftinterface) -I %t -module-name Exporter
2222

2323
/// Build lib with an @exported import of the exported one.
24-
/// Default/old behavior.
2524
// RUN: %target-swift-frontend -emit-module %t/Exporter.swift \
2625
// RUN: -module-name Exporter -swift-version 5 -I %t \
2726
// RUN: -enable-library-evolution \
@@ -31,26 +30,10 @@
3130
// RUN: %target-swift-typecheck-module-from-interface(%t/Exporter.swiftinterface) -I %t
3231
// RUN: %target-swift-typecheck-module-from-interface(%t/Exporter.private.swiftinterface) -module-name Exporter -I %t
3332
// RUN: cat %t/Exporter.swiftinterface | %FileCheck -check-prefix=CHECK-USE-EXPORTER %s
34-
// RUN: cat %t/Exporter.private.swiftinterface | %FileCheck -check-prefix=CHECK-USE-EXPORTER %s
35-
36-
/// Build lib with an @exported import of the exported one.
37-
/// New behavior via flag.
38-
// RUN: %target-swift-frontend -emit-module %t/Exporter.swift \
39-
// RUN: -module-name Exporter -swift-version 5 -I %t \
40-
// RUN: -enable-library-evolution \
41-
// RUN: -emit-module-path %t/Exporter.swiftmodule \
42-
// RUN: -emit-module-interface-path %t/Exporter.swiftinterface \
43-
// RUN: -emit-private-module-interface-path %t/Exporter.private.swiftinterface \
44-
// RUN: -enable-experimental-feature ModuleInterfaceExportAs
45-
// RUN: %target-swift-typecheck-module-from-interface(%t/Exporter.swiftinterface) -I %t
46-
// RUN: %target-swift-typecheck-module-from-interface(%t/Exporter.private.swiftinterface) -module-name Exporter -I %t
47-
// RUN: cat %t/Exporter.swiftinterface | %FileCheck -check-prefix=CHECK-USE-EXPORTER %s
4833
// RUN: cat %t/Exporter.private.swiftinterface | %FileCheck -check-prefix=CHECK-USE-EXPORTED %s
4934

5035
/// Build lib with an @exported import of the exported one.
51-
/// New behavior via env var.
52-
// RUN: env SWIFT_DEBUG_USE_EXPORTED_MODULE_NAME_IN_PUBLIC_ONLY=1 \
53-
// RUN: %target-swift-frontend -emit-module %t/Exporter.swift \
36+
// RUN: %target-swift-frontend -emit-module %t/Exporter.swift \
5437
// RUN: -module-name Exporter -swift-version 5 -I %t \
5538
// RUN: -enable-library-evolution \
5639
// RUN: -emit-module-path %t/Exporter.swiftmodule \
@@ -67,22 +50,20 @@
6750
// RUN: -enable-library-evolution \
6851
// RUN: -emit-module-path %t/Client.swiftmodule \
6952
// RUN: -emit-module-interface-path %t/Client.swiftinterface \
70-
// RUN: -emit-private-module-interface-path %t/Client.private.swiftinterface \
71-
// RUN: -enable-experimental-feature ModuleInterfaceExportAs
53+
// RUN: -emit-private-module-interface-path %t/Client.private.swiftinterface
7254
// RUN: %target-swift-typecheck-module-from-interface(%t/Client.swiftinterface) -I %t
7355
// RUN: %target-swift-typecheck-module-from-interface(%t/Client.private.swiftinterface) -module-name Client -I %t
7456
// RUN: cat %t/Client.swiftinterface | %FileCheck -check-prefix=CHECK-USE-EXPORTER %s
7557
// RUN: cat %t/Client.private.swiftinterface | %FileCheck -check-prefix=CHECK-USE-EXPORTED %s
7658

77-
/// Build a client of the exporter lib.
59+
/// Build a client of the exporter lib against the public swiftinterface.
7860
// RUN: rm %t/Exporter.private.swiftinterface %t/Exporter.swiftmodule
7961
// RUN: %target-swift-frontend -emit-module %t/Client.swift \
8062
// RUN: -module-name Client -swift-version 5 -I %t \
8163
// RUN: -enable-library-evolution \
8264
// RUN: -emit-module-path %t/Client.swiftmodule \
8365
// RUN: -emit-module-interface-path %t/Client.swiftinterface \
84-
// RUN: -emit-private-module-interface-path %t/Client.private.swiftinterface \
85-
// RUN: -enable-experimental-feature ModuleInterfaceExportAs
66+
// RUN: -emit-private-module-interface-path %t/Client.private.swiftinterface
8667
// RUN: %target-swift-typecheck-module-from-interface(%t/Client.swiftinterface) -I %t
8768
// RUN: %target-swift-typecheck-module-from-interface(%t/Client.private.swiftinterface) -module-name Client -I %t
8869
// RUN: cat %t/Client.swiftinterface | %FileCheck -check-prefix=CHECK-USE-EXPORTER %s

test/ModuleInterface/swift-export-as.swift

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// RUN: %empty-directory(%t)
22
// RUN: split-file %s %t
33

4+
/// Build exportee.
45
// RUN: %target-swift-frontend -emit-module %t/PrivateLib.swift \
56
// RUN: -swift-version 5 -enable-library-evolution \
67
// RUN: -export-as PublicLib \
@@ -13,6 +14,7 @@
1314
// RUN: cat %t/PrivateLib.swiftinterface | %FileCheck --check-prefixes=PRIVATELIB-PUBLIC %s
1415
// RUN: cat %t/PrivateLib.private.swiftinterface | %FileCheck --check-prefixes=PRIVATELIB-PUBLIC %s
1516

17+
/// Build exporter.
1618
// RUN: %target-swift-frontend -emit-module %t/PublicLib.swift -I %t \
1719
// RUN: -swift-version 5 -enable-library-evolution \
1820
// RUN: -o %t/PublicLib.swiftmodule \
@@ -22,42 +24,40 @@
2224
// RUN: %target-swift-typecheck-module-from-interface(%t/PublicLib.private.swiftinterface) -I %t \
2325
// RUN: -module-name PublicLib
2426
// RUN: cat %t/PublicLib.swiftinterface | %FileCheck --check-prefixes=PUBLICLIB-PUBLIC %s
25-
// RUN: cat %t/PublicLib.private.swiftinterface | %FileCheck --check-prefixes=PUBLICLIB-PUBLIC %s
27+
// RUN: cat %t/PublicLib.private.swiftinterface | %FileCheck --check-prefixes=PUBLICLIB-PRIVATE %s
2628

27-
/// Default logic applying export-as in both swiftinterface.
29+
/// Build client.
2830
// RUN: %target-swift-frontend -emit-module %t/ClientLib.swift -I %t \
2931
// RUN: -swift-version 5 -enable-library-evolution \
3032
// RUN: -o %t/ClientLib.swiftmodule \
3133
// RUN: -emit-module-interface-path %t/ClientLib.swiftinterface \
3234
// RUN: -emit-private-module-interface-path %t/ClientLib.private.swiftinterface
3335
// RUN: %target-swift-typecheck-module-from-interface(%t/ClientLib.swiftinterface) -I %t
34-
// RUN: %target-swift-typecheck-module-from-interface(%t/ClientLib.private.swiftinterface) -I %t
36+
// RUN: %target-swift-typecheck-module-from-interface(%t/ClientLib.private.swiftinterface) -I %t -module-name ClientLib
3537
// RUN: cat %t/ClientLib.swiftinterface | %FileCheck --check-prefixes=CLIENT-PUBLIC %s
36-
// RUN: cat %t/ClientLib.private.swiftinterface | %FileCheck --check-prefixes=CLIENT-PUBLIC %s
38+
// RUN: cat %t/ClientLib.private.swiftinterface | %FileCheck --check-prefixes=CLIENT-PRIVATE %s
3739

38-
/// New logic applying export-as only in the public swiftinterface with
39-
/// `-enable-experimental-feature ModuleInterfaceExportAs`.
40+
/// Build client against private swiftinterfaces.
41+
// RUN: rm -f %t/PrivateLib.swiftmodule %t/PublicLib.swiftmodule
4042
// RUN: %target-swift-frontend -emit-module %t/ClientLib.swift -I %t \
4143
// RUN: -swift-version 5 -enable-library-evolution \
4244
// RUN: -o %t/ClientLib.swiftmodule \
4345
// RUN: -emit-module-interface-path %t/ClientLib.swiftinterface \
44-
// RUN: -emit-private-module-interface-path %t/ClientLib.private.swiftinterface \
45-
// RUN: -enable-experimental-feature ModuleInterfaceExportAs
46+
// RUN: -emit-private-module-interface-path %t/ClientLib.private.swiftinterface
4647
// RUN: %target-swift-typecheck-module-from-interface(%t/ClientLib.swiftinterface) -I %t
47-
// RUN: %target-swift-typecheck-module-from-interface(%t/ClientLib.private.swiftinterface) -I %t
48+
// RUN: %target-swift-typecheck-module-from-interface(%t/ClientLib.private.swiftinterface) -I %t -module-name ClientLib
4849
// RUN: cat %t/ClientLib.swiftinterface | %FileCheck --check-prefixes=CLIENT-PUBLIC %s
4950
// RUN: cat %t/ClientLib.private.swiftinterface | %FileCheck --check-prefixes=CLIENT-PRIVATE %s
5051

51-
/// Check that we get the same behavior using swiftinterfaces only.
52-
// RUN: rm -f %t/PrivateLib.swiftmodule %t/PublicLib.swiftmodule
52+
/// Build client against public swiftinterfaces, for the same result.
53+
// RUN: rm -f %t/PrivateLib.private.swiftinterface %t/PublicLib.private.swiftinterface
5354
// RUN: %target-swift-frontend -emit-module %t/ClientLib.swift -I %t \
5455
// RUN: -swift-version 5 -enable-library-evolution \
5556
// RUN: -o %t/ClientLib.swiftmodule \
5657
// RUN: -emit-module-interface-path %t/ClientLib.swiftinterface \
57-
// RUN: -emit-private-module-interface-path %t/ClientLib.private.swiftinterface \
58-
// RUN: -enable-experimental-feature ModuleInterfaceExportAs
58+
// RUN: -emit-private-module-interface-path %t/ClientLib.private.swiftinterface
5959
// RUN: %target-swift-typecheck-module-from-interface(%t/ClientLib.swiftinterface) -I %t
60-
// RUN: %target-swift-typecheck-module-from-interface(%t/ClientLib.private.swiftinterface) -I %t
60+
// RUN: %target-swift-typecheck-module-from-interface(%t/ClientLib.private.swiftinterface) -I %t -module-name ClientLib
6161
// RUN: cat %t/ClientLib.swiftinterface | %FileCheck --check-prefixes=CLIENT-PUBLIC %s
6262
// RUN: cat %t/ClientLib.private.swiftinterface | %FileCheck --check-prefixes=CLIENT-PRIVATE %s
6363

@@ -76,6 +76,7 @@ public struct PublicNameStruct {}
7676

7777
public func publicLibUser(_ arg: PrivateNameStruct) {}
7878
// PUBLICLIB-PUBLIC: arg: PublicLib.PrivateNameStruct
79+
// PUBLICLIB-PRIVATE: arg: PrivateLib.PrivateNameStruct
7980

8081
//--- ClientLib.swift
8182

0 commit comments

Comments
 (0)