File tree Expand file tree Collapse file tree 3 files changed +42
-1
lines changed Expand file tree Collapse file tree 3 files changed +42
-1
lines changed Original file line number Diff line number Diff line change @@ -8251,6 +8251,13 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyMemberConstraint(
82518251 if (instanceTy->isAny () || instanceTy->isAnyObject ())
82528252 impact += 5 ;
82538253
8254+ // Increasing the impact for missing member in any argument position so it
8255+ // doesn't affect situations where there are another fixes involved.
8256+ auto *anchorExpr = getAsExpr (locator->getAnchor ());
8257+ if (anchorExpr && isArgumentExpr (anchorExpr)) {
8258+ impact += 5 ;
8259+ }
8260+
82548261 if (recordFix (fix, impact))
82558262 return SolutionKind::Error;
82568263
@@ -8301,7 +8308,7 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyMemberConstraint(
83018308 functionRefKind, locator,
83028309 /* includeInaccessibleMembers*/ true );
83038310
8304- // If uwrapped type still couldn't find anything for a given name,
8311+ // If unwrapped type still couldn't find anything for a given name,
83058312 // let's fallback to a "not such member" fix.
83068313 if (result.ViableCandidates .empty () && result.UnviableCandidates .empty ())
83078314 return fixMissingMember (origBaseTy, memberTy, locator);
Original file line number Diff line number Diff line change @@ -4934,6 +4934,15 @@ ConstraintSystem::isArgumentExpr(Expr *expr) {
49344934 return None;
49354935 }
49364936
4937+ // Specifically for unresolved member expr getParentExpr returns a chain
4938+ // result expr as its immediate parent, so let's look one level up on AST.
4939+ if (auto *URMCR = getAsExpr<UnresolvedMemberChainResultExpr>(argList)) {
4940+ argList = getParentExpr (URMCR);
4941+ if (!argList) {
4942+ return None;
4943+ }
4944+ }
4945+
49374946 if (isa<ParenExpr>(argList)) {
49384947 for (;;) {
49394948 auto *parent = getParentExpr (argList);
Original file line number Diff line number Diff line change @@ -171,3 +171,28 @@ struct EnumElementPatternFromContextualType<T> {
171171 }
172172 }
173173}
174+
175+ // SR-14408
176+ enum CompassPoint {
177+ case North( Int )
178+ case South
179+ case East
180+ case West
181+ }
182+
183+ func isNorth( c : CompassPoint ) -> Bool {
184+ // expected-error@+1{{member 'North' expects argument of type 'Int'}}
185+ return c == . North // expected-error {{binary operator '==' cannot be applied to two 'CompassPoint' operands}}
186+ // expected-note@-1 {{binary operator '==' cannot be synthesized for enums with associated values}}
187+ }
188+
189+ func isNorth2( c : CompassPoint ) -> Bool {
190+ // expected-error@+1{{member 'North' expects argument of type 'Int'}}
191+ return . North == c // expected-error {{binary operator '==' cannot be applied to two 'CompassPoint' operands}}
192+ // expected-note@-1 {{binary operator '==' cannot be synthesized for enums with associated values}}
193+ }
194+
195+ func isSouth( c : CompassPoint ) -> Bool {
196+ return c == . South // expected-error {{binary operator '==' cannot be applied to two 'CompassPoint' operands}}
197+ // expected-note@-1 {{binary operator '==' cannot be synthesized for enums with associated values}}
198+ }
You can’t perform that action at this time.
0 commit comments