Skip to content

Commit e773dd2

Browse files
committed
Remove an Unnecessary Workaround
Now that the parser no longer constructs invalid TypeReprs for if-lets, printing the annotation here will always reflect what the user actually wrote. rdar://62894516
1 parent 46b64d4 commit e773dd2

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

lib/AST/ASTPrinter.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2642,18 +2642,10 @@ void PrintAST::visitVarDecl(VarDecl *decl) {
26422642
Printer << ": ";
26432643
TypeLoc tyLoc;
26442644
if (auto *repr = decl->getTypeReprOrParentPatternTypeRepr()) {
2645-
// Workaround for if-let statements. The parser creates a `OptionalTypeRepr`
2646-
// even though the user-written declared type for the if-let variable
2647-
// is non-optional. Get the non-optional type so we can print it correctly.
2648-
if (auto *optRepr = dyn_cast<OptionalTypeRepr>(repr)) {
2649-
if (type && !isa<OptionalType>(type.getPointer())) {
2650-
repr = optRepr->getBase();
2651-
}
2652-
}
26532645
tyLoc = TypeLoc(repr, type);
2654-
} else
2646+
} else {
26552647
tyLoc = TypeLoc::withoutLoc(type);
2656-
2648+
}
26572649
Printer.printDeclResultTypePre(decl, tyLoc);
26582650

26592651
// HACK: When printing result types for vars with opaque result types,

0 commit comments

Comments
 (0)