Skip to content

Commit 3a651a6

Browse files
committed
[Concurrency] Fix circular reference on isolation propagation.
1 parent a5b15ed commit 3a651a6

File tree

3 files changed

+31
-16
lines changed

3 files changed

+31
-16
lines changed

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,9 @@ static Optional<ActorIsolation> getIsolationFromWitnessedRequirements(
10351035
if (!idc)
10361036
return None;
10371037

1038+
if (dc->getSelfProtocolDecl())
1039+
return None;
1040+
10381041
// Walk through each of the conformances in this context, collecting any
10391042
// requirements that have actor isolation.
10401043
auto conformances = evaluateOrDefault(
@@ -1167,6 +1170,12 @@ ActorIsolation ActorIsolationRequest::evaluate(
11671170
}
11681171
}
11691172

1173+
// If this is an accessor, use the actor isolation of its storage
1174+
// declaration.
1175+
if (auto accessor = dyn_cast<AccessorDecl>(value)) {
1176+
return getActorIsolation(accessor->getStorage());
1177+
}
1178+
11701179
// If the declaration witnesses a protocol requirement that is isolated,
11711180
// use that.
11721181
if (auto witnessedIsolation = getIsolationFromWitnessedRequirements(value)) {
@@ -1194,14 +1203,6 @@ ActorIsolation ActorIsolationRequest::evaluate(
11941203
}
11951204
}
11961205

1197-
// If this is an accessor, use the actor isolation of its storage
1198-
// declaration.
1199-
if (auto accessor = dyn_cast<AccessorDecl>(value)) {
1200-
auto storageIsolation = getActorIsolation(accessor->getStorage());
1201-
if (!storageIsolation.isUnspecified())
1202-
return inferredIsolation(storageIsolation);
1203-
}
1204-
12051206
// If the declaration is in an extension that has one of the isolation
12061207
// attributes, use that.
12071208
if (auto ext = dyn_cast<ExtensionDecl>(value->getDeclContext())) {

test/Incremental/Verifier/single-file-private/AnyObject.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,17 @@ func lookupOnAnyObject(object: AnyObject) { // expected-provides {{lookupOnAnyOb
7272
// expected-member {{Swift.CVarArg.someMethod}}
7373
// expected-member {{Swift.CustomStringConvertible.someMethod}}
7474
// expected-member {{Swift.CustomDebugStringConvertible.someMethod}}
75+
// expected-member {{Swift.Equatable.someMember}}
76+
// expected-member{{Swift.CustomDebugStringConvertible.init}}
77+
// expected-member{{Swift.CVarArg.someMember}}
78+
// expected-member{{Foundation._KeyValueCodingAndObservingPublishing.someMember}}
79+
// expected-member{{Swift.Equatable.init}}
80+
// expected-member{{Swift.Hashable.init}}
81+
// expected-member{{Swift.CVarArg.init}}
82+
// expected-member{{Foundation._KeyValueCodingAndObserving.someMember}}
83+
// expected-member{{Foundation._KeyValueCodingAndObservingPublishing.init}}
84+
// expected-member{{Swift.CustomDebugStringConvertible.someMember}}
85+
// expected-member{{Swift.CustomStringConvertible.someMember}}
86+
// expected-member{{Swift.CustomStringConvertible.init}}
87+
// expected-member{{Swift.Hashable.someMember}}
88+
// expected-member{{Foundation._KeyValueCodingAndObserving.init}}

test/decl/class/circular_inheritance.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
// RUN: not %target-swift-frontend -typecheck -debug-cycles %s -build-request-dependency-graph -output-request-graphviz %t.dot -stats-output-dir %t/stats-dir 2> %t.cycles
55
// RUN: %FileCheck -check-prefix CHECK-DOT %s < %t.dot
66

7-
class Left // expected-error {{'Left' inherits from itself}} expected-note {{through reference here}}
7+
class Left // expected-error {{'Left' inherits from itself}} expected-note 2{{through reference here}}
88
: Right.Hand { // expected-note {{through reference here}}
9-
class Hand {}
9+
class Hand {} // expected-note {{through reference here}}
1010
}
1111

12-
class Right // expected-note {{through reference here}} expected-note{{class 'Right' declared here}}
12+
class Right // expected-note 2 {{through reference here}} expected-note{{class 'Right' declared here}}
1313
: Left.Hand { // expected-note {{through reference here}}
14-
class Hand {}
14+
class Hand {} // expected-error {{circular reference}}
1515
}
1616

1717
class C : B { } // expected-error{{'C' inherits from itself}}
@@ -30,15 +30,15 @@ class Outer {
3030
class Inner : Outer {}
3131
}
3232

33-
class Outer2 // expected-error {{'Outer2' inherits from itself}} expected-note {{through reference here}}
33+
class Outer2 // expected-error {{'Outer2' inherits from itself}} expected-note 2 {{through reference here}}
3434
: Outer2.Inner { // expected-note {{through reference here}}
3535

36-
class Inner {}
36+
class Inner {} // expected-error{{circular reference}}
3737
}
3838

39-
class Outer3 // expected-error {{'Outer3' inherits from itself}} expected-note {{through reference here}}
39+
class Outer3 // expected-error {{'Outer3' inherits from itself}} expected-note 2 {{through reference here}}
4040
: Outer3.Inner<Int> { // expected-note {{through reference here}}
41-
class Inner<T> {}
41+
class Inner<T> {} // expected-error{{circular reference}}
4242
}
4343

4444
// CHECK-DOT: digraph Dependencies

0 commit comments

Comments
 (0)