Skip to content

Commit 2182f53

Browse files
committed
swift-module-digester: fix a false positive when diagnosing super class changes.
1 parent 0d9f92b commit 2182f53

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

test/api-digester/Inputs/cake1.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,5 @@ public class SuperClassRemoval: C3 {}
9494

9595
public class ClassToStruct {}
9696
public protocol ProtocolToEnum {}
97+
98+
public class SuperClassChange: C7 {}

test/api-digester/Inputs/cake2.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ public class C7: P1 {
7171
public func foo(_ a: Int, _ b: Int) {}
7272
}
7373

74+
public class C8: C7 {}
75+
7476
public protocol P3: P1, P4 {}
7577

7678
public protocol P4 {}
@@ -101,3 +103,5 @@ public class SuperClassRemoval {}
101103

102104
public struct ClassToStruct {}
103105
public enum ProtocolToEnum {}
106+
107+
public class SuperClassChange: C8 {}

tools/swift-api-digester/swift-api-digester.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -710,9 +710,7 @@ static void diagnoseNominalTypeDeclChange(SDKNodeDeclType *L, SDKNodeDeclType *R
710710
if (RSuperClass.empty()) {
711711
Diags.diagnose(SourceLoc(), diag::super_class_removed, L->getScreenInfo(),
712712
LSuperClass);
713-
} else {
714-
// FIXME: This will be a false positive if the new subclass is a subclass
715-
// of the old type.
713+
} else if (!contains(R->getClassInheritanceChain(), LSuperClass)) {
716714
Diags.diagnose(SourceLoc(), diag::super_class_changed, L->getScreenInfo(),
717715
LSuperClass, RSuperClass);
718716
}

0 commit comments

Comments
 (0)