[NCGenerics] trigger module mismatch

A swiftmodule can only be correctly ingested by a compiler
that has a matching state of using or not-using
NoncopyableGenerics.

The reason for this is fundamental: the absence of a Copyable
conformance in the swiftmodule indicates that a type is
noncopyable. Thus, if a compiler with NoncopyableGenerics
reads a swiftmodule that was not compiled with that feature,
it will think every type in that module is noncopyable.

Similarly, if a compiler with NoncopyableGenerics produces a
swiftmodule, there will be Copyable requirements on each
generic parameter that the compiler without the feature will
become confused about.

The solution here is to trigger a module mismatch, so that
the compiler re-generates the swiftmodule file using the
swiftinterface, which has been kept compatible with the compiler
regardless of whether the feature is enabled.
This commit is contained in:
Kavon Farvardin
2023-12-15 00:49:32 -08:00
parent 54dff6fb17
commit 483b569bc8
21 changed files with 323 additions and 67 deletions

View File

@@ -3247,8 +3247,13 @@ bool CompilerInvocation::parseArgs(
serialization::Status
CompilerInvocation::loadFromSerializedAST(StringRef data) {
serialization::ExtendedValidationInfo extendedInfo;
serialization::ValidationInfo info = serialization::validateSerializedAST(
data, getSILOptions().EnableOSSAModules, LangOpts.SDKName, &extendedInfo);
serialization::ValidationInfo info =
serialization::validateSerializedAST(
data,
getSILOptions().EnableOSSAModules,
LangOpts.hasFeature(Feature::NoncopyableGenerics),
LangOpts.SDKName,
&extendedInfo);
if (info.status != serialization::Status::Valid)
return info.status;
@@ -3283,8 +3288,11 @@ CompilerInvocation::setUpInputForSILTool(
InputFile(inputFilename, bePrimary, fileBufOrErr.get().get(), file_types::TY_SIL));
auto result = serialization::validateSerializedAST(
fileBufOrErr.get()->getBuffer(), getSILOptions().EnableOSSAModules,
LangOpts.SDKName, &extendedInfo);
fileBufOrErr.get()->getBuffer(),
getSILOptions().EnableOSSAModules,
LangOpts.hasFeature(Feature::NoncopyableGenerics),
LangOpts.SDKName,
&extendedInfo);
bool hasSerializedAST = result.status == serialization::Status::Valid;
if (hasSerializedAST) {