Skip to content

Commit 403156b

Browse files
committed
Revert "AST: Don't print convenience on actor initializers."
This reverts commit 3453b13.
1 parent 28e1fdf commit 403156b

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

lib/AST/ASTPrinter.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4280,13 +4280,15 @@ void PrintAST::visitConstructorDecl(ConstructorDecl *decl) {
42804280
// Protocol extension initializers are modeled as convenience initializers,
42814281
// but they're not written that way in source. Check if we're actually
42824282
// printing onto a class.
4283-
ClassDecl *classDecl = CurrentType
4284-
? CurrentType->getClassOrBoundGenericClass()
4285-
: decl->getDeclContext()->getSelfClassDecl();
4286-
if (classDecl) {
4287-
// Convenience intializers are also unmarked on actors.
4288-
if (!classDecl->isActor())
4289-
Printer.printKeyword("convenience", Options, " ");
4283+
bool isClassContext;
4284+
if (CurrentType) {
4285+
isClassContext = CurrentType->getClassOrBoundGenericClass() != nullptr;
4286+
} else {
4287+
const DeclContext *dc = decl->getDeclContext();
4288+
isClassContext = dc->getSelfClassDecl() != nullptr;
4289+
}
4290+
if (isClassContext) {
4291+
Printer.printKeyword("convenience", Options, " ");
42904292
} else {
42914293
assert(decl->getDeclContext()->getExtendedProtocolDecl() &&
42924294
"unexpected convenience initializer");

test/ModuleInterface/actor_init.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
// CHECK-LABEL: public actor TestActor {
1313
@available(SwiftStdlib 5.5, *)
1414
public actor TestActor {
15-
// CHECK: public init(convenience: Swift.Int)
15+
// FIXME: The convenience keyword should be omitted (rdar://130926278)
16+
// CHECK: public convenience init(convenience: Swift.Int)
1617
public init(convenience: Int) {
1718
self.init()
1819
}

0 commit comments

Comments
 (0)