Skip to content

Commit c203b39

Browse files
committed
[Macros] Use the original attribute list when gathering possible macro-generated
names in the source lookup cache. Invoking macro expansion while populating the source lookup cache is deliberately avoided because it's prone to circularity. This applies to member attribute expansion, which is requested via `getSemanticAttrs()`. Populating the auxiliary decl cache should use the original attribute list, because declarations found via global lookup, such as macro and operator decls, cannot have inferred attached macros.
1 parent 8862b1b commit c203b39

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/AST/Module.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ void SourceLookupCache::populateAuxiliaryDeclCache() {
350350
// macro does not produce the requested name, so the only impact is possibly
351351
// expanding earlier than needed / unnecessarily looking in the top-level
352352
// auxiliary decl cache.
353-
for (auto attrConst : decl->getSemanticAttrs().getAttributes<CustomAttr>()) {
353+
for (auto attrConst : decl->getAttrs().getAttributes<CustomAttr>()) {
354354
auto *attr = const_cast<CustomAttr *>(attrConst);
355355
UnresolvedMacroReference macroRef(attr);
356356
auto macroName = macroRef.getMacroName().getBaseIdentifier();

test/Concurrency/global_actor_function_types.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,3 +386,13 @@ func test_global_actor_mismatch() {
386386
let _: @MainActor () -> T = fn // expected-error{{cannot convert value actor-isolated to 'GA' to specified type actor-isolated to 'MainActor'}}
387387
}
388388
}
389+
390+
struct GlobalType {}
391+
392+
@_Concurrency.MainActor
393+
extension global_actor_function_types.GlobalType {
394+
@_Concurrency.MainActor static func ==(
395+
lhs: global_actor_function_types.GlobalType,
396+
rhs: global_actor_function_types.GlobalType
397+
) -> Bool { true }
398+
}

0 commit comments

Comments
 (0)