Skip to content

Commit 92d2309

Browse files
committed
Merge pull request #619 from jtbandes/subscript-fix
Propagate ErrorType when checking subscript decls
2 parents b235064 + 3720716 commit 92d2309

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

lib/AST/Decl.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -3371,7 +3371,10 @@ void SubscriptDecl::setIndices(Pattern *p) {
33713371
}
33723372

33733373
Type SubscriptDecl::getIndicesType() const {
3374-
return getType()->castTo<AnyFunctionType>()->getInput();
3374+
const auto type = getType();
3375+
if (type->is<ErrorType>())
3376+
return type;
3377+
return type->castTo<AnyFunctionType>()->getInput();
33753378
}
33763379

33773380
Type SubscriptDecl::getIndicesInterfaceType() const {

lib/Sema/TypeCheckType.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -2987,6 +2987,9 @@ bool TypeChecker::isRepresentableInObjC(const SubscriptDecl *SD,
29872987
if (TupleTy->getNumElements() == 1 && !TupleTy->getElement(0).isVararg())
29882988
IndicesType = TupleTy->getElementType(0);
29892989
}
2990+
2991+
if (IndicesType->is<ErrorType>())
2992+
return false;
29902993

29912994
bool IndicesResult = isRepresentableInObjC(SD->getDeclContext(), IndicesType);
29922995
bool ElementResult = isRepresentableInObjC(SD->getDeclContext(),

validation-test/compiler_crashers/24670-isunknownobjecttype.swift renamed to validation-test/compiler_crashers_fixed/24670-isunknownobjecttype.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: not --crash %target-swift-frontend %s -parse
1+
// RUN: not %target-swift-frontend %s -parse
22

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

validation-test/compiler_crashers/27787-swift-typechecker-overapproximateosversionsatlocation.swift renamed to validation-test/compiler_crashers_fixed/27787-swift-typechecker-overapproximateosversionsatlocation.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: not --crash %target-swift-frontend %s -parse
1+
// RUN: not %target-swift-frontend %s -parse
22

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

0 commit comments

Comments
 (0)