Sema: Fix synthesis of materializeForSet for subscripts in protocol extensions

Since each override of a subscript protocol requirement provides
its own materializeForSet, there is no need to do dynamic dispatch,
a peer call to the setter suffices. However, since CodeSynthesis
runs at the AST level, it would create a SubscriptExpr which
overload resolution would later bind to the protocol requirement
subscript rather than the static witness in the extension.

This triggered an assertion. Solve the problem by binding the
actual ConcreteDeclRef of the SubscriptExpr at synthesis time,
and modifying CSGen to special-case SubscriptExprs that already
have a ConcreteDeclRef set.

Fixes <rdar://problem/21370629>.

Swift SVN r29906
This commit is contained in:
Slava Pestov
2015-07-03 02:25:26 +00:00
parent 402bbd3813
commit e7d8c3c4bc
3 changed files with 48 additions and 6 deletions

View File

@@ -580,7 +580,7 @@ static Expr *buildStorageReference(
if (auto subscript = dyn_cast<SubscriptDecl>(storage)) {
Expr *indices = referenceContext.getIndexRefExpr(ctx, subscript);
return new (ctx) SubscriptExpr(selfDRE, indices, ConcreteDeclRef(),
return new (ctx) SubscriptExpr(selfDRE, indices, storage,
IsImplicit, semantics);
}