Skip to content

Commit 0455913

Browse files
committed
AST: Make ConstructorDecl::getInitializerInterfaceType() more forgiving of invalid code
1 parent 77a411a commit 0455913

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/AST/Decl.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6856,7 +6856,13 @@ Type ConstructorDecl::getInitializerInterfaceType() {
68566856
return InitializerInterfaceType;
68576857

68586858
// Lazily calculate initializer type.
6859-
auto funcTy = getInterfaceType()->castTo<AnyFunctionType>()->getResult();
6859+
auto allocatorTy = getInterfaceType();
6860+
if (!allocatorTy->is<AnyFunctionType>()) {
6861+
InitializerInterfaceType = ErrorType::get(getASTContext());
6862+
return InitializerInterfaceType;
6863+
}
6864+
6865+
auto funcTy = allocatorTy->castTo<AnyFunctionType>()->getResult();
68606866
assert(funcTy->is<FunctionType>());
68616867

68626868
// Constructors have an initializer type that takes an instance

0 commit comments

Comments
 (0)