Closed AppAppWorks closed 2 months ago
Could you change those to the actual type names or stick with the enum case name if we don’t actually need to go through the initializer?
I've reverted most changes back to their original states, however for the convenience initializers I've implemented another idea, e.g.
/// convenience init for `decl`
public init(decl: some RawDeclSyntaxNodeProtocol) {
self = .decl(RawDeclSyntax(decl))
}
The call sites should be more readable now?
item: .init(expr: RawMissingExprSyntax(arena: self.arena)),
@swift-ci Please test
@swift-ci Please test
@swift-ci Please test Windows
This PR aims to improve developer ergonomics when using the designated initializers of raw syntax nodes. Simply put, it's through achieving feature parity with the non-raw side.
Prefer generic types over type erasure types
Currently the designated initializer of
RawXXXSyntax
always uses type-erased types instead of generic types as parameter types, leading to much clunkiness, e.g.The initializer body, however, only invokes
pattern.raw
, therefore we could just replacepattern: RawPatternSyntax
withpattern: some RawPatternSyntaxNodeProtocol
transparently,Actually it's what
PatternExprSyntax.init
has been doing,Generate convenience generic initializers for choices enum
e.g.
So call sites might get rid of type erasure as follows,
Remove type erasure in call sites
This PR has removed unnecessary uses of type-erased types in many call sites thanks to the new initializers.