Skip to content

Commit 3889ede

Browse files
authored
Merge pull request swiftlang#74342 from slavapestov/flow-analysis-self-metatype-fix
SIL: Fix false positive in FlowIsolation with DynamicSelfType usage
2 parents 1eed24a + c270597 commit 3889ede

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

lib/SILOptimizer/Mandatory/FlowIsolation.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,12 @@ void AnalysisInfo::analyze(const SILArgument *selfParam) {
582582
worklist.pushUsesOfValueIfNotVisited(selfParam);
583583

584584
while (Operand *operand = worklist.pop()) {
585+
// A type-dependent use of `self` is an instruction that contains the
586+
// DynamicSelfType. These instructions do not access any protected
587+
// state.
588+
if (operand->isTypeDependent())
589+
continue;
590+
585591
SILInstruction *user = operand->getUser();
586592

587593
// First, check if this is an apply that involves `self`

test/Concurrency/flow_isolation.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -684,8 +684,7 @@ actor OhBrother {
684684
static var DefaultResult: Int { 10 }
685685

686686
init() {
687-
// expected-note@+2 {{after this closure involving 'self', only non-isolated properties of 'self' can be accessed from this init}}
688-
// expected-warning@+1 {{cannot access property 'giver' here in non-isolated initializer; this is an error in the Swift 6 language mode}}
687+
// this is OK: we're using DynamicSelfType but that doesn't access protected state.
689688
self.giver = { (x: OhBrother) -> Int in Self.DefaultResult }
690689
}
691690

0 commit comments

Comments
 (0)