mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Serialization] Keep indirect conformances knowledge with safety
Given a scenario where a public type A, conforms to an internal protocol B, which conforms to a public protocol C. A conforms indirectly to C through a protocol that's hidden from the clients. This is handled in module interface by printing the indirect conformance of A to C explicitly at the end of the swiftinterface. We have the same problem with deserialization safety that used to hide the internal protocols from clients, thus breaking the knowledge of the indirect dependency. To keep the indirect conformances, let's consider all protocols as safe and preserve their conformance information. rdar://105241772
This commit is contained in:
committed by
Alexis Laferrière
parent
08af8a657f
commit
9602df1e83
@@ -3124,14 +3124,11 @@ class Serializer::DeclSerializer : public DeclVisitor<DeclSerializer> {
|
||||
if (hasSafeMembers)
|
||||
return true;
|
||||
|
||||
// We can mark the extension unsafe only if it has no public
|
||||
// We can mark the extension unsafe only if it has no public
|
||||
// conformances.
|
||||
auto protocols = ext->getLocalProtocols(
|
||||
ConformanceLookupKind::OnlyExplicit);
|
||||
bool hasSafeConformances = std::any_of(protocols.begin(),
|
||||
protocols.end(),
|
||||
isDeserializationSafe);
|
||||
if (hasSafeConformances)
|
||||
if (!protocols.empty())
|
||||
return true;
|
||||
|
||||
// Truly empty extensions are safe, it may happen in swiftinterfaces.
|
||||
@@ -3141,6 +3138,9 @@ class Serializer::DeclSerializer : public DeclVisitor<DeclSerializer> {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isa<ProtocolDecl>(decl))
|
||||
return true;
|
||||
|
||||
auto value = cast<ValueDecl>(decl);
|
||||
|
||||
// A decl is safe if formally accessible publicly.
|
||||
|
||||
Reference in New Issue
Block a user