Skip to content

Commit 57d9fb8

Browse files
authored
Merge pull request #11089 from jckarter/quoted-subscript-identifier-4.0
[4.0] Don't consider KeyPathApplication operations when looking up non-SubscriptExprs.
2 parents dee6a7d + 2ddca05 commit 57d9fb8

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

lib/Sema/CSDiag.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2845,6 +2845,11 @@ bool FailureDiagnosis::diagnoseGeneralConversionFailure(Constraint *constraint){
28452845
fromType = sub->getType();
28462846
}
28472847

2848+
// Bail on constraints that don't relate two types.
2849+
if (constraint->getKind() == ConstraintKind::Disjunction
2850+
|| constraint->getKind() == ConstraintKind::BindOverload)
2851+
return false;
2852+
28482853
fromType = fromType->getRValueType();
28492854
auto toType = CS->simplifyType(constraint->getSecondType())
28502855
->getWithoutImmediateLabel();

lib/Sema/CSSimplify.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2891,7 +2891,9 @@ performMemberLookup(ConstraintKind constraintKind, DeclName memberName,
28912891
result.OverallResult = MemberLookupResult::HasResults;
28922892

28932893
// If we're looking for a subscript, consider key path operations.
2894-
if (memberName.isSimpleName(getASTContext().Id_subscript)) {
2894+
if (memberName.isSimpleName(getASTContext().Id_subscript)
2895+
&& (isa<SubscriptExpr>(memberLocator->getAnchor())
2896+
|| isa<KeyPathExpr>(memberLocator->getAnchor()))) {
28952897
result.ViableCandidates.push_back(
28962898
OverloadChoice(baseTy, OverloadChoiceKind::KeyPathApplication));
28972899
}

lib/Sema/ConstraintGraph.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,6 @@ static bool shouldContractEdge(ConstraintKind kind) {
641641
case ConstraintKind::BindParam:
642642
case ConstraintKind::BindToPointerType:
643643
case ConstraintKind::Equal:
644-
case ConstraintKind::BindOverload:
645644

646645
// We currently only allow subtype contractions for the purpose of
647646
// parameter binding constraints.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// RUN: %target-swift-frontend -typecheck -verify %s
2+
// SR-5513
3+
4+
class OTTextView {
5+
func `subscript`(_ sender: Any?) {}
6+
}
7+
8+
class MyTextView: OTTextView {
9+
override func `subscript`(_ sender: Any?) { super.`subscript`(sender) }
10+
}

0 commit comments

Comments
 (0)