Skip to content

Commit

Permalink
Merge pull request #1821 from gregomni/typealias
Browse files Browse the repository at this point in the history
[SR-995] Handle name changes to ArrayLiteralConvertible associated type
  • Loading branch information
gregomni committed Mar 24, 2016
2 parents e57b9a5 + 2c51abf commit 7182c58
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 7182c58

Please sign in to comment.