Serialization: Recovery for protocol conformances with changed witness or requirement signatures.

Deserializing a witness record in a conformance may fail if either of the requirement or witness changed name or type, most likely due to SDK modernization changes across Swift versions. When this happens, leave an opaque placeholder in the conformance to indicate that the witness exists but we don't get to see it. For expedience, right now this just witnesses the requirement to itself, so that code in the type checker or elsewhere that tries to ad-hoc devirtualize references to the requirement just gets the requirement back. Arguably, we shouldn't include the witness at all in imported conformances, since they should be an implementation detail, but that's a bigger, riskier change. This patch as is should be enough to address rdar://problem/31185053.
This commit is contained in:
Joe Groff
2017-04-19 16:07:19 -07:00
parent b0d138eb94
commit e3e0f440a1
14 changed files with 344 additions and 16 deletions

View File

@@ -200,7 +200,9 @@ validateControlBlock(llvm::BitstreamCursor &cursor,
default:
// Add new cases here, in descending order.
case 4:
result.compatibilityVersion = blobData.substr(scratch[2]+1, scratch[3]);
result.compatibilityVersion =
version::Version(blobData.substr(scratch[2]+1, scratch[3]),
SourceLoc(), nullptr);
LLVM_FALLTHROUGH;
case 3:
result.shortVersion = blobData.slice(0, scratch[2]);