Skip to content

Commit be843ed

Browse files
authored
Merge pull request swiftlang#35717 from xymus/fix-extensions-with-if-config
[ModuleInterface] Don't print extensions only for a nested #if
2 parents b16f340 + dd85b1d commit be843ed

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

lib/AST/ASTPrinter.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1802,6 +1802,11 @@ bool ShouldPrintChecker::shouldPrint(const Decl *D,
18021802
}
18031803
return false;
18041804
}
1805+
1806+
if (isa<IfConfigDecl>(D)) {
1807+
return Options.PrintIfConfig;
1808+
}
1809+
18051810
return true;
18061811
}
18071812

test/ModuleInterface/empty-extension.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
// RUN: %target-swift-frontend-typecheck -emit-module-interface-path %t/out.swiftinterface %s -I %t -swift-version 5 -enable-library-evolution
1010
// RUN: %FileCheck %s < %t/out.swiftinterface
1111

12+
// REQUIRES: OS=macosx
13+
1214
#if IOI_LIB
1315

1416
public struct IOIImportedType {
@@ -38,12 +40,26 @@ public protocol PublicProto {
3840
func foo()
3941
}
4042
extension IOIImportedType : PublicProto {}
43+
44+
extension IOIImportedType {
45+
#if os(iOS)
46+
public func funcForAnotherOS() {}
47+
#endif
48+
}
4149
// CHECK-NOT: IOIImportedType
50+
// CHECK-NOT: funcForAnotherOS
4251

4352
extension NormalImportedType : PublicProto {}
4453
// CHECK: extension NormalImportedType
4554

4655
extension ExportedType : PublicProto {}
4756
// CHECK: extension ExportedType
4857

58+
extension NormalImportedType {
59+
#if os(macOS)
60+
public func funcForThisOS() {};
61+
#endif
62+
}
63+
// CHECK: funcForThisOS
64+
4965
#endif

0 commit comments

Comments
 (0)