Skip to content

Commit 5c1b079

Browse files
committed
---
yaml --- r: 335615 b: refs/heads/rxwei-patch-1 c: 0366343 h: refs/heads/master i: 335613: cd4c801 335611: d99e273 335607: 0786837 335599: e4d6a59 335583: 14b6bf4 335551: da831c1 335487: 3be7452 335359: 64e8926
1 parent caeca36 commit 5c1b079

File tree

10 files changed

+58
-3
lines changed

10 files changed

+58
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-08-18-a: b10b1fce14385faa6d44f6b933e95
10151015
refs/heads/rdar-43033749-fix-batch-mode-no-diags-swift-5.0-branch: a14e64eaad30de89f0f5f0b2a782eed7ecdcb255
10161016
refs/heads/revert-19006-error-bridging-integer-type: 8a9065a3696535305ea53fe9b71f91cbe6702019
10171017
refs/heads/revert-19050-revert-19006-error-bridging-integer-type: ecf752d54b05dd0a20f510f0bfa54a3fec3bcaca
1018-
refs/heads/rxwei-patch-1: 93616cd49ee86d42b343617cefc9eb61ff108627
1018+
refs/heads/rxwei-patch-1: 0366343681e8c93c009350e484c2e5d6b0169051
10191019
refs/heads/shahmishal-patch-1: e58ec0f7488258d42bef51bc3e6d7b3dc74d7b2a
10201020
refs/heads/typelist-existential: 4046359efd541fb5c72d69a92eefc0a784df8f5e
10211021
refs/tags/swift-4.2-DEVELOPMENT-SNAPSHOT-2018-08-20-a: 4319ba09e4fb8650ee86061075c74a016b6baab9

branches/rxwei-patch-1/include/swift/AST/PrintOptions.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,12 @@ struct PrintOptions {
185185
/// type might be ambiguous.
186186
bool FullyQualifiedTypesIfAmbiguous = false;
187187

188+
/// If true, printed module names will use the "exported" name, which may be
189+
/// different from the regular name.
190+
///
191+
/// \see FileUnit::getExportedModuleName
192+
bool UseExportedModuleNames = false;
193+
188194
/// Print Swift.Array and Swift.Optional with sugared syntax
189195
/// ([] and ?), even if there are no sugar type nodes.
190196
bool SynthesizeSugarOnTypes = false;

branches/rxwei-patch-1/lib/AST/ASTPrinter.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ PrintOptions PrintOptions::printParseableInterfaceFile() {
9999
result.TypeDefinitions = true;
100100
result.PrintIfConfig = false;
101101
result.FullyQualifiedTypes = true;
102+
result.UseExportedModuleNames = true;
102103
result.AllowNullTypes = false;
103104
result.SkipImports = true;
104105
result.OmitNameOfInaccessibleProperties = true;
@@ -3342,8 +3343,14 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
33423343

33433344
template <typename T>
33443345
void printModuleContext(T *Ty) {
3345-
ModuleDecl *Mod = Ty->getDecl()->getModuleContext();
3346-
Printer.printModuleRef(Mod, Mod->getName());
3346+
FileUnit *File = cast<FileUnit>(Ty->getDecl()->getModuleScopeContext());
3347+
ModuleDecl *Mod = File->getParentModule();
3348+
3349+
Identifier Name = Mod->getName();
3350+
if (Options.UseExportedModuleNames)
3351+
Name = Mod->getASTContext().getIdentifier(File->getExportedModuleName());
3352+
3353+
Printer.printModuleRef(Mod, Name);
33473354
Printer << ".";
33483355
}
33493356

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#import <ExportAsCoreKit.h>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
struct CKThing {
2+
long value;
3+
};
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module CoreKit {
2+
header "CoreKit.h"
3+
header "ExportAsCoreKit.h"
4+
export *
5+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#import <ExportAsCoreKit.h>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
struct CKThing {
2+
long value;
3+
};
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module CoreKit {
2+
header "CoreKit.h"
3+
export *
4+
}
5+
6+
module ExportAsCoreKit_BAD {
7+
header "ExportAsCoreKit.h"
8+
export_as CoreKit
9+
export *
10+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend -typecheck -emit-parseable-module-interface-path %t/CoreKitClient.swiftinterface -module-name CoreKitClient -I %S/Inputs/exported-module-name-before %s
3+
// RUN: %FileCheck -implicit-check-not BAD %s < %t/CoreKitClient.swiftinterface
4+
5+
// Test that we can rebuild it even when the "export as" module goes away.
6+
// RUN: %target-swift-frontend -build-module-from-parseable-interface -o %t/CoreKitClient.swiftmodule -I %S/Inputs/exported-module-name-after %t/CoreKitClient.swiftinterface
7+
8+
// CHECK: import CoreKit
9+
import CoreKit
10+
11+
// CHECK-LABEL: public struct CKThingWrapper : RawRepresentable {
12+
public struct CKThingWrapper: RawRepresentable {
13+
public var rawValue: CKThing
14+
public init(rawValue: CKThing) {
15+
self.rawValue = rawValue
16+
}
17+
// Note that this is CoreKit.CKThing, not ExportAsCoreKit.CKThing
18+
// CHECK: public typealias RawValue = CoreKit.CKThing
19+
} // CHECK: {{^}$}}

0 commit comments

Comments
 (0)