@@ -79,7 +79,7 @@ filterForEnumElement(DeclContext *DC, SourceLoc UseLoc,
79
79
EnumElementDecl *foundElement = nullptr ;
80
80
VarDecl *foundConstant = nullptr ;
81
81
82
- for (LookupResultEntry result : foundElements) {
82
+ for (const LookupResultEntry & result : foundElements) {
83
83
ValueDecl *e = result.getValueDecl ();
84
84
assert (e);
85
85
if (e->isInvalid ()) {
@@ -1315,39 +1315,6 @@ Pattern *TypeChecker::coercePatternToType(ContextualPattern pattern,
1315
1315
EEP->getLoc ());
1316
1316
if (!elt) {
1317
1317
if (!type->hasError ()) {
1318
- // Lowercasing of Swift.Optional's cases is handled in the
1319
- // standard library itself, not through the clang importer,
1320
- // so we have to do this check here. Additionally, .Some
1321
- // isn't a static VarDecl, so the existing mechanics in
1322
- // extractEnumElement won't work.
1323
- if (type->getAnyNominal () == Context.getOptionalDecl ()) {
1324
- if (EEP->getName ().isSimpleName (" None" ) ||
1325
- EEP->getName ().isSimpleName (" Some" )) {
1326
- SmallString<4 > Rename;
1327
- camel_case::toLowercaseWord (EEP->getName ()
1328
- .getBaseIdentifier ().str (),
1329
- Rename);
1330
- diags.diagnose (
1331
- EEP->getLoc (), diag::availability_decl_unavailable_rename,
1332
- /* "getter" prefix*/ 2 , EEP->getName ().getBaseName (),
1333
- /* replaced*/ false , /* special kind*/ 0 , Rename.str (),
1334
- /* message*/ StringRef ())
1335
- .fixItReplace (EEP->getLoc (), Rename.str ());
1336
-
1337
- return nullptr ;
1338
- }
1339
-
1340
- // If we have the original expression parse tree, try reinterpreting
1341
- // it as an expr-pattern if enum element lookup failed, since `.foo`
1342
- // could also refer to a static member of the context type.
1343
- } else if (EEP->hasUnresolvedOriginalExpr ()) {
1344
- P = new (Context) ExprPattern (EEP->getUnresolvedOriginalExpr (),
1345
- nullptr , nullptr );
1346
- return coercePatternToType (
1347
- pattern.forSubPattern (P, /* retainTopLevel=*/ true ), type,
1348
- options);
1349
- }
1350
-
1351
1318
// If we have an optional type, let's try to see if the case
1352
1319
// exists in its base type and if it does then synthesize an
1353
1320
// OptionalSomePattern that wraps the case. This uses recursion
@@ -1369,6 +1336,15 @@ Pattern *TypeChecker::coercePatternToType(ContextualPattern pattern,
1369
1336
EEP->getName (), type);
1370
1337
return nullptr ;
1371
1338
}
1339
+ } else if (EEP->hasUnresolvedOriginalExpr ()) {
1340
+ // If we have the original expression parse tree, try reinterpreting
1341
+ // it as an expr-pattern if enum element lookup failed, since `.foo`
1342
+ // could also refer to a static member of the context type.
1343
+ P = new (Context) ExprPattern (EEP->getUnresolvedOriginalExpr (),
1344
+ nullptr , nullptr );
1345
+ return coercePatternToType (
1346
+ pattern.forSubPattern (P, /* retainTopLevel=*/ true ), type,
1347
+ options);
1372
1348
}
1373
1349
}
1374
1350
}
0 commit comments