Tighter type-checking of enums with synthesized RawRepresentable

conformance
Fixes SR-2134
This commit is contained in:
SpringsUp
2016-08-22 21:34:54 +02:00
parent 82a7a5570a
commit f9af1257ef
17 changed files with 160 additions and 86 deletions

View File

@@ -606,10 +606,14 @@ void NominalTypeDecl::prepareConformanceTable() const {
if (resolver)
resolver->resolveRawType(theEnum);
if (theEnum->hasRawType()) {
if (auto rawRepresentable = getASTContext().getProtocol(
KnownProtocolKind::RawRepresentable)) {
ConformanceTable->addSynthesizedConformance(mutableThis,
rawRepresentable);
if (auto rawRepresentable = ctx.getProtocol(KnownProtocolKind::RawRepresentable)) {
// The presence of a raw type is an explicit declaration that
// the compiler should derive a RawRepresentable conformance.
auto conformance = ctx.getConformance(mutableThis->getDeclaredTypeInContext(), rawRepresentable,
mutableThis->getNameLoc(), mutableThis->getInnermostDeclContext(),
ProtocolConformanceState::Incomplete);
ConformanceTable->registerProtocolConformance(conformance);
}
}
}