Skip to content

Commit 6aac2e3

Browse files
committed
[Type checker] Don't check near-miss candidates of the wrong kind.
Fixes rdar://problem/35832679. (cherry picked from commit 6eec137)
1 parent fc37967 commit 6aac2e3

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6479,6 +6479,11 @@ static bool shouldWarnAboutPotentialWitness(
64796479
if (groupChecker.isCoveredMember(witness))
64806480
return false;
64816481

6482+
// If the kinds of the requirement and witness are different, there's
6483+
// nothing to warn about.
6484+
if (req->getKind() != witness->getKind())
6485+
return false;
6486+
64826487
// If the warning couldn't be suppressed, don't warn.
64836488
if (!canSuppressPotentialWitnessWarningWithMovement(req, witness) &&
64846489
!canSuppressPotentialWitnessWarningWithNonObjC(req, witness))
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: %target-swift-frontend %s -emit-ir -o -
2+
3+
func f() {
4+
enum NotAnError: Swift.Error {
5+
case nope(length: Int)
6+
}
7+
}
8+

0 commit comments

Comments
 (0)