Skip to content

Commit f09cdc2

Browse files
committed
Fix deserialization assertion involving isolated conformances
1 parent e4f1b62 commit f09cdc2

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7928,7 +7928,7 @@ ConformanceIsolationRequest::evaluate(Evaluator &evaluator, ProtocolConformance
79287928
return ActorIsolation::forNonisolated(false);
79297929

79307930
// If we are inferring isolated conformances and the conforming type is
7931-
// isolated to a global actor,
7931+
// isolated to a global actor, use the conforming type's isolation.
79327932
auto nominal = dc->getSelfNominalTypeDecl();
79337933
if (ctx.LangOpts.hasFeature(Feature::InferIsolatedConformances) &&
79347934
nominal) {

lib/Serialization/Deserialization.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1058,8 +1058,11 @@ ProtocolConformanceDeserializer::readNormalProtocolConformance(
10581058
auto globalActorType = globalActorTypeOrError.get();
10591059

10601060
TypeExpr *globalActorTypeExpr = nullptr;
1061-
if (globalActorType)
1061+
if (globalActorType) {
10621062
globalActorTypeExpr = TypeExpr::createImplicit(globalActorType, ctx);
1063+
rawOptions |=
1064+
static_cast<unsigned>(ProtocolConformanceFlags::GlobalActorIsolated);
1065+
}
10631066

10641067
auto conformance = ctx.getNormalConformance(
10651068
conformingType, proto, SourceLoc(), dc,

test/Serialization/Inputs/def_isolated_conformance.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,8 @@ public class MyClass { }
88
extension MyClass: @MainActor MyProtocol {
99
@MainActor public func f() { }
1010
}
11+
12+
public protocol OtherProtocol {
13+
}
14+
15+
extension MyClass: OtherProtocol { }
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %target-swift-frontend -emit-module -target %target-swift-5.1-abi-triple -swift-version 6 -o %t/def_isolated_conformance.swiftmodule %S/Inputs/def_isolated_conformance.swift
2+
// RUN: %target-swift-frontend -emit-module -target %target-swift-5.1-abi-triple -swift-version 6 -o %t/def_isolated_conformance.swiftmodule %S/Inputs/def_isolated_conformance.swift -default-isolation=MainActor
33

44
// RUN: %target-swift-frontend -typecheck -verify -target %target-swift-5.1-abi-triple -swift-version 6 %s -I %t
55

@@ -8,8 +8,11 @@
88
import def_isolated_conformance
99

1010
func acceptMyProtocol(_: some MyProtocol) { }
11+
func acceptOtherProtocol(_: some MyProtocol) { }
1112

1213
nonisolated func f(mc: MyClass) {
1314
acceptMyProtocol(mc)
1415
// expected-error@-1{{main actor-isolated conformance of 'MyClass' to 'MyProtocol' cannot be used in nonisolated context}}
16+
acceptOtherProtocol(mc)
17+
// expected-error@-1{{main actor-isolated conformance of 'MyClass' to 'MyProtocol' cannot be used in nonisolated context}}
1518
}

0 commit comments

Comments
 (0)