Skip to content

Commit

Permalink
fix logic
Browse files Browse the repository at this point in the history
  • Loading branch information
bparrishMines committed Dec 22, 2024
1 parent 344a3ab commit 3f0aabb
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/pigeon/lib/swift_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2501,9 +2501,9 @@ private func nilOrValue<T>(_ value: Any?) -> T? {
for (final String import in apisOfImports.keys) {
final List<String> unsupportedPlatforms = <String>[
if (!apisOfImports[import]!
.every((AstProxyApi api) => api.swiftOptions?.supportsIos ?? true))
.any((AstProxyApi api) => api.swiftOptions?.supportsIos ?? true))
'!os(iOS)',
if (!apisOfImports[import]!.every(
if (!apisOfImports[import]!.any(
(AstProxyApi api) => api.swiftOptions?.supportsMacos ?? true))
'!os(macOS)',
];
Expand Down
39 changes: 39 additions & 0 deletions packages/pigeon/test/swift/proxy_api_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,45 @@ void main() {
contains('#if !os(iOS) || !os(macOS)\nimport MyImport\n#endif'),
);
});

test('do not add check if at least one class is supported', () {
final Root root = Root(
apis: <Api>[
AstProxyApi(
name: 'Api',
swiftOptions: const SwiftProxyApiOptions(
import: 'MyImport',
supportsIos: false,
),
constructors: <Constructor>[],
fields: <ApiField>[],
methods: <Method>[],
),
AstProxyApi(
name: 'Api2',
swiftOptions: const SwiftProxyApiOptions(
import: 'MyImport',
),
constructors: <Constructor>[],
fields: <ApiField>[],
methods: <Method>[],
),
],
classes: <Class>[],
enums: <Enum>[],
);
final StringBuffer sink = StringBuffer();
const SwiftGenerator generator = SwiftGenerator();
generator.generate(
const SwiftOptions(),
root,
sink,
dartPackageName: DEFAULT_PACKAGE_NAME,
);
final String code = sink.toString();

expect(code, isNot(contains('#if !os(iOS)\nimport MyImport')));
});
});

group('inheritance', () {
Expand Down

0 comments on commit 3f0aabb

Please sign in to comment.