Skip to content

Commit

Permalink
[SR-995] Handle name changes to ArrayLiteralConvertible associated type
Browse files Browse the repository at this point in the history
This is just being more general and defensive to handle name changes in
the stdlib.
  • Loading branch information
gregomni committed Mar 24, 2016
1 parent cce9507 commit 2c51abf
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/Sema/CSGen.cpp
Expand Up @@ -1773,8 +1773,6 @@ namespace {
}

Type visitArrayExpr(ArrayExpr *expr) {
ASTContext &C = CS.getASTContext();

// An array expression can be of a type T that conforms to the
// ArrayLiteralConvertible protocol.
auto &tc = CS.getTypeChecker();
Expand All @@ -1785,10 +1783,14 @@ namespace {
return Type();
}

// FIXME: Protect against broken standard library.
auto elementAssocTy = cast<AssociatedTypeDecl>(
arrayProto->lookupDirect(
C.getIdentifier("Element")).front());
// Assume that ArrayLiteralConvertible contains a single associated type.
AssociatedTypeDecl *elementAssocTy = nullptr;
for (auto decl : arrayProto->getMembers()) {
if ((elementAssocTy = dyn_cast<AssociatedTypeDecl>(decl)))
break;
}
if (!elementAssocTy)
return Type();

auto locator = CS.getConstraintLocator(expr);
auto contextualType = CS.getContextualType(expr);
Expand Down

0 comments on commit 2c51abf

Please sign in to comment.