swiftlang/swift

Error says `@preconcurrency` only applies in inheritance clauses

Open

#88.338 aperta il 7 apr 2026

Vedi su GitHub
 (2 commenti) (0 reazioni) (0 assegnatari)Swift (10.719 fork)batch import
@preconcurrencyTypeResolverattributescompilergood first issueswift 6.3type checker

Metriche repository

Star
 (69.989 star)
Metriche merge PR
 (Merge medio 7g 6h) (556 PR mergiate in 30 g)

Descrizione

Description

This is not true. The attribute can also be used on declarations such as types, functions, and imports.

Reproduction

let _: @preconcurrency @MainActor() -> Void = {}
error: '@preconcurrency' only applies in inheritance clauses
  83 | 
  84 | let _: @preconcurrency @MainActor() -> Void = {}
     |        `- error: '@preconcurrency' only applies in inheritance clauses
  85 | 

Expected behavior

An accurate error message. It might be better to say that @preconcurrency cannot be used on a type attribute instead of enumerating all the valid positions.

Environment

Swift version 6.3-dev (fefcb257b5b5d32)

Additional information

No response

Guida contributor