Skip to content

Commit ac6e970

Browse files
committed
AST: Add a new verifier check for methods
1 parent 1cd22b6 commit ac6e970

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lib/AST/ASTVerifier.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2828,6 +2828,17 @@ class Verifier : public ASTWalker {
28282828
abort();
28292829
}
28302830

2831+
// Check that type members have an interface type of the form
2832+
// (Self) -> (Args...) -> Result.
2833+
if (AFD->getImplicitSelfDecl()) {
2834+
if (!interfaceTy->castTo<AnyFunctionType>()
2835+
->getResult()->is<FunctionType>()) {
2836+
Out << "Interface type of method must return a function";
2837+
interfaceTy->dump(Out);
2838+
abort();
2839+
}
2840+
}
2841+
28312842
// Throwing @objc methods must have a foreign error convention.
28322843
if (AFD->isObjC() &&
28332844
static_cast<bool>(AFD->getForeignErrorConvention())

0 commit comments

Comments
 (0)