Skip to content

Commit db141af

Browse files
author
David Ungar
authored
Merge pull request #30639 from davidungar/rdar-60840456-custom-attr-on-extension
Start lookup *outside* of D when D is, e.g. an ExtensionDecl
2 parents 3e32a4c + de4ff37 commit db141af

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/Sema/TypeCheckAttr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2643,7 +2643,7 @@ void AttributeChecker::visitFrozenAttr(FrozenAttr *attr) {
26432643
}
26442644

26452645
void AttributeChecker::visitCustomAttr(CustomAttr *attr) {
2646-
auto dc = D->getInnermostDeclContext();
2646+
auto dc = D->getDeclContext();
26472647

26482648
// Figure out which nominal declaration this custom attribute refers to.
26492649
auto nominal = evaluateOrDefault(
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: %target-swift-frontend -typecheck %s -verify
2+
3+
// Trips an assertion if an ASTScope lookup is attempted into the innermost
4+
// DeclContext of the extension.
5+
6+
struct Ty{}
7+
8+
@foo extension Ty {} // expected-error {{unknown attribute 'foo'}}
9+

0 commit comments

Comments
 (0)