Skip to content

Commit 03dae14

Browse files
authored
Merge pull request #73854 from hborla/6.0-task-local-macro-hack
[6.0][Macros] Ignore the `@TaskLocal` macro attached to vars with projected value vars.
2 parents e9d2261 + f18149b commit 03dae14

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

lib/Sema/TypeCheckMacros.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,6 +1369,22 @@ static SourceFile *evaluateAttachedMacro(MacroDecl *macro, Decl *attachedTo,
13691369
dc = attachedTo->getInnermostDeclContext();
13701370
}
13711371

1372+
// FIXME: compatibility hack for the transition from property wrapper
1373+
// to macro for TaskLocal.
1374+
//
1375+
// VarDecls with `@_projectedValueProperty` have already had the property
1376+
// wrapper transform applied. This only impacts swiftinterfaces, and if
1377+
// a swiftinterface was produced against a Concurrency library that does
1378+
// not declare TaskLocal as a macro, we need to ignore the macro to avoid
1379+
// producing duplicate declarations. This is only needed temporarily until
1380+
// all swiftinterfaces have been built against the Concurrency library
1381+
// containing the new macro declaration.
1382+
if (auto *var = dyn_cast<VarDecl>(attachedTo)) {
1383+
if (var->getAttrs().getAttribute<ProjectedValuePropertyAttr>()) {
1384+
return nullptr;
1385+
}
1386+
}
1387+
13721388
ASTContext &ctx = dc->getASTContext();
13731389

13741390
auto moduleDecl = dc->getParentModule();
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// swift-interface-format-version: 1.0
2+
// swift-compiler-version: Swift version 6.0
3+
// swift-module-flags: -swift-version 5 -disable-availability-checking
4+
5+
// RUN: %empty-directory(%t)
6+
// RUN: %target-swift-typecheck-module-from-interface(%s)
7+
8+
import Swift
9+
import _Concurrency
10+
11+
@_hasMissingDesignatedInitializers final public class C {
12+
@_Concurrency.TaskLocal @_projectedValueProperty($x) public static var x: Swift.Int? {
13+
get
14+
}
15+
public static var $x: _Concurrency.TaskLocal<Swift.Int?> {
16+
get
17+
@available(*, unavailable, message: "use '$myTaskLocal.withValue(_:do:)' instead")
18+
set
19+
}
20+
}

0 commit comments

Comments
 (0)