Skip to content

Commit de44396

Browse files
committed
Always enable "missing" conformances to Sendable.
Always build the conformances, and produce warnings/errors when they are needed during type checking.
1 parent c79fa23 commit de44396

File tree

5 files changed

+14
-13
lines changed

5 files changed

+14
-13
lines changed

include/swift/AST/Decl.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3251,7 +3251,8 @@ class NominalTypeDecl : public GenericTypeDecl, public IterableDeclContext {
32513251
///
32523252
/// This is used by deserialization of module files to report
32533253
/// conformances.
3254-
void registerProtocolConformance(ProtocolConformance *conformance);
3254+
void registerProtocolConformance(ProtocolConformance *conformance,
3255+
bool synthesized = false);
32553256

32563257
void setConformanceLoader(LazyMemberLoader *resolver, uint64_t contextData);
32573258

lib/AST/Module.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -996,8 +996,7 @@ static ProtocolConformanceRef getInvalidOrMissingConformance(
996996
// Introduce "missing" conformances to Sendable, so that type checking
997997
// (and even code generation) can continue.
998998
ASTContext &ctx = proto->getASTContext();
999-
if (proto->isSpecificProtocol(KnownProtocolKind::Sendable) &&
1000-
ctx.LangOpts.WarnConcurrency) {
999+
if (proto->isSpecificProtocol(KnownProtocolKind::Sendable)) {
10011000
return ProtocolConformanceRef(
10021001
ctx.getBuiltinConformance(
10031002
type, proto, GenericSignature(), { },

lib/AST/ProtocolConformance.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,9 +1320,9 @@ void NominalTypeDecl::getImplicitProtocols(
13201320
}
13211321

13221322
void NominalTypeDecl::registerProtocolConformance(
1323-
ProtocolConformance *conformance) {
1323+
ProtocolConformance *conformance, bool synthesized) {
13241324
prepareConformanceTable();
1325-
ConformanceTable->registerProtocolConformance(conformance);
1325+
ConformanceTable->registerProtocolConformance(conformance, synthesized);
13261326
}
13271327

13281328
ArrayRef<ValueDecl *>

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3741,6 +3741,7 @@ NormalProtocolConformance *GetImplicitSendableRequest::evaluate(
37413741
conformance->setSourceKindAndImplyingConformance(
37423742
ConformanceEntryKind::Synthesized, nullptr);
37433743

3744+
nominal->registerProtocolConformance(conformance, /*synthesized=*/true);
37443745
return conformance;
37453746
};
37463747

test/Concurrency/concurrent_value_inference.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-typecheck-verify-swift -enable-library-evolution -disable-availability-checking
1+
// RUN: %target-typecheck-verify-swift -enable-library-evolution
22
// REQUIRES: concurrency
33

44
class C1 { }
@@ -27,7 +27,6 @@ struct GS2<T> {
2727
}
2828

2929
func acceptCV<T: Sendable>(_: T) { }
30-
// expected-note@-1 6{{where 'T' =}}
3130

3231
// Example that was triggering circular dependencies.
3332
struct Signature { }
@@ -86,6 +85,7 @@ struct HasFunctions {
8685
var cfp: @convention(c) () -> Void
8786
}
8887

88+
@available(SwiftStdlib 5.5, *)
8989
@globalActor
9090
actor MyGlobalActor {
9191
static let shared = MyGlobalActor()
@@ -103,22 +103,22 @@ func testCV(
103103
fps: FrozenPublicStruct, fpe: FrozenPublicEnum,
104104
hf: HasFunctions
105105
) {
106-
acceptCV(c1) // expected-error{{'C1' conform to 'Sendable'}}
106+
acceptCV(c1) // expected-warning{{type 'C1' does not conform to the 'Sendable' protocol}}
107107
acceptCV(c2)
108108
acceptCV(c3)
109109
acceptCV(c4)
110110
acceptCV(s1)
111-
acceptCV(e1) // expected-error{{'E1' conform to 'Sendable'}}
111+
acceptCV(e1) // expected-warning{{type 'E1' does not conform to the 'Sendable'}}
112112
acceptCV(e2)
113113
acceptCV(gs1)
114-
acceptCV(gs2) // expected-error{{'GS2<Int>' conform to 'Sendable'}}
114+
acceptCV(gs2) // expected-warning{{type 'GS2<Int>' does not conform to the 'Sendable' protocol}}
115115

116116
// Not available due to recursive conformance dependencies.
117-
acceptCV(bc) // expected-error{{global function 'acceptCV' requires that 'Bitcode' conform to 'Sendable'}}
117+
acceptCV(bc) // expected-warning{{type 'Bitcode' does not conform to the 'Sendable' protocol}}
118118

119119
// Not available due to "public".
120-
acceptCV(ps) // expected-error{{global function 'acceptCV' requires that 'PublicStruct' conform to 'Sendable'}}
121-
acceptCV(pe) // expected-error{{global function 'acceptCV' requires that 'PublicEnum' conform to 'Sendable'}}
120+
acceptCV(ps) // expected-warning{{type 'PublicStruct' does not conform to the 'Sendable' protocol}}
121+
acceptCV(pe) // expected-warning{{type 'PublicEnum' does not conform to the 'Sendable' protocol}}
122122

123123
// Public is okay when also @frozen.
124124
acceptCV(fps)

0 commit comments

Comments
 (0)