mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Fix deserialization assertion involving isolated conformances
(cherry picked from commit f09cdc2893)
This commit is contained in:
@@ -7942,7 +7942,7 @@ ConformanceIsolationRequest::evaluate(Evaluator &evaluator, ProtocolConformance
|
||||
return ActorIsolation::forNonisolated(false);
|
||||
|
||||
// If we are inferring isolated conformances and the conforming type is
|
||||
// isolated to a global actor,
|
||||
// isolated to a global actor, use the conforming type's isolation.
|
||||
auto nominal = dc->getSelfNominalTypeDecl();
|
||||
if (ctx.LangOpts.hasFeature(Feature::InferIsolatedConformances) &&
|
||||
nominal) {
|
||||
|
||||
@@ -1058,8 +1058,11 @@ ProtocolConformanceDeserializer::readNormalProtocolConformance(
|
||||
auto globalActorType = globalActorTypeOrError.get();
|
||||
|
||||
TypeExpr *globalActorTypeExpr = nullptr;
|
||||
if (globalActorType)
|
||||
if (globalActorType) {
|
||||
globalActorTypeExpr = TypeExpr::createImplicit(globalActorType, ctx);
|
||||
rawOptions |=
|
||||
static_cast<unsigned>(ProtocolConformanceFlags::GlobalActorIsolated);
|
||||
}
|
||||
|
||||
auto conformance = ctx.getNormalConformance(
|
||||
conformingType, proto, SourceLoc(), dc,
|
||||
|
||||
@@ -8,3 +8,8 @@ public class MyClass { }
|
||||
extension MyClass: @MainActor MyProtocol {
|
||||
@MainActor public func f() { }
|
||||
}
|
||||
|
||||
public protocol OtherProtocol {
|
||||
}
|
||||
|
||||
extension MyClass: OtherProtocol { }
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// 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
|
||||
// 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
|
||||
|
||||
// RUN: %target-swift-frontend -typecheck -verify -target %target-swift-5.1-abi-triple -swift-version 6 %s -I %t
|
||||
|
||||
@@ -8,8 +8,11 @@
|
||||
import def_isolated_conformance
|
||||
|
||||
func acceptMyProtocol(_: some MyProtocol) { }
|
||||
func acceptOtherProtocol(_: some MyProtocol) { }
|
||||
|
||||
nonisolated func f(mc: MyClass) {
|
||||
acceptMyProtocol(mc)
|
||||
// expected-error@-1{{main actor-isolated conformance of 'MyClass' to 'MyProtocol' cannot be used in nonisolated context}}
|
||||
acceptOtherProtocol(mc)
|
||||
// expected-error@-1{{main actor-isolated conformance of 'MyClass' to 'MyProtocol' cannot be used in nonisolated context}}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user