Skip to content

Commit ea2084e

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 31242bc commit ea2084e

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
@@ -2613,18 +2613,10 @@ void PrintAST::visitVarDecl(VarDecl *decl) {
26132613
Printer << ": ";
26142614
TypeLoc tyLoc;
26152615
if (auto *repr = decl->getTypeReprOrParentPatternTypeRepr()) {
2616-
// Workaround for if-let statements. The parser creates a `OptionalTypeRepr`
2617-
// even though the user-written declared type for the if-let variable
2618-
// is non-optional. Get the non-optional type so we can print it correctly.
2619-
if (auto *optRepr = dyn_cast<OptionalTypeRepr>(repr)) {
2620-
if (type && !isa<OptionalType>(type.getPointer())) {
2621-
repr = optRepr->getBase();
2622-
}
2623-
}
26242616
tyLoc = TypeLoc(repr, type);
2625-
} else
2617+
} else {
26262618
tyLoc = TypeLoc::withoutLoc(type);
2627-
2619+
}
26282620
Printer.printDeclResultTypePre(decl, tyLoc);
26292621

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

0 commit comments

Comments
 (0)