8000 Swift 6.2 emits "Capture of non-sendable type" warning incorrectly when declaring closure that captures generic type · Issue #82133 · swiftlang/swift · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Swift 6.2 emits "Capture of non-sendable type" warning incorrectly when declaring closure that captures generic type #82133

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

Closed
dfed opened this issue Jun 10, 2025 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels

Comments

@dfed
Copy link
dfed commented Jun 10, 2025

Description

Swift 6.2 seems to be incorrectly warning when referencing a generic type in a closure

Reproduction

public protocol ArgumentReceiving {
	associatedtype Arguments
}

public final class DeferredInitializer<T: ArgumentReceiving>: Sendable {
	public init(_ initializer: @escaping @Sendable (T.Arguments) -> T) {
		self.initializer = { initializer($0) } // WARNING: Capture of non-sendable type 'T.Type' in an isolated closure
		// self.initializer = initializer // When uncommented (and the prior line is commented out) this line builds without warning, as expected.
	}

	private let initializer: @Sendable (T.Arguments) -> T
}

Expected behavior

No warning emitted

Environment

Apple Swift version 6.2 (swiftlang-6.2.0.9.909 clang-1700.3.9.907)
Target: arm64-apple-macosx15.0
/Applications/Xcode-26.0.0-Beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-help intro

Additional information

No response

@dfed dfed added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels Jun 10, 2025
@dfed
Copy link
Author
dfed commented Jun 10, 2025

Oh snap – this is the same as #82116! Closing as dup.

@dfed dfed closed this as completed Jun 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels
Projects
None yet
Development

No branches or pull requests

1 participant
0