Skip to content

[SR-6572] Specialize ExtensionDeclSyntax in libSyntax Parsing #49122

@nkcsgexi

Description

@nkcsgexi
Previous ID SR-6572
Radar None
Original Reporter @nkcsgexi
Type Task
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Source Tooling
Labels Task
Assignee sigito (JIRA)
Priority Medium

md5: 0c91fdc7ba3ed9ea78b10c4bea2ed8fd

Issue Description:

Currently, libSyntax parsing doesn't specialize extension declarations, meaning all extension declarations are manifested as UnkownDecl. Since libSyntax clients will very likely interested in specialized analysis on extensions. We need to teach the parser to specialize them.

To demo what we have now:

$cat ~/Desktop/test.swift
extension C{}
func foo() {}
$../build/Ninja-DebugAssert/swift-macosx-x86_64/bin/swift-syntax-test -input-source-filename ~/Desktop/test.swift -parse-gen -print-node-kind -print-trivial-node-kind
<SourceFile><DeclList><TopLevelCodeDecl><StmtList><DeclarationStmt><UnknownDecl>extension <SimpleTypeIdentifier>C</SimpleTypeIdentifier>{<DeclList></DeclList>}</UnknownDecl></DeclarationStmt><DeclarationStmt><FunctionDecl>
func foo<FunctionSignature>(<FunctionParameterList></FunctionParameterList>) </FunctionSignature><CodeBlock>{<StmtList></StmtList>}</CodeBlock></FunctionDecl></DeclarationStmt></StmtList></TopLevelCodeDecl></DeclList>
</SourceFile>

See that the function decl is specialized however the extension decl is not. The desirable feature will be having extension decls specialized as well. One can follow the patch we specialized struct declaration from: c4604d7

Metadata

Metadata

Assignees

No one assigned

    Labels

    compilerThe Swift compiler itselfdeclarationsFeature: declarationsextensionFeature → declarations: `extension` declarationsparserArea → compiler: The legacy C++ parser† libswiftSyntaxArchive • Area → compiler: the once-integrated C++ Syntax library succeeded by SwiftSyntax

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions