Skip to content

Commit 72796b2

Browse files
committed
Fold a bunch of identical tryMarkImplicitlyAsync calls into one.
1 parent ec379b3 commit 72796b2

File tree

1 file changed

+8
-26
lines changed

1 file changed

+8
-26
lines changed

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1847,15 +1847,17 @@ namespace {
18471847
ConcurrentReferenceKind::CrossActor);
18481848
}
18491849

1850+
// Call is implicitly asynchronous.
1851+
auto result = tryMarkImplicitlyAsync(
1852+
loc, valueRef, context,
1853+
ImplicitActorHopTarget::forGlobalActor(globalActor));
1854+
if (result == AsyncMarkingResult::FoundAsync)
1855+
return false;
1856+
1857+
// Diagnose failures.
18501858
switch (contextIsolation) {
18511859
case ActorIsolation::DistributedActorInstance:
18521860
case ActorIsolation::ActorInstance: {
1853-
auto result = tryMarkImplicitlyAsync(
1854-
loc, valueRef, context,
1855-
ImplicitActorHopTarget::forGlobalActor(globalActor));
1856-
if (result == AsyncMarkingResult::FoundAsync)
1857-
return false;
1858-
18591861
auto useKind = static_cast<unsigned>(
18601862
kindOfUsage(value, context).getValueOr(VarRefUseEnv::Read));
18611863

@@ -1869,14 +1871,6 @@ namespace {
18691871

18701872
case ActorIsolation::GlobalActor:
18711873
case ActorIsolation::GlobalActorUnsafe: {
1872-
// Check if this decl reference is the callee of the enclosing Apply,
1873-
// making it OK as an implicitly async call.
1874-
auto result = tryMarkImplicitlyAsync(
1875-
loc, valueRef, context,
1876-
ImplicitActorHopTarget::forGlobalActor(globalActor));
1877-
if (result == AsyncMarkingResult::FoundAsync)
1878-
return false;
1879-
18801874
auto useKind = static_cast<unsigned>(
18811875
kindOfUsage(value, context).getValueOr(VarRefUseEnv::Read));
18821876

@@ -1891,12 +1885,6 @@ namespace {
18911885
}
18921886

18931887
case ActorIsolation::Independent: {
1894-
auto result = tryMarkImplicitlyAsync(
1895-
loc, valueRef, context,
1896-
ImplicitActorHopTarget::forGlobalActor(globalActor));
1897-
if (result == AsyncMarkingResult::FoundAsync)
1898-
return false;
1899-
19001888
auto useKind = static_cast<unsigned>(
19011889
kindOfUsage(value, context).getValueOr(VarRefUseEnv::Read));
19021890

@@ -1910,12 +1898,6 @@ namespace {
19101898
}
19111899

19121900
case ActorIsolation::Unspecified: {
1913-
auto result = tryMarkImplicitlyAsync(
1914-
loc, valueRef, context,
1915-
ImplicitActorHopTarget::forGlobalActor(globalActor));
1916-
if (result == AsyncMarkingResult::FoundAsync)
1917-
return false;
1918-
19191901
// Diagnose the reference.
19201902
auto useKind = static_cast<unsigned>(
19211903
kindOfUsage(value, context).getValueOr(VarRefUseEnv::Read));

0 commit comments

Comments
 (0)