Skip to content

Commit 4e56b54

Browse files
Suyash SrijanSuyash Srijan
authored andcommitted
[typechecker] [test] cleanup
1 parent 6a7655e commit 4e56b54

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

lib/Sema/TypeCheckPattern.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,15 +1395,14 @@ bool TypeChecker::coercePatternToType(Pattern *&P, TypeResolution resolution,
13951395
goto recur;
13961396
}
13971397

1398-
// If we have an optional type let's try to see if the case
1399-
// exists in its base type and create a new pattern which contains
1400-
// the enum case.
1398+
// If we have an optional type, let's try to see if the case
1399+
// exists in its base type and if it does then synthesize an
1400+
// OptionalSomePattern that wraps the case.
14011401
if (auto baseType = type->getOptionalObjectType()) {
14021402
if (lookupEnumMemberElement(*this, dc, baseType, EEP->getName(),
14031403
EEP->getLoc())) {
14041404
P = new (Context)
1405-
OptionalSomePattern(EEP, EEP->getEndLoc(), true);
1406-
P->setImplicit();
1405+
OptionalSomePattern(EEP, EEP->getEndLoc(), /*implicit*/true);
14071406
return coercePatternToType(P, resolution, type, options);
14081407
} else {
14091408
diagnose(EEP->getLoc(),

test/Constraints/patterns.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,4 +420,4 @@ switch sr7799 {
420420
case .bar?: break // Ok
421421
case .baz: break // Ok
422422
default: break
423-
}
423+
}

test/SILGen/enum.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,4 +252,4 @@ func sr7799(bar: SR7799?) {
252252
case .two?: print("two")
253253
default: print("default")
254254
}
255-
}
255+
}

0 commit comments

Comments
 (0)