Skip to content

Commit d2f5449

Browse files
authored
Merge pull request #63365 from xymus/testable-safety
[Serialization] Disable deserialization safety when testing is enabled
2 parents fecf449 + 9974769 commit d2f5449

File tree

3 files changed

+4
-8
lines changed

3 files changed

+4
-8
lines changed

lib/Serialization/Serialization.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3136,11 +3136,6 @@ class Serializer::DeclSerializer : public DeclVisitor<DeclSerializer> {
31363136
if (accessScope.isPublic())
31373137
return true;
31383138

3139-
// Testable allows access to internal details.
3140-
if (value->getDeclContext()->getParentModule()->isTestingEnabled() &&
3141-
accessScope.isInternal())
3142-
return true;
3143-
31443139
if (auto accessor = dyn_cast<AccessorDecl>(value))
31453140
// Accessors are as safe as their storage.
31463141
if (isDeserializationSafe(accessor->getStorage()))
@@ -3189,7 +3184,8 @@ class Serializer::DeclSerializer : public DeclVisitor<DeclSerializer> {
31893184
#endif
31903185

31913186
// Private imports allow safe access to everything.
3192-
if (DC->getParentModule()->arePrivateImportsEnabled())
3187+
if (DC->getParentModule()->arePrivateImportsEnabled() ||
3188+
DC->getParentModule()->isTestingEnabled())
31933189
return;
31943190

31953191
// Ignore things with no access level.

test/Serialization/Safety/unsafe-decls.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// RUN: -enable-library-evolution -swift-version 5 \
1212
// RUN: -Xllvm -debug-only=Serialization \
1313
// RUN: -enable-testing 2>&1 \
14-
// RUN: | %FileCheck --check-prefixes=SAFETY-PRIVATE,NO-SAFETY-INTERNAL-NOT %s
14+
// RUN: | %FileCheck --check-prefixes=DISABLED %s
1515

1616
/// Don't mark decls as unsafe when private import is enabled.
1717
// RUN: %target-swift-frontend -emit-module %s \

test/Serialization/Safety/unsafe-extensions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// RUN: -enable-library-evolution -swift-version 5 \
1212
// RUN: -Xllvm -debug-only=Serialization \
1313
// RUN: -enable-testing 2>&1 \
14-
// RUN: | %FileCheck --check-prefixes=SAFETY-PRIVATE,NO-SAFETY-INTERNAL %s
14+
// RUN: | %FileCheck --check-prefixes=DISABLED %s
1515

1616
/// Don't mark decls as unsafe when private import is enabled.
1717
// RUN: %target-swift-frontend -emit-module %s \

0 commit comments

Comments
 (0)