Skip to content

Commit d24f9d2

Browse files
authored
Merge pull request swiftlang#20490 from aschwaighofer/feedback_private_import
2 parents 7f02b26 + 3fe6d36 commit d24f9d2

File tree

5 files changed

+16
-3
lines changed

5 files changed

+16
-3
lines changed

lib/Serialization/Serialization.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2691,8 +2691,7 @@ void Serializer::writeDecl(const Decl *D) {
26912691
if (auto *SF = dyn_cast<SourceFile>(enclosingFile)) {
26922692
return llvm::sys::path::filename(SF->getFilename());
26932693
} else if (auto *LF = dyn_cast<LoadedFile>(enclosingFile)) {
2694-
return llvm::sys::path::filename(
2695-
(LF->getFilenameForPrivateDecl(decl)));
2694+
return LF->getFilenameForPrivateDecl(decl);
26962695
}
26972696
return StringRef();
26982697
};
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
private struct Base {
22
private func bar() {}
33
}
4+
5+
struct Value {
6+
}
7+
8+
extension Value {
9+
fileprivate func foo() {}
10+
}

test/Serialization/Inputs/private_import_other_2.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@ private struct Base {
55

66
private struct Other {
77
}
8+
9+
extension Value {
10+
fileprivate func foo() {}
11+
}

test/Serialization/private_import.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
Base().foo()
4545
// This should not be ambigious.
4646
Base().bar()
47-
47+
// This should not conflict with the second declaration in
48+
// private_import_other_2.swift.
49+
Value().foo()
4850
unreleated()
4951
#endif

test/attr/private_import.swift

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

55
@_private(sourceFile: "Array.swift") import Swift // expected-error {{module 'Swift' was not compiled for private import}}
66
@_private(sourceFile: "empty.swift") import empty // no-error
7+
@_private(sourceFile: "not_existing_file.swift") import empty // no-error
78

89
@_private(sourceFile: "none") func foo() {} // expected-error {{@_private may only be used on 'import' declarations}} {{1-31=}}

0 commit comments

Comments
 (0)