mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user