Skip to content

Commit 6bd59cd

Browse files
authored
[pigeon][reland]enable treat warnings as errors for swift code in unit test (#3901)
`as [Any?]` here is actually not a "cast", but a "type annotation". An equivalent fix can be: ``` let arg: [Any?] = [nil] let inputEncoded = binaryMessenger.codec.encode(arg) ``` Fixes ``` heterogeneous collection literal could only be inferred to '[Any?]'; add explicit type annotation if this is intentional ``` Which was introduced in #3889 and later got reverted. See flutter/flutter#126006 for more details about some interesting research on this warning. *List which issues are fixed by this PR. You must list at least one issue.* Fixes flutter/flutter#126006 *If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*
1 parent d9f7041 commit 6bd59cd

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

packages/pigeon/platform_tests/test_plugin/example/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,7 @@
542542
PRODUCT_NAME = "$(TARGET_NAME)";
543543
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
544544
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
545+
SWIFT_TREAT_WARNINGS_AS_ERRORS = YES;
545546
SWIFT_VERSION = 5.0;
546547
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner";
547548
};
@@ -557,6 +558,7 @@
557558
MARKETING_VERSION = 1.0;
558559
PRODUCT_BUNDLE_IDENTIFIER = dev.flutter.plugins.RunnerTests;
559560
PRODUCT_NAME = "$(TARGET_NAME)";
561+
SWIFT_TREAT_WARNINGS_AS_ERRORS = YES;
560562
SWIFT_VERSION = 5.0;
561563
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner";
562564
};
@@ -572,6 +574,7 @@
572574
MARKETING_VERSION = 1.0;
573575
PRODUCT_BUNDLE_IDENTIFIER = dev.flutter.plugins.RunnerTests;
574576
PRODUCT_NAME = "$(TARGET_NAME)";
577+
SWIFT_TREAT_WARNINGS_AS_ERRORS = YES;
575578
SWIFT_VERSION = 5.0;
576579
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner";
577580
};

packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/NullableReturnsTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class NullableReturnsTests: XCTestCase {
4040
NullableArgHostApiSetup.setUp(binaryMessenger: binaryMessenger, api: api)
4141
XCTAssertNotNil(binaryMessenger.handlers[channel])
4242

43-
let inputEncoded = binaryMessenger.codec.encode([nil])
43+
let inputEncoded = binaryMessenger.codec.encode([nil] as [Any?])
4444

4545
let expectation = XCTestExpectation(description: "callback")
4646
binaryMessenger.handlers[channel]?(inputEncoded) { _ in

0 commit comments

Comments
 (0)