diff --git a/Sources/JSONAST/JSON.Node.swift b/Sources/JSONAST/JSON.Node.swift index e8da24c..ef3ab8a 100644 --- a/Sources/JSONAST/JSON.Node.swift +++ b/Sources/JSONAST/JSON.Node.swift @@ -224,10 +224,12 @@ extension JSON.Node { /// - Returns: /// The closest value of ``Float16`` to the payload of this variant if it matches /// ``number(_:) [case]``, `nil` otherwise. + #if arch(arm64) @available(macOS 11.0, iOS 14.0, tvOS 14.0, watchOS 7.0, *) public func `as`(_: Float16.Type) -> Float16? { self.as(JSON.Number.self)?.as(Float16.self) } + #endif /// Attempts to load an instance of ``Number`` from this variant. /// diff --git a/Sources/JSONAST/JSON.Number.swift b/Sources/JSONAST/JSON.Number.swift index 3ba597a..073a01c 100644 --- a/Sources/JSONAST/JSON.Number.swift +++ b/Sources/JSONAST/JSON.Number.swift @@ -156,10 +156,12 @@ extension JSON.Number { /// Converts this numeric literal to a ``Float16`` value, or its closest /// floating-point representation. + #if arch(arm64) @available(macOS 11.0, iOS 14.0, tvOS 14.0, watchOS 7.0, *) public func `as`(_: Float16.Type) -> Float16? { self.parsed(as: Float16.self) } + #endif } extension JSON.Number { /// We want floating point types to roundtrip losslessly, the only way to guarantee that is diff --git a/Sources/JSONDecoding/Conformances/Float16 (ext).swift b/Sources/JSONDecoding/Conformances/Float16 (ext).swift index a677bd9..535f81c 100644 --- a/Sources/JSONDecoding/Conformances/Float16 (ext).swift +++ b/Sources/JSONDecoding/Conformances/Float16 (ext).swift @@ -1,6 +1,8 @@ +#if arch(arm64) @available(macOS 11.0, iOS 14.0, tvOS 14.0, watchOS 7.0, *) extension Float16: JSONDecodable { @inlinable public init(json: borrowing JSON.Node) throws { self = try json.cast { $0.as(Self.self) } } } +#endif diff --git a/Sources/JSONEncoding/Conformances/Float16 (ext).swift b/Sources/JSONEncoding/Conformances/Float16 (ext).swift index 8e067c7..34939ca 100644 --- a/Sources/JSONEncoding/Conformances/Float16 (ext).swift +++ b/Sources/JSONEncoding/Conformances/Float16 (ext).swift @@ -1,2 +1,4 @@ +#if arch(arm64) @available(macOS 11.0, iOS 14.0, tvOS 14.0, watchOS 7.0, *) extension Float16: JSONEncodable {} +#endif