Skip to content

Commit edafed3

Browse files
committed
Merge remote-tracking branch 'origin/main' into rebranch
2 parents 76305a9 + e7a5887 commit edafed3

File tree

4 files changed

+18
-16
lines changed

4 files changed

+18
-16
lines changed

lib/AST/Decl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4031,7 +4031,7 @@ getAccessScopeForFormalAccess(const ValueDecl *VD,
40314031
case AccessLevel::Package: {
40324032
auto pkg = resultDC->getPackageContext(/*lookupIfNotCurrent*/ true);
40334033
if (!pkg) {
4034-
auto srcFile = resultDC->getParentSourceFile();
4034+
auto srcFile = resultDC->getOutermostParentSourceFile();
40354035
// Check if the file containing package decls is an interface file; if an
40364036
// interface file contains package decls, they must be usableFromInline or
40374037
// inlinable and are accessed within the defining module, so package-name

lib/AST/DeclContext.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ DeclContext *DeclContext::getModuleScopeContext() const {
407407

408408
void DeclContext::getSeparatelyImportedOverlays(
409409
ModuleDecl *declaring, SmallVectorImpl<ModuleDecl *> &overlays) const {
410-
if (auto SF = getParentSourceFile())
410+
if (auto SF = getOutermostParentSourceFile())
411411
SF->getSeparatelyImportedOverlays(declaring, overlays);
412412
}
413413

@@ -1234,13 +1234,13 @@ getPrivateDeclContext(const DeclContext *DC, const SourceFile *useSF) {
12341234

12351235
// use the type declaration as the private scope if it is in the same
12361236
// file as useSF. This occurs for both extensions and declarations.
1237-
if (NTD->getParentSourceFile() == useSF)
1237+
if (NTD->getOutermostParentSourceFile() == useSF)
12381238
return NTD;
12391239

12401240
// Otherwise use the last extension declaration in the same file.
12411241
const DeclContext *lastExtension = nullptr;
12421242
for (ExtensionDecl *ED : NTD->getExtensions())
1243-
if (ED->getParentSourceFile() == useSF)
1243+
if (ED->getOutermostParentSourceFile() == useSF)
12441244
lastExtension = ED;
12451245

12461246
// If there's no last extension, return the supplied context.
@@ -1250,7 +1250,7 @@ getPrivateDeclContext(const DeclContext *DC, const SourceFile *useSF) {
12501250
AccessScope::AccessScope(const DeclContext *DC, bool isPrivate)
12511251
: Value(DC, isPrivate) {
12521252
if (isPrivate) {
1253-
DC = getPrivateDeclContext(DC, DC->getParentSourceFile());
1253+
DC = getPrivateDeclContext(DC, DC->getOutermostParentSourceFile());
12541254
Value.setPointer(DC);
12551255
}
12561256
if (!DC || isa<ModuleDecl>(DC) || isa<PackageUnit>(DC))
@@ -1300,8 +1300,8 @@ bool AccessScope::allowsPrivateAccess(const DeclContext *useDC, const DeclContex
13001300
}
13011301
}
13021302
// Do not allow access if the sourceDC is in a different file
1303-
auto useSF = useDC->getParentSourceFile();
1304-
if (useSF != sourceDC->getParentSourceFile())
1303+
auto useSF = useDC->getOutermostParentSourceFile();
1304+
if (useSF != sourceDC->getOutermostParentSourceFile())
13051305
return false;
13061306

13071307
// Do not allow access if the sourceDC does not represent a type.

test/Macros/macro_expand_extensions.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
// RUN: %empty-directory(%t)
44
// RUN: %host-build-swift -swift-version 5 -emit-library -o %t/%target-library-name(MacroDefinition) -module-name=MacroDefinition %S/Inputs/syntax_macro_definitions.swift -g -no-toolchain-stdlib-rpath
55

6+
// Check for errors first
7+
// RUN: %target-swift-frontend -enable-experimental-feature ExtensionMacros -swift-version 5 -typecheck -load-plugin-library %t/%target-library-name(MacroDefinition) %s -I %t -disable-availability-checking
8+
69
// RUN: %target-swift-frontend -enable-experimental-feature ExtensionMacros -swift-version 5 -typecheck -load-plugin-library %t/%target-library-name(MacroDefinition) %s -I %t -disable-availability-checking -dump-macro-expansions > %t/expansions-dump.txt 2>&1
710
// RUN: %FileCheck -check-prefix=CHECK-DUMP %s < %t/expansions-dump.txt
811
// RUN: %target-typecheck-verify-swift -enable-experimental-feature ExtensionMacros -swift-version 5 -load-plugin-library %t/%target-library-name(MacroDefinition) -module-name MacroUser -DTEST_DIAGNOSTICS -swift-version 5 -I %t
@@ -202,6 +205,12 @@ func testHasPropertyWrappers(hpw: HasPropertyWrappers) {
202205
requiresEquatable(hpw)
203206
}
204207

208+
@Equatable
209+
struct HasPrivateMembers {
210+
@NotEquatable
211+
private var value: Int = 0
212+
}
213+
205214
// Check that conformances implied by a macro-defined conformance are serialized
206215
// without issue.
207216
public protocol ImpliesHashable: Hashable { }

test/lit.cfg

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2672,13 +2672,6 @@ if hasattr(config, 'target_link_sdk_future_version'):
26722672
config.substitutions.append(('%target-link-sdk-future-version',
26732673
config.target_link_sdk_future_version))
26742674

2675-
def realpath(path):
2676-
if not kIsWindows:
2677-
return os.path.realpath(path)
2678-
else:
2679-
# For Windows, we don't expand substitute drives due to MAX_PATH limitations, matching what the llvm lit does.
2680-
return os.path.abspath(path)
2681-
26822675
run_filecheck = '%s %s --allow-unused-prefixes --sanitize BUILD_DIR=%s --sanitize SOURCE_DIR=%s --use-filecheck %s %s' % (
26832676
shell_quote(sys.executable),
26842677
shell_quote(config.PathSanitizingFileCheck),
@@ -2688,8 +2681,8 @@ run_filecheck = '%s %s --allow-unused-prefixes --sanitize BUILD_DIR=%s --sanitiz
26882681
# we provide we use realpath here. Because PathSanitizingFileCheck only
26892682
# understands sanitize patterns with forward slashes, and realpath normalizes
26902683
# the slashes, we have to replace them back to forward slashes.
2691-
shell_quote(realpath(swift_obj_root).replace("\\", "/")),
2692-
shell_quote(realpath(config.swift_src_root).replace("\\", "/")),
2684+
shell_quote(lit.util.abs_path_preserve_drive(swift_obj_root).replace("\\", "/")),
2685+
shell_quote(lit.util.abs_path_preserve_drive(config.swift_src_root).replace("\\", "/")),
26932686
shell_quote(config.filecheck),
26942687
'--enable-windows-compatibility' if kIsWindows else '')
26952688

0 commit comments

Comments
 (0)