Skip to content

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

Closed as duplicate of#82116
@dfed

Description

@dfed

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

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