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(
8251
8251
if (instanceTy->isAny () || instanceTy->isAnyObject ())
8252
8252
impact += 5 ;
8253
8253
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
+
8254
8261
if (recordFix (fix, impact))
8255
8262
return SolutionKind::Error;
8256
8263
@@ -8301,7 +8308,7 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyMemberConstraint(
8301
8308
functionRefKind, locator,
8302
8309
/* includeInaccessibleMembers*/ true );
8303
8310
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,
8305
8312
// let's fallback to a "not such member" fix.
8306
8313
if (result.ViableCandidates .empty () && result.UnviableCandidates .empty ())
8307
8314
return fixMissingMember (origBaseTy, memberTy, locator);
Original file line number Diff line number Diff line change @@ -4934,6 +4934,15 @@ ConstraintSystem::isArgumentExpr(Expr *expr) {
4934
4934
return None;
4935
4935
}
4936
4936
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
+
4937
4946
if (isa<ParenExpr>(argList)) {
4938
4947
for (;;) {
4939
4948
auto *parent = getParentExpr (argList);
Original file line number Diff line number Diff line change @@ -171,3 +171,28 @@ struct EnumElementPatternFromContextualType<T> {
171
171
}
172
172
}
173
173
}
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