Skip to content

Commit 0cca70b

Browse files
authored
Merge pull request #37260 from xedin/rdar-76475495
[Sema] Suppress concurrency related diagnostics for invalid AST nodes
2 parents 094f6cf + 0e9c33e commit 0cca70b

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

lib/Sema/TypeCheckEffects.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2620,9 +2620,10 @@ class CheckEffectsCoverage : public EffectsHandlingWalker<CheckEffectsCoverage>
26202620

26212621
void checkThrowAsyncSite(ASTNode E, bool requiresTry,
26222622
const Classification &classification) {
2623-
// Suppress all diagnostics when there's an un-analyzable throw site.
2623+
// Suppress all diagnostics when there's an un-analyzable throw/async site.
26242624
if (classification.isInvalid()) {
26252625
Flags.set(ContextFlags::HasAnyThrowSite);
2626+
Flags.set(ContextFlags::HasAnyAsyncSite);
26262627
if (requiresTry) Flags.set(ContextFlags::HasTryThrowSite);
26272628
return;
26282629
}

test/Concurrency/actor_inout_isolation.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,6 @@ actor MyActor {
184184
// expected-error@+1{{actor-isolated property 'int' cannot be passed 'inout' to 'async' function call}}
185185
await modifyAsynchronously(&(int))
186186

187-
// This warning is emitted because this fails to typecheck before the
188-
// async-ness is attached.
189-
// expected-warning@+2{{no 'async' operations occur within 'await' expression}}
190187
// expected-error@+1{{cannot pass immutable value of type 'Int' as inout argument}}
191188
await modifyAsynchronously(&(maybePoint?.z)!)
192189
// expected-error@+2{{actor-isolated property 'position' can only be used 'inout' from inside the actor}}

test/Concurrency/async_tasks.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ func test_unsafeContinuations() async {
5555
let _: String = await withUnsafeContinuation { continuation in
5656
continuation.resume(returning: "")
5757
}
58+
59+
// rdar://76475495 - suppress warnings for invalid expressions
60+
func test_invalid_async_no_warnings() async -> Int {
61+
return await withUnsafeContinuation {
62+
$0.resume(throwing: 1) // expected-error {{cannot convert value of type 'Int' to expected argument type 'Never'}}
63+
}
64+
}
5865
}
5966

6067
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)

0 commit comments

Comments
 (0)