We had some unbalanced calls of `walkTo*Pre` and `walkTo*Post` in `SemaAnnotator`.
The main fix was to set `Cancelled` to `true` if traversal is being stopped in `walkToExprPre`.
While I was at it, I also
- Added some more checks, ensuring that no more `walkTo*` calls are issued after `Cancelled` has been set to `true`.
- Added some comments, describing the intended traversal behaviour.
- Inverted the return value of the `ReportParamList` lambda to be in line with the return value of the enclosing `walkToDeclPre`
- Moved `walkToExprPost` to be place right after `walkToExprPre`
Resolves rdar://64139829 [SR-12957]
Escapingness is a property of the type of a value, not a property of a function
parameter. Having it as a separate parameter flag just meant one more piece of
state that could get out of sync and cause weird problems.
Instead, always look at the noescape bit in a function type as the canonical
source of truth.
This does mean that '@escaping' is now printed in a few diagnostics where it was
not printed before; we can investigate these as separate issues, but it is
correct to print it there because the function types in question are, in fact,
escaping.
Fixes <https://bugs.swift.org/browse/SR-10256>, <rdar://problem/49522774>.
As for `OpenExistentialExpr`, normal ASTWalker walks into the existential
expression first, then walks into sub expression. However,
`SourceEntitiyWalker` must walk AST tree by source order. Handle
`OpenExistentialExpr` and its `OpaqueValueExpr` so that
`SourceEntityWalker` walks to them in "outer to inner" manner.
rdar://problem/41147733