Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable the MirrorBypass logic in Swift 6 #631

Merged
merged 1 commit into from
Feb 18, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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