From 9c1c68d247a113558b33cb5231e0568cb78ab915 Mon Sep 17 00:00:00 2001 From: Cristian Magherusan-Stanciu Date: Thu, 15 Oct 2026 08:00:37 +0200 Subject: [PATCH] fix(closures): make callback captures explicit Qualify the rotor's captured `elements` access and snapshot the text size variant before the escaping Foundation callback. This removes the implicit- self and mutating-self diagnostics when the Foundation callback is escaping. Co-Authored-By: Claude Sonnet 5.5 --- Sources/OpenSwiftUI/Accessibility/AccessibilityRotor.swift | 2 +- Sources/OpenSwiftUICore/View/Text/Text/Text+View.swift | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Sources/OpenSwiftUI/Accessibility/AccessibilityRotor.swift b/Sources/OpenSwiftUI/Accessibility/AccessibilityRotor.swift index 07a16e62c..66e4bd65e 100644 --- a/Sources/OpenSwiftUI/Accessibility/AccessibilityRotor.swift +++ b/Sources/OpenSwiftUI/Accessibility/AccessibilityRotor.swift @@ -156,7 +156,7 @@ extension AccessibilityLinkRotorBridge { elements.removeAll(keepingCapacity: true) paragraph.enumerateAttribute(.coreAXLink, in: NSRange(location: 0, length: paragraph.length)) { value, range, _ in if value as? Bool == true { - elements.append(Self.linkElement(for: node, range: range)) + self.elements.append(Self.linkElement(for: node, range: range)) } } } diff --git a/Sources/OpenSwiftUICore/View/Text/Text/Text+View.swift b/Sources/OpenSwiftUICore/View/Text/Text/Text+View.swift index 239bcd4b3..ac341db4c 100644 --- a/Sources/OpenSwiftUICore/View/Text/Text/Text+View.swift +++ b/Sources/OpenSwiftUICore/View/Text/Text/Text+View.swift @@ -1681,6 +1681,7 @@ private struct DynamicTextView: PrimitiveView, UnaryView { private struct DynamicTextHelper: SizeFittingTextResolver { let view: DynamicTextView lazy var widthAdaptedText: ResolvedStyledText = { + let currentSizeVariant = sizeVariant var isUniqueSizeVariant = sizeVariant == .regular let storage: NSMutableAttributedString? if view.text.layoutProperties.sizeFitting { @@ -1695,7 +1696,7 @@ private struct DynamicTextView: PrimitiveView, UnaryView { ) as? any ResolvableStringAttribute else { return } - let variant = resolvable.sizeVariant(sizeVariant) + let variant = resolvable.sizeVariant(currentSizeVariant) isUniqueSizeVariant = isUniqueSizeVariant || variant.exact result.addAttribute( value.resolvableAttributeKey,