mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[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:
@@ -109,7 +109,8 @@ protected:
|
||||
ctx->addModuleInterfaceChecker(
|
||||
std::make_unique<ModuleInterfaceCheckerImpl>(*ctx, cacheDir,
|
||||
prebuiltCacheDir, ModuleInterfaceLoaderOptions(),
|
||||
swift::RequireOSSAModules_t(silOpts)));
|
||||
swift::RequireOSSAModules_t(silOpts),
|
||||
swift::RequireNoncopyableGenerics_t(langOpts)));
|
||||
|
||||
auto loader = ModuleInterfaceLoader::create(
|
||||
*ctx, *static_cast<ModuleInterfaceCheckerImpl*>(
|
||||
@@ -149,7 +150,9 @@ protected:
|
||||
|
||||
auto bufData = (*bufOrErr)->getBuffer();
|
||||
auto validationInfo = serialization::validateSerializedAST(
|
||||
bufData, silOpts.EnableOSSAModules, /*requiredSDK*/StringRef());
|
||||
bufData, silOpts.EnableOSSAModules,
|
||||
langOpts.hasFeature(Feature::NoncopyableGenerics),
|
||||
/*requiredSDK*/StringRef());
|
||||
ASSERT_EQ(serialization::Status::Valid, validationInfo.status);
|
||||
ASSERT_EQ(bufData, moduleBuffer->getBuffer());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user