diff --git a/lib/Sema/TypeCheckConcurrency.cpp b/lib/Sema/TypeCheckConcurrency.cpp index d69c232cecf3d..d4cdb4e30195b 100644 --- a/lib/Sema/TypeCheckConcurrency.cpp +++ b/lib/Sema/TypeCheckConcurrency.cpp @@ -3957,10 +3957,9 @@ bool swift::checkSendableConformance( // Sendable can only be used in the same source file. auto conformanceDecl = conformanceDC->getAsDecl(); - auto behavior = SendableCheckContext(conformanceDC) + auto behavior = SendableCheckContext(conformanceDC, check) .defaultDiagnosticBehavior(); if (conformanceDC->getParentSourceFile() && - nominal->getParentSourceFile() && conformanceDC->getParentSourceFile() != nominal->getParentSourceFile()) { conformanceDecl->diagnose(diag::concurrent_value_outside_source_file, nominal->getDescriptiveKind(), diff --git a/test/Concurrency/Inputs/NonStrictModule.swift b/test/Concurrency/Inputs/NonStrictModule.swift index b0e3f1769ccf5..a72f11d3c7deb 100644 --- a/test/Concurrency/Inputs/NonStrictModule.swift +++ b/test/Concurrency/Inputs/NonStrictModule.swift @@ -1 +1,3 @@ public class NonStrictClass { } + +public struct NonStrictStruct { } diff --git a/test/Concurrency/sendable_conformance_checking.swift b/test/Concurrency/sendable_conformance_checking.swift index 5d7349f546f27..1ea9018047f43 100644 --- a/test/Concurrency/sendable_conformance_checking.swift +++ b/test/Concurrency/sendable_conformance_checking.swift @@ -147,6 +147,7 @@ actor A10: AsyncThrowingProtocolWithNotSendable { } // rdar://86653457 - Crash due to missing Sendable conformances. +// expected-warning@+1{{non-final class 'Klass' cannot conform to 'Sendable'; use '@unchecked Sendable'}} class Klass: Sendable {} final class SubKlass: Klass<[S]> {} public struct S {} diff --git a/test/Concurrency/sendable_module_checking.swift b/test/Concurrency/sendable_module_checking.swift index 03823632717d8..8814c1e159453 100644 --- a/test/Concurrency/sendable_module_checking.swift +++ b/test/Concurrency/sendable_module_checking.swift @@ -17,3 +17,5 @@ func testA(a: A) async { // CHECK: note: struct 'StrictStruct' does not conform to the 'Sendable' protocol // CHECK: note: class 'NonStrictClass' does not conform to the 'Sendable' protocol } + +extension NonStrictStruct: @unchecked Sendable { } diff --git a/test/decl/protocol/special/Actor.swift b/test/decl/protocol/special/Actor.swift index df1f39a99f89d..6b9f19055f7ca 100644 --- a/test/decl/protocol/special/Actor.swift +++ b/test/decl/protocol/special/Actor.swift @@ -44,6 +44,7 @@ actor A7 { @available(SwiftStdlib 5.1, *) class C1: Actor { // expected-error@-1{{non-actor type 'C1' cannot conform to the 'Actor' protocol}} + // expected-warning@-2{{non-final class 'C1' cannot conform to 'Sendable'; use '@unchecked Sendable'}} nonisolated var unownedExecutor: UnownedSerialExecutor { fatalError("") } @@ -52,6 +53,7 @@ class C1: Actor { @available(SwiftStdlib 5.1, *) class C2: Actor { // expected-error@-1{{non-actor type 'C2' cannot conform to the 'Actor' protocol}} + // expected-warning@-2{{non-final class 'C2' cannot conform to 'Sendable'; use '@unchecked Sendable'}} // FIXME: this should be an isolation violation var unownedExecutor: UnownedSerialExecutor { fatalError("") @@ -62,6 +64,7 @@ class C2: Actor { class C3: Actor { // expected-error@-1{{type 'C3' does not conform to protocol 'Actor'}} // expected-error@-2{{non-actor type 'C3' cannot conform to the 'Actor' protocol}} + // expected-warning@-3{{non-final class 'C3' cannot conform to 'Sendable'; use '@unchecked Sendable'}} nonisolated func enqueue(_ job: UnownedJob) { } }