mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user