Suggest explicit protocol conformance via Fix-Its.

When we notice that a type implicitly conforms to a protocol but is
not explicitly stated to do so, note this and provide a Fix-It
attaching the conformance to a declaration within the translation
unit, e.g.,

t.swift:28:16: error: type 'S1' does not explicitly conform to protocol 'P'
var p1 : P = S1()
               ^
t.swift:8:8: note: introduce explicit conformance to protocol 'P'
struct S1 : Q {
       ^
             , P



Swift SVN r6760
This commit is contained in:
Doug Gregor
2013-07-30 22:45:10 +00:00
parent 8aa302cd6d
commit ceaa5e00bf
8 changed files with 256 additions and 21 deletions

View File

@@ -338,11 +338,16 @@ ProtocolConformance *processConformance(ASTContext &ctx, T decl, CanType canTy,
auto &conformanceRecord = ctx.ConformsTo[{canTy, proto}];
if (conformanceRecord && conformanceRecord != conformance) {
if (conformanceRecord.getPointer() &&
conformanceRecord.getPointer() != conformance) {
delete conformance;
conformance = conformanceRecord;
conformance = conformanceRecord.getPointer();
// Only explicit conformances ever get serialized.
conformanceRecord.setInt(true);
} else {
conformanceRecord = conformance;
// Only explicit conformances ever get serialized.
conformanceRecord.setPointer(conformance);
conformanceRecord.setInt(true);
}
if (decl)