Skip to content

Commit 1601b20

Browse files
authored
Merge pull request #42033 from DougGregor/validate-global-actor-attr
Make sure we evaluate the a global actor annotation on an extension.
2 parents 053847a + 02081d7 commit 1601b20

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/Sema/TypeCheckAttr.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3283,8 +3283,18 @@ void AttributeChecker::visitCustomAttr(CustomAttr *attr) {
32833283
// retrieval request perform checking for us.
32843284
if (nominal->isGlobalActor()) {
32853285
(void)D->getGlobalActorAttr();
3286-
if (auto value = dyn_cast<ValueDecl>(D))
3286+
if (auto value = dyn_cast<ValueDecl>(D)) {
32873287
(void)getActorIsolation(value);
3288+
} else {
3289+
// Make sure we evaluate the global actor type.
3290+
auto dc = D->getInnermostDeclContext();
3291+
(void)evaluateOrDefault(
3292+
Ctx.evaluator,
3293+
CustomAttrTypeRequest{
3294+
attr, dc, CustomAttrTypeKind::GlobalActor},
3295+
Type());
3296+
}
3297+
32883298
return;
32893299
}
32903300

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
11
public actor Bar {}
2+
3+
public class SomewhatOnMainActor { }
4+
5+
@MainActor
6+
extension SomewhatOnMainActor { }

0 commit comments

Comments
 (0)