Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions lib/AST/ASTPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4285,15 +4285,13 @@ void PrintAST::visitConstructorDecl(ConstructorDecl *decl) {
// Protocol extension initializers are modeled as convenience initializers,
// but they're not written that way in source. Check if we're actually
// printing onto a class.
bool isClassContext;
if (CurrentType) {
isClassContext = CurrentType->getClassOrBoundGenericClass() != nullptr;
} else {
const DeclContext *dc = decl->getDeclContext();
isClassContext = dc->getSelfClassDecl() != nullptr;
}
if (isClassContext) {
Printer.printKeyword("convenience", Options, " ");
ClassDecl *classDecl = CurrentType
? CurrentType->getClassOrBoundGenericClass()
: decl->getDeclContext()->getSelfClassDecl();
if (classDecl) {
// Convenience intializers are also unmarked on actors.
if (!classDecl->isActor())
Printer.printKeyword("convenience", Options, " ");
} else {
assert(decl->getDeclContext()->getExtendedProtocolDecl() &&
"unexpected convenience initializer");
Expand Down
3 changes: 1 addition & 2 deletions test/ModuleInterface/actor_init.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
// CHECK-LABEL: public actor TestActor {
@available(SwiftStdlib 5.5, *)
public actor TestActor {
// FIXME: The convenience keyword should be omitted (rdar://130926278)
// CHECK: public convenience init(convenience: Swift.Int)
// CHECK: public init(convenience: Swift.Int)
public init(convenience: Int) {
self.init()
}
Expand Down