Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2b735c4

Browse files
committedApr 23, 2020
BuilderTransform: Use optional declared type
1 parent 690b0c0 commit 2b735c4

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed
 

‎lib/Sema/BuilderTransform.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -621,18 +621,24 @@ class BuilderClosureVisitor
621621
}
622622

623623
Expr *buildSomeExpr(Expr *arg) {
624+
auto optionalDecl = ctx.getOptionalDecl();
625+
auto optionalType = optionalDecl->getDeclaredType();
626+
624627
auto loc = arg->getStartLoc();
625628
auto optionalTypeExpr =
626-
TypeExpr::createImplicitHack(loc, ctx.getOptionalType(), ctx);
629+
TypeExpr::createImplicitHack(loc, optionalType, ctx);
627630
auto someRef = new (ctx) UnresolvedDotExpr(
628631
optionalTypeExpr, loc, DeclNameRef(ctx.getIdentifier("some")),
629632
DeclNameLoc(loc), /*implicit=*/true);
630633
return CallExpr::createImplicit(ctx, someRef, arg, { });
631634
}
632635

633636
Expr *buildNoneExpr(SourceLoc endLoc) {
637+
auto optionalDecl = ctx.getOptionalDecl();
638+
auto optionalType = optionalDecl->getDeclaredType();
639+
634640
auto optionalTypeExpr =
635-
TypeExpr::createImplicitHack(endLoc, ctx.getOptionalType(), ctx);
641+
TypeExpr::createImplicitHack(endLoc, optionalType, ctx);
636642
return new (ctx) UnresolvedDotExpr(
637643
optionalTypeExpr, endLoc, DeclNameRef(ctx.getIdentifier("none")),
638644
DeclNameLoc(endLoc), /*implicit=*/true);

0 commit comments

Comments
 (0)
Please sign in to comment.