swiftlang/swift

Error says `@preconcurrency` only applies in inheritance clauses

Open

#88.338 geöffnet am 7. Apr. 2026

Auf GitHub ansehen
 (2 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Swift (10.719 Forks)batch import
@preconcurrencyTypeResolverattributescompilergood first issueswift 6.3type checker

Repository-Metriken

Stars
 (69.989 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 7T 6h) (556 gemergte PRs in 30 T)

Beschreibung

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

Contributor Guide