Skip to content

Commit 528479e

Browse files
authored
Merge pull request #31710 from CodaFi/threes-company
[Gardening] Remove Dead Swift 3 Optional Migration Code
2 parents 5f06f33 + 2b3a895 commit 528479e

File tree

1 file changed

+10
-34
lines changed

1 file changed

+10
-34
lines changed

lib/Sema/TypeCheckPattern.cpp

Lines changed: 10 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ filterForEnumElement(DeclContext *DC, SourceLoc UseLoc,
7979
EnumElementDecl *foundElement = nullptr;
8080
VarDecl *foundConstant = nullptr;
8181

82-
for (LookupResultEntry result : foundElements) {
82+
for (const LookupResultEntry &result : foundElements) {
8383
ValueDecl *e = result.getValueDecl();
8484
assert(e);
8585
if (e->isInvalid()) {
@@ -1315,39 +1315,6 @@ Pattern *TypeChecker::coercePatternToType(ContextualPattern pattern,
13151315
EEP->getLoc());
13161316
if (!elt) {
13171317
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-
13511318
// If we have an optional type, let's try to see if the case
13521319
// exists in its base type and if it does then synthesize an
13531320
// OptionalSomePattern that wraps the case. This uses recursion
@@ -1369,6 +1336,15 @@ Pattern *TypeChecker::coercePatternToType(ContextualPattern pattern,
13691336
EEP->getName(), type);
13701337
return nullptr;
13711338
}
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);
13721348
}
13731349
}
13741350
}

0 commit comments

Comments
 (0)