Skip to content

Commit

Permalink
Enable the MirrorBypass logic in Swift 6 (#631)
Browse files Browse the repository at this point in the history
  • Loading branch information
gwynne authored Feb 18, 2025
1 parent dd5a92d commit 4f886eb
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions Sources/FluentKit/Model/MirrorBypass.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if compiler(<6)
#if compiler(<6.1)
@_silgen_name("swift_reflectionMirror_normalizedType")
internal func _getNormalizedType<T>(_: T, type: Any.Type) -> Any.Type

Expand All @@ -24,7 +24,7 @@ internal struct _FastChildIterator: IteratorProtocol {
deinit { self.freeFunc(self.ptr) }
}

#if compiler(<6)
#if compiler(<6.1)
private let subject: AnyObject
private let type: Any.Type
private let childCount: Int
Expand All @@ -34,7 +34,7 @@ internal struct _FastChildIterator: IteratorProtocol {
#endif
private var lastNameBox: _CStringBox?

#if compiler(<6)
#if compiler(<6.1)
fileprivate init(subject: AnyObject, type: Any.Type, childCount: Int) {
self.subject = subject
self.type = type
Expand All @@ -48,7 +48,7 @@ internal struct _FastChildIterator: IteratorProtocol {
#endif

init(subject: AnyObject) {
#if compiler(<6)
#if compiler(<6.1)
let type = _getNormalizedType(subject, type: Swift.type(of: subject))
self.init(
subject: subject,
Expand All @@ -69,7 +69,7 @@ internal struct _FastChildIterator: IteratorProtocol {
/// > Note: Ironically, in the fallback case that uses `Mirror` directly, preserving this semantic actually imposes
/// > an _additional_ performance penalty.
mutating func next() -> (name: UnsafePointer<CChar>?, child: Any)? {
#if compiler(<6)
#if compiler(<6.1)
guard self.index < self.childCount else {
self.lastNameBox = nil // ensure any lingering name gets freed
return nil
Expand Down Expand Up @@ -105,7 +105,7 @@ internal struct _FastChildIterator: IteratorProtocol {
}

internal struct _FastChildSequence: Sequence {
#if compiler(<6)
#if compiler(<6.1)
private let subject: AnyObject
private let type: Any.Type
private let childCount: Int
Expand All @@ -114,7 +114,7 @@ internal struct _FastChildSequence: Sequence {
#endif

init(subject: AnyObject) {
#if compiler(<6)
#if compiler(<6.1)
self.subject = subject
self.type = _getNormalizedType(subject, type: Swift.type(of: subject))
self.childCount = _getChildCount(subject, type: self.type)
Expand All @@ -124,7 +124,7 @@ internal struct _FastChildSequence: Sequence {
}

func makeIterator() -> _FastChildIterator {
#if compiler(<6)
#if compiler(<6.1)
_FastChildIterator(subject: self.subject, type: self.type, childCount: self.childCount)
#else
_FastChildIterator(iterator: self.children.makeIterator())
Expand Down

0 comments on commit 4f886eb

Please sign in to comment.