Skip to content

Commit 8035d39

Browse files
authored
Merge pull request #31165 from xymus/print-less-objc-imports
[PrintAsObjC] Don't print imports for empty extensions
2 parents d4112d9 + e078a86 commit 8035d39

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

lib/PrintAsObjC/ModuleContentsWriter.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,9 @@ class ModuleWriter {
400400
}
401401

402402
bool writeExtension(const ExtensionDecl *ED) {
403+
if (printer.isEmptyExtensionDecl(ED))
404+
return true;
405+
403406
bool allRequirementsSatisfied = true;
404407

405408
const ClassDecl *CD = ED->getSelfClassDecl();

test/PrintAsObjC/Inputs/custom-modules/MiserablePileOfSecrets.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@
33
@interface NSObject (Secrets)
44
- (void)secretMethod;
55
@end
6+
7+
@interface SecretClass : NSObject
8+
@end

test/PrintAsObjC/imports.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,7 @@ import MostlyPrivate2_Private
6767
@objc public class TestSubclass: NSObject {
6868
@_implementationOnly public override func secretMethod() {}
6969
}
70+
71+
extension SecretClass {
72+
private func somethingThatShouldNotBeIncluded() {}
73+
}

0 commit comments

Comments
 (0)