AST: Skip serializing non-public accessors of @backDeployed properties.

Avoids a crash in SILGen when skipping non-inlinable function bodies.

Resolves rdar://136853454.
This commit is contained in:
Allan Shortlidge
2025-07-27 11:28:27 -07:00
parent c4a9bf0109
commit 7d866bfe69
8 changed files with 101 additions and 11 deletions

View File

@@ -34,6 +34,18 @@ public struct TopLevelStruct {
set(newValue) {}
}
@backDeployed(before: macOS 12.0)
public private(set) var readWritePropertyPrivateSet: Int {
get { 42 }
set(newValue) {}
}
@backDeployed(before: macOS 12.0)
public internal(set) var readWritePropertyInternalSet: Int {
get { 42 }
set(newValue) {}
}
@backDeployed(before: macOS 12.0)
public subscript(at index: Int) -> Int {
get { 42 }
@@ -234,7 +246,6 @@ public final class CannotBackDeployClassDeinit {
deinit {}
}
// Ok, final decls in a non-final, derived class
public class CannotBackDeployOverride: TopLevelClass {
@backDeployed(before: macOS 12.0) // expected-error {{'@backDeployed' cannot be combined with 'override'}}
final public override func hook() {}
@@ -293,6 +304,40 @@ public func cannotBackDeployFuncWithOpaqueResultType() -> some TopLevelProtocol
return ConformsToTopLevelProtocol()
}
public struct CannotBackDeployNonPublicAccessors {
private var privateVar: Int {
@backDeployed(before: macOS 12.0) // expected-error {{'@backDeployed' may not be used on private declarations}}
get { 0 }
@backDeployed(before: macOS 12.0) // expected-error {{'@backDeployed' may not be used on private declarations}}
set { }
}
internal var internalVar: Int {
@backDeployed(before: macOS 12.0) // expected-error {{'@backDeployed' may not be used on internal declarations}}
get { 0 }
@backDeployed(before: macOS 12.0) // expected-error {{'@backDeployed' may not be used on internal declarations}}
set { }
}
public private(set) var publicVarPrivateSet: Int {
@backDeployed(before: macOS 12.0)
get { 0 }
@backDeployed(before: macOS 12.0) // expected-error {{'@backDeployed' may not be used on private declarations}}
set { }
}
public internal(set) var publicVarInternalSet: Int {
@backDeployed(before: macOS 12.0)
get { 0 }
@backDeployed(before: macOS 12.0) // expected-error {{'@backDeployed' may not be used on internal declarations}}
set { }
}
}
// MARK: - Function body diagnostics
public struct FunctionBodyDiagnostics {