[swift2objc] Support throws annotation
#1766
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Methods and functions in Swift that can throw an exception must be annotated with
throws. When you call one of these functions, you have to either handle the exception, or forward it by prefixing the call withtry(in which case your function must also be markedthrows).So when we're wrapping one of these methods we need to add
tryandthrowskeywords, like this:throwsshows up in thedeclarationFragmentsof the function, after the)but before the->. Getters can also throw, but supporting them is a little more complicated.Details
CanThrowinterface. Added this to all functions, methods, initializers, properties, and variables.throwsto the method signature, andtrywhen invoking the wrapped method.()is split into(and), in parse_type.dart I had to change the_emptyTupleParseletto be a_tupleParselet, though we haven't added support for tuples yet.parseFunctionParamstoparseFunctionInfo, which now also checks for annotations. Essentially it just reads all the keywords after the). Had to refactor a bit to handle all the new token splitting.matchFragment.