Skip to content

Commit 64cd96e

Browse files
authored
Merge pull request #69210 from xymus/export-as-module-interface-by-default
ModuleInterface: Always ignore export-as for printing references in private swiftinterfaces
2 parents 41dc466 + 471b228 commit 64cd96e

File tree

5 files changed

+25
-51
lines changed

5 files changed

+25
-51
lines changed

include/swift/Basic/Features.def

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

152-
EXPERIMENTAL_FEATURE(ModuleInterfaceExportAs, true)
153152
EXPERIMENTAL_FEATURE(AccessLevelOnImport, true)
154153

155154
/// 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
@@ -822,13 +822,7 @@ bool swift::emitSwiftInterface(raw_ostream &out,
822822

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

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

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

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

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
// RUN: -enable-library-evolution \
1111
// RUN: -emit-module-path %t/Exported.swiftmodule \
1212
// RUN: -emit-module-interface-path %t/Exported.swiftinterface \
13-
// RUN: -emit-private-module-interface-path %t/Exported.private.swiftinterface \
14-
// RUN: -enable-experimental-feature ModuleInterfaceExportAs
13+
// RUN: -emit-private-module-interface-path %t/Exported.private.swiftinterface
1514
// RUN: %target-swift-typecheck-module-from-interface(%t/Exported.private.swiftinterface) -module-name Exported -I %t
1615
// RUN: cat %t/Exported.swiftinterface | %FileCheck -check-prefix=CHECK-USE-EXPORTER %s
1716
// RUN: cat %t/Exported.private.swiftinterface | %FileCheck -check-prefix=CHECK-USE-EXPORTED %s
@@ -21,7 +20,6 @@
2120
// RUN: %target-swift-typecheck-module-from-interface(%t/Exported.swiftinterface) -I %t -module-name Exporter
2221

2322
/// Build lib with an @exported import of the exported one.
24-
/// Default/old behavior.
2523
// RUN: %target-swift-frontend -emit-module %t/Exporter.swift \
2624
// RUN: -module-name Exporter -swift-version 5 -I %t \
2725
// RUN: -enable-library-evolution \
@@ -31,26 +29,10 @@
3129
// RUN: %target-swift-typecheck-module-from-interface(%t/Exporter.swiftinterface) -I %t
3230
// RUN: %target-swift-typecheck-module-from-interface(%t/Exporter.private.swiftinterface) -module-name Exporter -I %t
3331
// 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
4832
// RUN: cat %t/Exporter.private.swiftinterface | %FileCheck -check-prefix=CHECK-USE-EXPORTED %s
4933

5034
/// 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 \
35+
// RUN: %target-swift-frontend -emit-module %t/Exporter.swift \
5436
// RUN: -module-name Exporter -swift-version 5 -I %t \
5537
// RUN: -enable-library-evolution \
5638
// RUN: -emit-module-path %t/Exporter.swiftmodule \
@@ -67,22 +49,20 @@
6749
// RUN: -enable-library-evolution \
6850
// RUN: -emit-module-path %t/Client.swiftmodule \
6951
// 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
52+
// RUN: -emit-private-module-interface-path %t/Client.private.swiftinterface
7253
// RUN: %target-swift-typecheck-module-from-interface(%t/Client.swiftinterface) -I %t
7354
// RUN: %target-swift-typecheck-module-from-interface(%t/Client.private.swiftinterface) -module-name Client -I %t
7455
// RUN: cat %t/Client.swiftinterface | %FileCheck -check-prefix=CHECK-USE-EXPORTER %s
7556
// RUN: cat %t/Client.private.swiftinterface | %FileCheck -check-prefix=CHECK-USE-EXPORTED %s
7657

77-
/// Build a client of the exporter lib.
58+
/// Build a client of the exporter lib against the public swiftinterface.
7859
// RUN: rm %t/Exporter.private.swiftinterface %t/Exporter.swiftmodule
7960
// RUN: %target-swift-frontend -emit-module %t/Client.swift \
8061
// RUN: -module-name Client -swift-version 5 -I %t \
8162
// RUN: -enable-library-evolution \
8263
// RUN: -emit-module-path %t/Client.swiftmodule \
8364
// 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
65+
// RUN: -emit-private-module-interface-path %t/Client.private.swiftinterface
8666
// RUN: %target-swift-typecheck-module-from-interface(%t/Client.swiftinterface) -I %t
8767
// RUN: %target-swift-typecheck-module-from-interface(%t/Client.private.swiftinterface) -module-name Client -I %t
8868
// RUN: cat %t/Client.swiftinterface | %FileCheck -check-prefix=CHECK-USE-EXPORTER %s

test/ModuleInterface/swift-export-as.swift

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

4+
/// Make sure the flag `ModuleInterfaceExportAs` doesn't raise an error.
5+
// RUN: %target-swift-frontend -emit-module %t/PrivateLib.swift \
6+
// RUN: -enable-experimental-feature ModuleInterfaceExportAs
7+
8+
/// Build exportee.
49
// RUN: %target-swift-frontend -emit-module %t/PrivateLib.swift \
510
// RUN: -swift-version 5 -enable-library-evolution \
611
// RUN: -export-as PublicLib \
@@ -13,6 +18,7 @@
1318
// RUN: cat %t/PrivateLib.swiftinterface | %FileCheck --check-prefixes=PRIVATELIB-PUBLIC %s
1419
// RUN: cat %t/PrivateLib.private.swiftinterface | %FileCheck --check-prefixes=PRIVATELIB-PUBLIC %s
1520

21+
/// Build exporter.
1622
// RUN: %target-swift-frontend -emit-module %t/PublicLib.swift -I %t \
1723
// RUN: -swift-version 5 -enable-library-evolution \
1824
// RUN: -o %t/PublicLib.swiftmodule \
@@ -22,42 +28,40 @@
2228
// RUN: %target-swift-typecheck-module-from-interface(%t/PublicLib.private.swiftinterface) -I %t \
2329
// RUN: -module-name PublicLib
2430
// RUN: cat %t/PublicLib.swiftinterface | %FileCheck --check-prefixes=PUBLICLIB-PUBLIC %s
25-
// RUN: cat %t/PublicLib.private.swiftinterface | %FileCheck --check-prefixes=PUBLICLIB-PUBLIC %s
31+
// RUN: cat %t/PublicLib.private.swiftinterface | %FileCheck --check-prefixes=PUBLICLIB-PRIVATE %s
2632

27-
/// Default logic applying export-as in both swiftinterface.
33+
/// Build client.
2834
// RUN: %target-swift-frontend -emit-module %t/ClientLib.swift -I %t \
2935
// RUN: -swift-version 5 -enable-library-evolution \
3036
// RUN: -o %t/ClientLib.swiftmodule \
3137
// RUN: -emit-module-interface-path %t/ClientLib.swiftinterface \
3238
// RUN: -emit-private-module-interface-path %t/ClientLib.private.swiftinterface
3339
// 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
40+
// RUN: %target-swift-typecheck-module-from-interface(%t/ClientLib.private.swiftinterface) -I %t -module-name ClientLib
3541
// RUN: cat %t/ClientLib.swiftinterface | %FileCheck --check-prefixes=CLIENT-PUBLIC %s
36-
// RUN: cat %t/ClientLib.private.swiftinterface | %FileCheck --check-prefixes=CLIENT-PUBLIC %s
42+
// RUN: cat %t/ClientLib.private.swiftinterface | %FileCheck --check-prefixes=CLIENT-PRIVATE %s
3743

38-
/// New logic applying export-as only in the public swiftinterface with
39-
/// `-enable-experimental-feature ModuleInterfaceExportAs`.
44+
/// Build client against private swiftinterfaces.
45+
// RUN: rm -f %t/PrivateLib.swiftmodule %t/PublicLib.swiftmodule
4046
// RUN: %target-swift-frontend -emit-module %t/ClientLib.swift -I %t \
4147
// RUN: -swift-version 5 -enable-library-evolution \
4248
// RUN: -o %t/ClientLib.swiftmodule \
4349
// 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
50+
// RUN: -emit-private-module-interface-path %t/ClientLib.private.swiftinterface
4651
// 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
52+
// RUN: %target-swift-typecheck-module-from-interface(%t/ClientLib.private.swiftinterface) -I %t -module-name ClientLib
4853
// RUN: cat %t/ClientLib.swiftinterface | %FileCheck --check-prefixes=CLIENT-PUBLIC %s
4954
// RUN: cat %t/ClientLib.private.swiftinterface | %FileCheck --check-prefixes=CLIENT-PRIVATE %s
5055

51-
/// Check that we get the same behavior using swiftinterfaces only.
52-
// RUN: rm -f %t/PrivateLib.swiftmodule %t/PublicLib.swiftmodule
56+
/// Build client against public swiftinterfaces, for the same result.
57+
// RUN: rm -f %t/PrivateLib.private.swiftinterface %t/PublicLib.private.swiftinterface
5358
// RUN: %target-swift-frontend -emit-module %t/ClientLib.swift -I %t \
5459
// RUN: -swift-version 5 -enable-library-evolution \
5560
// RUN: -o %t/ClientLib.swiftmodule \
5661
// 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
62+
// RUN: -emit-private-module-interface-path %t/ClientLib.private.swiftinterface
5963
// 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
64+
// RUN: %target-swift-typecheck-module-from-interface(%t/ClientLib.private.swiftinterface) -I %t -module-name ClientLib
6165
// RUN: cat %t/ClientLib.swiftinterface | %FileCheck --check-prefixes=CLIENT-PUBLIC %s
6266
// RUN: cat %t/ClientLib.private.swiftinterface | %FileCheck --check-prefixes=CLIENT-PRIVATE %s
6367

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

7781
public func publicLibUser(_ arg: PrivateNameStruct) {}
7882
// PUBLICLIB-PUBLIC: arg: PublicLib.PrivateNameStruct
83+
// PUBLICLIB-PRIVATE: arg: PrivateLib.PrivateNameStruct
7984

8085
//--- ClientLib.swift
8186

0 commit comments

Comments
 (0)