File tree Expand file tree Collapse file tree 2 files changed +11
-8
lines changed Expand file tree Collapse file tree 2 files changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -4280,13 +4280,15 @@ void PrintAST::visitConstructorDecl(ConstructorDecl *decl) {
4280
4280
// Protocol extension initializers are modeled as convenience initializers,
4281
4281
// but they're not written that way in source. Check if we're actually
4282
4282
// 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, " " );
4290
4292
} else {
4291
4293
assert (decl->getDeclContext ()->getExtendedProtocolDecl () &&
4292
4294
" unexpected convenience initializer" );
Original file line number Diff line number Diff line change 12
12
// CHECK-LABEL: public actor TestActor {
13
13
@available ( SwiftStdlib 5 . 5 , * )
14
14
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)
16
17
public init ( convenience: Int ) {
17
18
self . init ( )
18
19
}
You can’t perform that action at this time.
0 commit comments