Skip to content

Commit 3668e00

Browse files
authored
Merge pull request #59894 from DougGregor/spurious-preconcurrency-remarks-5.7
Don't emit `@preconcurrency import` remarks when we're skipping function bodies
2 parents add2681 + 61cf0af commit 3668e00

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

lib/Sema/TypeChecker.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,10 @@ static void diagnoseUnnecessaryPreconcurrencyImports(SourceFile &sf) {
279279
}
280280

281281
ASTContext &ctx = sf.getASTContext();
282+
283+
if (ctx.TypeCheckerOpts.SkipFunctionBodies != FunctionBodySkipping::None)
284+
return;
285+
282286
for (const auto &import : sf.getImports()) {
283287
if (import.options.contains(ImportFlags::Preconcurrency) &&
284288
import.importLoc.isValid() &&
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend -emit-module -emit-module-path %t/StrictModule.swiftmodule -module-name StrictModule -swift-version 6 %S/Inputs/StrictModule.swift
3+
// RUN: %target-swift-frontend -emit-module -emit-module-path %t/NonStrictModule.swiftmodule -module-name NonStrictModule %S/Inputs/NonStrictModule.swift
4+
// RUN: %target-swift-frontend -emit-module -emit-module-path %t/OtherActors.swiftmodule -module-name OtherActors %S/Inputs/OtherActors.swift -disable-availability-checking
5+
6+
// RUN: %target-swift-frontend -emit-module -I %t -verify -primary-file %s -emit-module-path %t/predates_concurrency_import_swiftmodule.swiftmodule -experimental-skip-all-function-bodies
7+
8+
// REQUIRES: concurrency
9+
// REQUIRES: asserts
10+
11+
@preconcurrency import NonStrictModule
12+
@preconcurrency import StrictModule
13+
@preconcurrency import OtherActors
14+
15+
// expected-no-warning
16+
17+
func acceptSendable<T: Sendable>(_: T) { }
18+
19+
@available(SwiftStdlib 5.1, *)
20+
func test(
21+
ss: StrictStruct, ns: NonStrictClass, oma: OtherModuleActor,
22+
ssc: SomeSendableClass
23+
) async {
24+
acceptSendable(ss)
25+
acceptSendable(ns)
26+
acceptSendable(oma)
27+
acceptSendable(ssc)
28+
}

0 commit comments

Comments
 (0)