Skip to content

Remove CanImportExprSyntax and provide API to interpret an ExprSyntax as a VersionTupleSyntax #1972

Closed
@ahoppen

Description

@ahoppen

canImport inside of #if should get parsed the same as in a normal expression position, eliminating the need for CanImportExprSyntax (sparked by link). This means that the parser won’t be able to generate diagnostics for invalid version numbers inside canImport anymore.

Instead, we should have a function on ExprSyntax that interprets the expression (which would be a FloatingLiteralExprSyntax for eg. 1.2) as a VersionTupleSyntax. If the ExprSyntax doesn’t represent a version, that function should return a list of diagnostics. SwiftIfConfig would then call that getter and would be responsible for reporting any errors that occur from interpreting the ExprSyntax of the _version argument as VersionTupleSyntax.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions