[Serialization] Fix deserializing opaque types for computed properties and subscripts

A client shouldn't know about the underlying type of an opaque type
unless it can see the body of the naming decl. Attempting to read it can
lead to accessing a hidden dependency and a compiler crash.

This was protected by a check specific to function decls but var decls
and subscripts were not handled. To support them we have to move this
logic to the writer side where we have access to the full
AbstractStorageDecl and write in the swifmodule whether the underlying
type should be visible outside of the module.

rdar://117607906
This commit is contained in:
Alexis Laferrière
2023-10-30 14:44:20 -07:00
parent d976ea676c
commit f2d1627656
7 changed files with 237 additions and 8 deletions

View File

@@ -4490,11 +4490,14 @@ public:
}
uint8_t rawAccessLevel =
getRawStableAccessLevel(opaqueDecl->getFormalAccess());
bool exportDetails = opaqueDecl->exportUnderlyingType();
unsigned abbrCode = S.DeclTypeAbbrCodes[OpaqueTypeLayout::Code];
OpaqueTypeLayout::emitRecord(S.Out, S.ScratchRecord, abbrCode,
contextID.getOpaqueValue(), namingDeclID,
interfaceSigID, interfaceTypeID, genericSigID,
underlyingSubsID, rawAccessLevel);
underlyingSubsID, rawAccessLevel,
exportDetails);
writeGenericParams(opaqueDecl->getGenericParams());
// Serialize all of the conditionally available substitutions expect the