Ignore bad @_hasStorage in module interfaces

An objcImpl bug previously caused `@_hasStorage` to be emitted inside some extensions in module interfaces. An earlier commit in this PR created an error for this, but for backwards compatibility, it would actually be better to simply ignore the attribute in module interfaces. Modify TypeCheckStorage to emit a warning, not an error, in this situation.

Additionally, modify the module interface loader to show warnings when you verify a module interface, but not for other module interface uses (like compiling or importing one). The assumption here is that if you’re verifying a module interface, you’re either the author of the module that created it or you’re investigating a problem with it, and in either case you’d like to be told about minor defects in case they’re related.

Fixes rdar://144811653 thoroughly.
This commit is contained in:
Becca Royal-Gordon
2025-03-27 18:25:11 -07:00
parent 29a2d32d0e
commit ce8cc1780a
4 changed files with 20 additions and 11 deletions

View File

@@ -1,10 +1,9 @@
// 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}}
@_hasStorage public var foo: Int { get set } // expected-warning {{'@_hasStorage' attribute cannot be applied to declaration in extension}}
}