Skip to content

[Sema] Suppress concurrency related diagnostics for invalid AST nodes #37260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/Sema/TypeCheckEffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2620,9 +2620,10 @@ class CheckEffectsCoverage : public EffectsHandlingWalker<CheckEffectsCoverage>

void checkThrowAsyncSite(ASTNode E, bool requiresTry,
const Classification &classification) {
// Suppress all diagnostics when there's an un-analyzable throw site.
// Suppress all diagnostics when there's an un-analyzable throw/async site.
if (classification.isInvalid()) {
Flags.set(ContextFlags::HasAnyThrowSite);
Flags.set(ContextFlags::HasAnyAsyncSite);
if (requiresTry) Flags.set(ContextFlags::HasTryThrowSite);
return;
}
Expand Down
3 changes: 0 additions & 3 deletions test/Concurrency/actor_inout_isolation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,6 @@ actor MyActor {
// expected-error@+1{{actor-isolated property 'int' cannot be passed 'inout' to 'async' function call}}
await modifyAsynchronously(&(int))

// This warning is emitted because this fails to typecheck before the
// async-ness is attached.
// expected-warning@+2{{no 'async' operations occur within 'await' expression}}
// expected-error@+1{{cannot pass immutable value of type 'Int' as inout argument}}
await modifyAsynchronously(&(maybePoint?.z)!)
// expected-error@+2{{actor-isolated property 'position' can only be used 'inout' from inside the actor}}
Expand Down
7 changes: 7 additions & 0 deletions test/Concurrency/async_tasks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ func test_unsafeContinuations() async {
let _: String = await withUnsafeContinuation { continuation in
continuation.resume(returning: "")
}

// rdar://76475495 - suppress warnings for invalid expressions
func test_invalid_async_no_warnings() async -> Int {
return await withUnsafeContinuation {
$0.resume(throwing: 1) // expected-error {{cannot convert value of type 'Int' to expected argument type 'Never'}}
}
}
}

@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
Expand Down