From dd4db41048773d475b346c014331fa9c592bfdff Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 12 Feb 2014 21:10:54 +0000 Subject: [PATCH] Serialization: Don't throw away the conformances of ApplyInst substitutions. We kinda need those. Limit the hack to pad it out with nulls to only apply in the case when the conformance list is empty but the original archetype requires conformances, which only occurs for archetypes or existentials. At long last, we can build at -O0 again, again! Reapplying now that Jordan fixed some fallout this had on his objc printer tests. Thanks Jordan! Swift SVN r13840 --- lib/Serialization/Serialization.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/Serialization/Serialization.cpp b/lib/Serialization/Serialization.cpp index 4bea04d2616..f3800e8374c 100644 --- a/lib/Serialization/Serialization.cpp +++ b/lib/Serialization/Serialization.cpp @@ -833,13 +833,19 @@ void Serializer::writeSubstitutions(ArrayRef substitutions, addTypeRef(sub.Archetype), addTypeRef(sub.Replacement), sub.Archetype->getConformsTo().size()); + ArrayRef conformances = sub.Conformance; + // For archetypes the conformance information is context dependent, // the conformance array is either empty or full of nulls and can be // ignored. We use an array of null pointers for conformances to satisfy // the requirement in writeConformances: the first and second arguments // have the same size. - SmallVector conformances( - sub.Archetype->getConformsTo().size(), nullptr); + SmallVector conformancesBuf; + if (sub.Conformance.empty() && !sub.Archetype->getConformsTo().empty()) { + conformancesBuf.resize(sub.Archetype->getConformsTo().size(), + nullptr); + conformances = conformancesBuf; + } writeConformances(sub.Archetype->getConformsTo(), conformances, nullptr, abbrCodes); }