File tree Expand file tree Collapse file tree 3 files changed +40
-2
lines changed
Expand file tree Collapse file tree 3 files changed +40
-2
lines changed Original file line number Diff line number Diff line change @@ -5104,8 +5104,9 @@ bool swift::checkSendableConformance(
51045104 auto conformanceDecl = conformanceDC->getAsDecl ();
51055105 auto behavior = SendableCheckContext (conformanceDC, check)
51065106 .defaultDiagnosticBehavior ();
5107- if (conformanceDC->getParentSourceFile () &&
5108- conformanceDC->getParentSourceFile () != nominal->getParentSourceFile ()) {
5107+ if (conformanceDC->getOutermostParentSourceFile () &&
5108+ conformanceDC->getOutermostParentSourceFile () !=
5109+ nominal->getOutermostParentSourceFile ()) {
51095110 conformanceDecl->diagnose (diag::concurrent_value_outside_source_file,
51105111 nominal)
51115112 .limitBehavior (behavior);
Original file line number Diff line number Diff line change @@ -2057,6 +2057,31 @@ extension RequiredDefaultInitMacro: MemberMacro {
20572057 }
20582058}
20592059
2060+ public struct SendableMacro : ExtensionMacro {
2061+ public static func expansion(
2062+ of node: AttributeSyntax ,
2063+ attachedTo decl: some DeclGroupSyntax ,
2064+ providingExtensionsOf type: some TypeSyntaxProtocol ,
2065+ conformingTo protocols: [ TypeSyntax ] ,
2066+ in context: some MacroExpansionContext
2067+ ) throws -> [ ExtensionDeclSyntax ] {
2068+ if protocols. isEmpty {
2069+ return [ ]
2070+ }
2071+
2072+ let decl : DeclSyntax =
2073+ """
2074+ extension \( type. trimmed) : Sendable {
2075+ }
2076+
2077+ """
2078+
2079+ return [
2080+ decl. cast ( ExtensionDeclSyntax . self)
2081+ ]
2082+ }
2083+ }
2084+
20602085public struct FakeCodeItemMacro : DeclarationMacro , PeerMacro {
20612086 public static func expansion(
20622087 of node: some FreestandingMacroExpansionSyntax ,
Original file line number Diff line number Diff line change @@ -244,3 +244,15 @@ func testStringFoo(s: String) {
244244 " Test " . printFoo ( )
245245 s. printFoo ( )
246246}
247+
248+ @attached ( extension, conformances: Sendable)
249+ macro AddSendable( ) = #externalMacro( module: " MacroDefinition " , type: " SendableMacro " )
250+
251+ @AddSendable
252+ final class SendableClass {
253+ }
254+
255+ // expected-warning@+2 {{non-final class 'InvalidSendableClass' cannot conform to 'Sendable'; use '@unchecked Sendable'}}
256+ @AddSendable
257+ class InvalidSendableClass {
258+ }
You can’t perform that action at this time.
0 commit comments