Diagnose invalid @_hasStorage attributes

A bug in `@objc @implementation` is causing incorrect `@_hasStorage` attributes to be printed into module interfaces. As an initial step towards fixing this, diagnose bad `@_hasStorage` attributes and treat them as computed properties so that these malformed interfaces don’t cause compiler crashes.

Partially fixes rdar://144811653.
This commit is contained in:
Becca Royal-Gordon
2025-03-27 16:24:44 -07:00
parent 51face17da
commit c44284d874
5 changed files with 29 additions and 4 deletions

View File

@@ -0,0 +1,10 @@
// swift-interface-format-version: 1.0
// swift-module-flags:
// expected-error@-2 {{failed to verify module interface of 'Test' due to the errors above}}
// RUN: %target-swift-typecheck-module-from-interface(%s) -module-name Test -verify -verify-ignore-unknown
// REQUIRES: OS=macosx
extension Array {
@_hasStorage public var foo: Int { get set } // expected-error {{'@_hasStorage' attribute cannot be applied to declaration in extension}}
}