Skip to content

Commit 9974769

Browse files
committed
[Serialization] Disable deserialization safety when testing is enabled
Resilient modules with testing enabled expose internal non-resilient internal types. These types cannot be reliably used by testable clients if they don't have all of their members known. For this reason, this disabled deserialization safety in modules when testing is enabled. rdar://104923020
1 parent 3302b27 commit 9974769

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)