swiftlang/swift

Error says `@preconcurrency` only applies in inheritance clauses

開放

#88,338 建立於 2026年4月7日

 (2 則留言) (0 個反應) (0 位負責人)Swift (10,719 個分叉)batch import
@preconcurrencyTypeResolverattributescompilerdiagnostics qualitygood first issueswift 6.3type checker

倉庫指標

星標
 (69,989 顆星)
PR 合併指標
 (平均合併 8天 17小時) (30 天內合併 510 個 PR)

描述

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

貢獻者指南