Skip to content

Commit 39a9d23

Browse files
authored
Merge pull request swiftlang#75180 from tshortli/module-interface-omit-convenience-on-actor-init
AST: Don't print `convenience` on actor initializers
2 parents 5916325 + 3453b13 commit 39a9d23

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

lib/AST/ASTPrinter.cpp

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

test/ModuleInterface/actor_init.swift

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

0 commit comments

Comments
 (0)