Skip to content

Commit 0bd6ca9

Browse files
Suyash SrijanSuyash Srijan
authored andcommitted
[typechecker] use getOptionalObjectType to peel off one level of optionality and use lookThroughAllOptionalTypes on it to peel off all levels of optionality if the type is a nested optional
1 parent 9502391 commit 0bd6ca9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/Sema/TypeCheckPattern.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,9 +1393,9 @@ bool TypeChecker::coercePatternToType(Pattern *&P, TypeResolution resolution,
13931393
// OptionalSomePattern that wraps the case. This uses recursion
13941394
// to add multiple levels of OptionalSomePattern if the optional
13951395
// is nested.
1396-
if (type->getOptionalObjectType()) {
1396+
if (auto baseType = type->getOptionalObjectType()) {
13971397
if (lookupEnumMemberElement(*this, dc,
1398-
type->lookThroughAllOptionalTypes(),
1398+
baseType->lookThroughAllOptionalTypes(),
13991399
EEP->getName(), EEP->getLoc())) {
14001400
P = new (Context)
14011401
OptionalSomePattern(EEP, EEP->getEndLoc(), /*implicit*/true);

0 commit comments

Comments
 (0)