mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[ParseDecl] Disallow init accessor decl outside of primary declaration
This commit is contained in:
@@ -8432,8 +8432,12 @@ void Parser::ParsedAccessors::classify(Parser &P, AbstractStorageDecl *storage,
|
||||
}
|
||||
|
||||
if (Init) {
|
||||
if (!storage->getDeclContext()->getSelfNominalTypeDecl() ||
|
||||
isa<SubscriptDecl>(storage)) {
|
||||
if (storage->getDeclContext()->getContextKind() ==
|
||||
DeclContextKind::ExtensionDecl) {
|
||||
P.diagnose(Init->getLoc(),
|
||||
diag::init_accessor_is_not_in_the_primary_declaration);
|
||||
} else if (!storage->getDeclContext()->getSelfNominalTypeDecl() ||
|
||||
isa<SubscriptDecl>(storage)) {
|
||||
P.diagnose(Init->getLoc(), diag::init_accessor_is_not_on_property);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user