Skip to content

Commit bf6fe03

Browse files
committed
[ObjC] Only Diagnose Selector Conflicts From Classes
Clang 1200 appears to be returning us results from protocol declarations when we run lookup for an Objective-C selector. This code path can therefore see protocol requirements, and would erroneously diagnose witnesses from Swift subclasses of Objective-C classes as an attempt to conflict with the requirement in the protocol itself. This fix is super narrow to try to unblock our builds. Tests will follow once I can reduce the issue. Resolves rdar://60005962
1 parent c825ed8 commit bf6fe03

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/Sema/TypeCheckDeclObjC.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2035,6 +2035,11 @@ bool swift::diagnoseUnintendedObjCMethodOverrides(SourceFile &sf) {
20352035
continue;
20362036
}
20372037

2038+
// Require the declaration to actually come from a class. Selectors that
2039+
// come from protocol requirements are not actually overrides.
2040+
if (!overriddenMethod->getDeclContext()->getSelfClassDecl())
2041+
continue;
2042+
20382043
// Diagnose the override.
20392044
auto methodDiagInfo = getObjCMethodDiagInfo(method);
20402045
auto overriddenDiagInfo = getObjCMethodDiagInfo(overriddenMethod);

0 commit comments

Comments
 (0)