Skip to content

Commit 4932c02

Browse files
committed
Avoid concurrency-related adjustments during witness matching
We were only applying this logic for some declaration types, not all, which is silly. Fixes #61602 / rdar://101243966.
1 parent ac131df commit 4932c02

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2427,8 +2427,9 @@ ConstraintSystem::getTypeOfMemberReference(
24272427

24282428
// Adjust the opened type for concurrency.
24292429
Type origOpenedType = openedType;
2430-
if ((isa<AbstractFunctionDecl>(value) || isa<EnumElementDecl>(value)) &&
2431-
!isRequirementOrWitness(locator)) {
2430+
if (isRequirementOrWitness(locator)) {
2431+
// Don't adjust when doing witness matching, because that can cause cycles.
2432+
} else if (isa<AbstractFunctionDecl>(value) || isa<EnumElementDecl>(value)) {
24322433
unsigned numApplies = getNumApplications(
24332434
value, hasAppliedSelf, functionRefKind);
24342435
openedType = adjustFunctionTypeForConcurrency(

test/Concurrency/actor_isolation_cycle.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,20 @@ public struct S : P {
1010
public func g(_: Int) {}
1111
public func f(_: T) {}
1212
}
13+
14+
// https://github.com/apple/swift/issues/61602
15+
@available(SwiftStdlib 5.1, *)
16+
@MainActor protocol ProtocolWithAssociatedTypes {
17+
associatedtype ID: Hashable
18+
associatedtype Value
19+
20+
subscript(_ id: ID) -> Value { get set }
21+
}
22+
23+
@available(SwiftStdlib 5.1, *)
24+
final class ClassConforming<ID: Hashable,Value>: ProtocolWithAssociatedTypes {
25+
subscript(id: ID) -> Value {
26+
get { fatalError() }
27+
set { fatalError() }
28+
}
29+
}

0 commit comments

Comments
 (0)