Open
Description
Currently, SyntaxProtocol
has an as
method that allows casting to any other syntax node type. Because of this, it’s possible to e.g. cast a FunctionDeclSyntax
to an IdentifierExprSyntax
without any compiler errors or warnings, even though we know that the cast will always fail.
What we should do instead, is to only have a as(_: ExprSyntaxProtocol.Type)
function on ExprSyntax
(analogous for StmtSyntax
and the other base nodes).
The as
function on SyntaxProtocol
can then be marked as deprecated and produce a warning that the cast will always fail.
is
and cast
will need to be updated accordingly.