swiftlang/swift

Error says `@preconcurrency` only applies in inheritance clauses

Open

#88.338 aberto em 7 de abr. de 2026

Ver no GitHub
 (2 comments) (0 reactions) (0 assignees)Swift (10.719 forks)batch import
@preconcurrencyTypeResolverattributescompilergood first issueswift 6.3type checker

Métricas do repositório

Stars
 (69.989 stars)
Métricas de merge de PR
 (Mesclagem média 7d 6h) (556 fundiu PRs em 30d)

Description

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

Guia do colaborador