[Typed throws] Parsing and AST representation for typed errors

Parse typed throw specifiers as `throws(X)` in every place where there
are effects specified, and record the resulting thrown error type in
the AST except the type system. This includes:
* `FunctionTypeRepr`, for the parsed representation of types
* `AbstractFunctionDecl`, for various function-like declarations
* `ClosureExpr`, for closures
* `ArrowExpr`, for parsing of types within expression context

This also introduces some serialization logic for the thrown error
type of function-like declarations, along with an API to extract the
thrown interface type from one of those declarations, although right
now it will either be `Error` or empty.
This commit is contained in:
Doug Gregor
2023-09-18 14:11:46 -07:00
parent 204d496c36
commit ef642098f2
47 changed files with 473 additions and 145 deletions

View File

@@ -108,6 +108,7 @@ static FuncDecl *deriveDistributedActor_resolve(DerivedConformance &derived) {
name, SourceLoc(),
/*async=*/false,
/*throws=*/true,
/*ThrownType=*/Type(),
/*genericParams=*/nullptr,
params,
/*returnType*/decl->getDeclaredInterfaceType(),
@@ -257,7 +258,9 @@ static FuncDecl* createLocalFunc_doInvokeOnReturn(
DeclName(C, doInvokeLocalFuncIdent, doInvokeParamsList),
sloc,
/*async=*/true,
/*throws=*/true, doInvokeGenericParamList, doInvokeParamsList,
/*throws=*/true,
/*ThrownType=*/Type(),
doInvokeGenericParamList, doInvokeParamsList,
/*returnType=*/C.TheEmptyTupleType, parentFunc);
doInvokeOnReturnFunc->setImplicit();
doInvokeOnReturnFunc->setSynthesized();
@@ -419,6 +422,7 @@ static FuncDecl *deriveDistributedActorSystem_invokeHandlerOnReturn(
FuncDecl::createImplicit(C, StaticSpellingKind::None, name, SourceLoc(),
/*async=*/true,
/*throws=*/true,
/*ThrownType=*/Type(),
/*genericParams=*/nullptr, params,
/*returnType*/ TupleType::getEmpty(C), system);
funcDecl->setSynthesized(true);