You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CodeGeneration/Sources/SyntaxSupport/AvailabilityNodes.swift
+1
Original file line number
Diff line number
Diff line change
@@ -158,6 +158,7 @@ public let AVAILABILITY_NODES: [Node] = [
158
158
base:.syntax,
159
159
nameForDiagnostics:"version tuple",
160
160
documentation:"A version number like `1.2.0`. Only the first version component is required. There might be an arbitrary number of following components.",
- Description: With the change to parse `#if canImport(MyModule, _version: 1.2.3)` as a function call instead of a dedicated syntax node, `1.2.3` natively gets parsed as a member access `3` to the `1.2` float literal. This property allows the reinterpretation of such an expression as a version tuple.
-` CanImportExprSyntax` and `CanImportVersionInfoSyntax`
108
+
- Description: Instead of parsing `canImport` inside `#if` directives as a special expression node, parse it as a functionc call expression. This is in-line with how the `swift(>=6.0)` and `compiler(>=6.0)` directives are parsed.
/// Parse the source code of this node as a `VersionTupleSyntax`.
17
+
///
18
+
/// In some situations, like the `_version` argument of the `canImport` condition in `#if`, the version gets parsed as a normal expression, which results in
19
+
/// - an integer literal for single-component versions
20
+
/// - a floating point number for two-component versions
21
+
/// - a floating point number with a member accesses for versions with more than three components
22
+
///
23
+
/// This is done so the parser can parse `canImport` like any other function call, reducing the need for special handling.
24
+
///
25
+
/// This property re-interprets such an expression as a version tuple in cases where the client know that it should semantically represent a version.
26
+
///
27
+
/// If the expression cannot be interpreted as a valid version tuple, returns `nil`.
0 commit comments