This repository was archived by the owner on Jun 27, 2023. It is now read-only.
Description I think when the context is active, it should return the reflected.1. However currently it returns reflected.0.
func decode<T>(_ type: T.Type, forKey key: K) throws -> T where T : Decodable {
if nextIsOptional {
context.addProperty(type: T?.self, at: codingPath + [key])
nextIsOptional = false
} else {
context.addProperty(type: T.self, at: codingPath + [key])
}
if let type = T.self as? AnyReflectionDecodable.Type, let reflected = try? type.anyReflectDecoded() {
if context.isActive {
context.activeCodingPath = codingPath + [key]
return reflected.0 as! T
}
return reflected.1 as! T
} else {
let decoder = ReflectionDecoder(codingPath: codingPath + [key], context: context)
return try T(from: decoder)
}
}
https://github.com/vapor/core/blob/master/Sources/Core/CodableReflection/ReflectionDecoders.swift#L144
The default implementation of ReflectionDecodable sets the .0 to be falsy value and .1 to be truthy value.
eg.
extension Bool: ReflectionDecodable {
/// See `ReflectionDecodable.reflectDecoded()` for more information.
public static func reflectDecoded() -> (Bool, Bool) { return (false, true) }
}
extension FixedWidthInteger {
/// See `ReflectionDecodable.reflectDecoded()` for more information.
public static func reflectDecoded() -> (Self, Self) { return (0, 1) }
}
Reactions are currently unavailable
I think when the context is active, it should return the
reflected.1. However currently it returnsreflected.0.https://github.com/vapor/core/blob/master/Sources/Core/CodableReflection/ReflectionDecoders.swift#L144
The default implementation of ReflectionDecodable sets the .0 to be falsy value and .1 to be truthy value.
eg.