Sema: Downgrade actor convenience initializer diagnostic to a warning in interfaces.

The `convenience` keyword is not accepted on actor initializers because the
compiler infers this status automatically and actors cannot be subclassed.
However, internally the compiler still computes whether an actor init is a
convenience init and this implicit status has been leaking through accidentally
in printed `.swiftinterface` files. This was noticed because in Swift 6 the
presence of the keyword is diagnosed as an error, making `.swiftinterface`
files unparseable for modules containing actors with convenience inits.

For Swift 6, I'm just going to suppress the error in `.swiftinterface` files
regardless of language mode. In future releases of the compiler, though, it can
stop printing the `convenience` keyword on these inits altogether, though.

Resolves rdar://130857256.
This commit is contained in:
Allan Shortlidge
2024-07-01 15:59:18 -07:00
parent a13c1dc2dc
commit 7cadb0b4e3
2 changed files with 27 additions and 3 deletions

View File

@@ -0,0 +1,22 @@
// RUN: %empty-directory(%t)
// RUN: %target-swift-emit-module-interface(%t/Library.swiftinterface) %s -module-name Library
// RUN: %target-swift-typecheck-module-from-interface(%t/Library.swiftinterface) -module-name Library
// RUN: %FileCheck %s --check-prefixes=CHECK < %t/Library.swiftinterface
// Re-verify with -swift-version 6
// RUN: %target-swift-emit-module-interface(%t/Library.swiftinterface) %s -swift-version 6 -module-name Library
// RUN: %target-swift-typecheck-module-from-interface(%t/Library.swiftinterface) -module-name Library
// RUN: %FileCheck %s --check-prefixes=CHECK < %t/Library.swiftinterface
// CHECK-LABEL: public actor TestActor {
@available(SwiftStdlib 5.5, *)
public actor TestActor {
// FIXME: The convenience keyword should be omitted (rdar://130926278)
// CHECK: public convenience init(convenience: Swift.Int)
public init(convenience: Int) {
self.init()
}
// CHECK: public init()
public init() {}
}