Skip to content

Commit ab42dd5

Browse files
authored
Merge pull request swiftlang#36333 from slavapestov/module-interfaces-with-stub-init
AST: Skip stub initializers when printing module interfaces
2 parents e82fd4a + 6615e16 commit ab42dd5

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

lib/AST/ASTPrinter.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,12 @@ PrintOptions PrintOptions::printSwiftInterfaceFile(ModuleDecl *ModuleToPrint,
238238
}
239239
}
240240

241+
// Skip stub constructors.
242+
if (auto *ctor = dyn_cast<ConstructorDecl>(D)) {
243+
if (ctor->hasStubImplementation())
244+
return false;
245+
}
246+
241247
return ShouldPrintChecker::shouldPrint(D, options);
242248
}
243249
};

test/ModuleInterface/stub-init.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// RUN: %target-swift-frontend -typecheck -swift-version 5 -emit-module-interface-path - -module-name test %s | %FileCheck %s
2+
3+
public class Base {
4+
public init(x: Int) {}
5+
}
6+
7+
public class Derived: Base {
8+
public init(z: Int) {
9+
super.init(x: z)
10+
}
11+
}
12+
13+
// CHECK-LABEL: public class Base {
14+
// CHECK-NEXT: public init(x: Swift.Int)
15+
// CHECK-NEXT: {{(@objc )?}}deinit
16+
// CHECK-NEXT: }
17+
18+
// CHECK-LABEL: public class Derived : test.Base {
19+
// CHECK-NEXT: public init(z: Swift.Int)
20+
// CHECK-NEXT: {{(@objc )?}}deinit
21+
// CHECK-NEXT: }
22+

0 commit comments

Comments
 (0)