File tree Expand file tree Collapse file tree 3 files changed +48
-0
lines changed
test/Concurrency/attr_execution Expand file tree Collapse file tree 3 files changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -153,6 +153,10 @@ void NonisolatedNonsendingByDefaultMigrationTarget::diagnose() const {
153153
154154 const auto featureName = feature.getName ();
155155 if (decl) {
156+ // Only diagnose declarations from the current module.
157+ if (decl->getModuleContext () != ctx.MainModule )
158+ return ;
159+
156160 // Diagnose the function, but slap the attribute on the storage declaration
157161 // instead if the function is an accessor.
158162 auto *functionDecl = dyn_cast<AbstractFunctionDecl>(decl);
File renamed without changes.
Original file line number Diff line number Diff line change 1+ // RUN: %empty-directory(%t/src)
2+ // RUN: split-file %s %t/src
3+
4+ /// Build the library
5+ // RUN: %target-swift-frontend -emit-module %t/src/Lib.swift \
6+ // RUN: -target %target-swift-5.1-abi-triple \
7+ // RUN: -module-name Lib -swift-version 5 -enable-library-evolution \
8+ // RUN: -emit-module-path %t/Lib.swiftmodule \
9+ // RUN: -emit-module-interface-path %t/Lib.swiftinterface
10+
11+ // RUN: rm %t/Lib.swiftmodule
12+
13+ // Build the client using interface
14+ // RUN: %target-swift-frontend -typecheck -verify -target %target-swift-5.1-abi-triple -swift-version 5 -I %t %t/src/Test.swift -enable-upcoming-feature NonisolatedNonsendingByDefault:migrate
15+
16+ // REQUIRES: asserts
17+ // REQUIRES: swift_feature_NonisolatedNonsendingByDefault
18+
19+ //--- Lib.swift
20+ public struct Counter : AsyncSequence {
21+ public typealias Element = Int
22+
23+ public init ( howHigh: Int ) {
24+ }
25+
26+ public struct AsyncIterator : AsyncIteratorProtocol {
27+ public mutating func next( ) async -> Int ? {
28+ nil
29+ }
30+ }
31+
32+ public func makeAsyncIterator( ) -> AsyncIterator {
33+ AsyncIterator ( )
34+ }
35+ }
36+
37+ //--- Test.swift
38+ import Lib
39+
40+ func count( n: Int ) async {
41+ // expected-warning@-1 {{feature 'NonisolatedNonsendingByDefault' will cause nonisolated async global function 'count' to run on the caller's actor; use '@concurrent' to preserve behavior}}
42+ for await _ in Counter ( howHigh: n) {
43+ }
44+ }
You can’t perform that action at this time.
0 commit comments