@@ -347,21 +347,34 @@ that is, a function that takes an `Int` and returns
347347another function that takes and returns an ` Int ` .
348348
349349Function types for functions
350- that can throw or rethrow an error must be marked with the ` throws ` keyword.
351- The ` throws ` keyword is part of a function's type,
352- and nonthrowing functions are subtypes of throwing functions.
353- A function that throws a concrete error type
354- includes the error type that it throws in its function type.
355- If that error type is a subtype,
356- then functions that throw the subtype as an error
357- are subtypes of functions that throw the supertype as an error.
358-
359- As a result, you can use a nonthrowing function
360- in the same places as a throwing function,
361- you can use a function that throws a concrete error type
362- in the same places as a throwing function,
363- and you can use a function that throws a more specific concrete error type
364- in the same places as a function that throws a more general error type.
350+ that can throw or rethrow an error must include the ` throws ` keyword.
351+ <!-- XXX TR: Confirm rethrowing functions use 'throws' -->
352+ You can include a type after ` throws ` in parentheses
353+ to specify the type of error that the function throws.
354+ Writing ` throws ` without specifying an type
355+ is the same as writing ` throws(any Error) ` .
356+ Omitting ` throws ` is the same as writing ` throws(Never) ` .
357+
358+ The type of error that a function throws is part of that function's type,
359+ and a subtype relationship between error types
360+ means the corresponding function types are also subtypes.
361+ For example, if you declare a custom ` MyError ` type,
362+ the relationship between some function types is as follows,
363+ from supertype to subtype:
364+
365+ 1 . Functions that throw any error, marked ` throws(any Error) ` .
366+ 1 . Functions that throw a specific error, marked ` throws(MyError) ` .
367+ 1 . Functions that don't throw, marked ` throws(Never) ` .
368+
369+ As a result of these subtype relationships:
370+
371+ - You can use a nonthrowing function
372+ in the same places as a throwing function.
373+ - You can use a function that throws a concrete error type
374+ in the same places as a throwing function.
375+ - You can use a function that throws a more specific error type
376+ in the same places as a function that throws a more general error type.
377+
365378Throwing and rethrowing functions are described in
366379< doc:Declarations#Throwing-Functions-and-Methods >
367380and < doc:Declarations#Rethrowing-Functions-and-Methods > .
0 commit comments