Skip to content

Propagate ErrorType when checking subscript decls #619

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 18, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/AST/Decl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3371,7 +3371,10 @@ void SubscriptDecl::setIndices(Pattern *p) {
}

Type SubscriptDecl::getIndicesType() const {
return getType()->castTo<AnyFunctionType>()->getInput();
const auto type = getType();
if (type->is<ErrorType>())
return type;
return type->castTo<AnyFunctionType>()->getInput();
}

Type SubscriptDecl::getIndicesInterfaceType() const {
Expand Down
3 changes: 3 additions & 0 deletions lib/Sema/TypeCheckType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2987,6 +2987,9 @@ bool TypeChecker::isRepresentableInObjC(const SubscriptDecl *SD,
if (TupleTy->getNumElements() == 1 && !TupleTy->getElement(0).isVararg())
IndicesType = TupleTy->getElementType(0);
}

if (IndicesType->is<ErrorType>())
return false;

bool IndicesResult = isRepresentableInObjC(SD->getDeclContext(), IndicesType);
bool ElementResult = isRepresentableInObjC(SD->getDeclContext(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: not --crash %target-swift-frontend %s -parse
// RUN: not %target-swift-frontend %s -parse

// Distributed under the terms of the MIT license
// Test case submitted to project by https://github.com/practicalswift (practicalswift)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: not --crash %target-swift-frontend %s -parse
// RUN: not %target-swift-frontend %s -parse

// Distributed under the terms of the MIT license
// Test case submitted to project by https://github.com/practicalswift (practicalswift)
Expand Down