Skip to content

Commit 2cfc459

Browse files
committed
Sema: Build fully type-checked AST for dynamic member lookups
1 parent 140a5b0 commit 2cfc459

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/Sema/CSApply.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,16 @@ static Expr *buildDynamicMemberLookupIndexExpr(StringRef name, SourceLoc loc,
266266
DeclContext *dc,
267267
ConstraintSystem &cs) {
268268
auto &ctx = cs.TC.Context;
269+
270+
auto *stringDecl = ctx.getStringDecl();
271+
auto stringType = stringDecl->getDeclaredType();
272+
269273
// Build and type check the string literal index value to the specific
270274
// string type expected by the subscript.
271-
Expr *nameExpr = new (ctx) StringLiteralExpr(name, loc, /*implicit*/true);
272-
(void)cs.TC.typeCheckExpression(nameExpr, dc);
275+
auto *nameExpr = new (ctx) StringLiteralExpr(name, loc, /*implicit*/true);
276+
nameExpr->setBuiltinInitializer(ctx.getStringBuiltinInitDecl(stringDecl));
277+
nameExpr->setType(stringType);
278+
273279
cs.cacheExprTypes(nameExpr);
274280
return nameExpr;
275281
}

0 commit comments

Comments
 (0)