swift-module-digester: diagnose removing default associated type as API breakage.

This commit is contained in:
Xi Ge
2018-09-21 14:14:36 -07:00
parent 6500e321aa
commit e8c604ff99
7 changed files with 27 additions and 0 deletions

View File

@@ -62,6 +62,8 @@ ERROR(conformance_removed,none,"%0 has removed %select{conformance to|inherited
ERROR(conformance_added,none,"%0 has added inherited protocol %1", (StringRef, StringRef))
ERROR(default_associated_type_removed,none,"%0 has removed default type %1", (StringRef, StringRef))
#ifndef DIAG_NO_UNDEF
# if defined(DIAG)
# undef DIAG

View File

@@ -69,3 +69,8 @@ public class C7 {
public protocol P3: P2, P1 {}
extension fixedLayoutStruct: P1 {}
public protocol AssociatedTypePro {
associatedtype T1 = Int
associatedtype T2
}

View File

@@ -76,3 +76,8 @@ public protocol P3: P1, P4 {}
public protocol P4 {}
extension fixedLayoutStruct: P2 {}
public protocol AssociatedTypePro {
associatedtype T1
associatedtype T2
}

View File

@@ -47,3 +47,6 @@ cake2: Var fixedLayoutStruct.lazy_d.storage is added to a non-resilient type
cake1: Protocol P3 has added inherited protocol P4
cake1: Protocol P3 has removed inherited protocol P2
cake1: Struct fixedLayoutStruct has removed conformance to P1
/* Protocol Requirement Change */
cake1: AssociatedType AssociatedTypePro.T1 has removed default type Int

View File

@@ -33,3 +33,6 @@ cake1: Var C1.CIIns2 changes from strong to weak
cake1: Protocol P3 has added inherited protocol P4
cake1: Protocol P3 has removed inherited protocol P2
cake1: Struct fixedLayoutStruct has removed conformance to P1
/* Protocol Requirement Change */
cake1: AssociatedType AssociatedTypePro.T1 has removed default type Int

View File

@@ -54,6 +54,8 @@ static StringRef getCategoryName(uint32_t ID) {
case LocalDiagID::conformance_added:
case LocalDiagID::conformance_removed:
return "/* Protocol Conformance Change */";
case LocalDiagID::default_associated_type_removed:
return "/* Protocol Requirement Change */";
default:
return StringRef();
}

View File

@@ -817,6 +817,13 @@ public:
case NodeMatchReason::Removed:
assert(!Right);
Left->annotate(NodeAnnotation::Removed);
if (auto *LT = dyn_cast<SDKNodeType>(Left)) {
if (auto *AT = dyn_cast<SDKNodeDeclAssociatedType>(LT->getParent())) {
Ctx.getDiags().diagnose(SourceLoc(),
diag::default_associated_type_removed,
AT->getScreenInfo(), LT->getPrintedName());
}
}
return;
case NodeMatchReason::FuncToProperty:
case NodeMatchReason::ModernizeEnum: