Skip to content

Swift 6.2: -[UIViewPropertyAnimator addCompletion:] bridges in as @Sendable when it used to bridge in as @MainActor #82127

Closed
@harlanhaskins

Description

@harlanhaskins

Description

I think this happened with SE-0463.

This method signature:

UIKIT_EXTERN API_AVAILABLE(ios(10.0)) API_UNAVAILABLE(watchos) NS_SWIFT_UI_ACTOR
@interface UIViewPropertyAnimator : NSObject <UIViewImplicitlyAnimating, NSCopying>
// ...
- (void)addCompletion:(void (^)(UIViewAnimatingPosition finalPosition))completion;
//...
@end

Used to import as this, which implies @MainActor

func addCompletion(_ completion: @escaping (UIViewAnimatingPosition) -> Void)

And now imports as:

func addCompletion(_ completion: @Sendable @escaping (UIViewAnimatingPosition) -> Void)

Which no longer implies @mainactor. I think this was intended, but it's suboptimal because we have to now wrap all the closures with MainActor.assumeIsolated { ... } after updating to Xcode 26.0

Reproduction

import UIKit
@MainActor final class MyClass {
    var property: Int = 0
    func scheduleAnimation(_ animator: UIViewPropertyAnimator) {
        animator.addCompletion { _ in
            self.property = 10
        }
    }
}

Expected behavior

I would expect the @MainActor-ness of the class to inform the isolation of the @Sendable completion handler.

Environment

swift-driver version: 1.127.4.2 Apple Swift version 6.2 (swiftlang-6.2.0.9.909 clang-1700.3.9.907)

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.triage neededThis issue needs more specific labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions