From 1f893d787b5b6bff76549c45e712f246eaef4e0b Mon Sep 17 00:00:00 2001 From: tarrinneal Date: Tue, 21 Feb 2023 15:44:37 -0800 Subject: [PATCH 1/6] fails with bool? only --- packages/pigeon/lib/swift_generator.dart | 2 +- .../ios/RunnerTests/AllDatatypesTests.swift | 2 +- .../ios/Classes/CoreTests.gen.swift | 28 +++++++++---------- .../test_plugin/ios/Classes/TestPlugin.swift | 2 +- .../macos/Classes/CoreTests.gen.swift | 28 +++++++++---------- 5 files changed, 31 insertions(+), 31 deletions(-) diff --git a/packages/pigeon/lib/swift_generator.dart b/packages/pigeon/lib/swift_generator.dart index 0d7a9e8e68a5..45ce382d9b18 100644 --- a/packages/pigeon/lib/swift_generator.dart +++ b/packages/pigeon/lib/swift_generator.dart @@ -199,7 +199,7 @@ import FlutterMacOS '${field.name} = $fieldType(rawValue: ${field.name}RawValue)'); }); } else { - indent.writeln('let ${field.name} = $listValue as? $fieldType '); + indent.writeln('let ${field.name} = $listValue as! $fieldType? '); } } else { if (!hostDatatype.isBuiltin && diff --git a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/AllDatatypesTests.swift b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/AllDatatypesTests.swift index 08b9b3b15ebb..4992841786e1 100644 --- a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/AllDatatypesTests.swift +++ b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/AllDatatypesTests.swift @@ -37,7 +37,7 @@ class AllDatatypesTests: XCTestCase { func testAllEquals() throws { let everything = AllNullableTypes( - aNullableBool: false, + aNullableBool: true, aNullableInt: 1, aNullableDouble: 2.0, aNullableByteArray: FlutterStandardTypedData(bytes: "1234".data(using: .utf8)!), diff --git a/packages/pigeon/platform_tests/test_plugin/ios/Classes/CoreTests.gen.swift b/packages/pigeon/platform_tests/test_plugin/ios/Classes/CoreTests.gen.swift index 3f3d3bbd6b19..af2260bc175c 100644 --- a/packages/pigeon/platform_tests/test_plugin/ios/Classes/CoreTests.gen.swift +++ b/packages/pigeon/platform_tests/test_plugin/ios/Classes/CoreTests.gen.swift @@ -117,23 +117,23 @@ struct AllNullableTypes { var aNullableString: String? = nil static func fromList(_ list: [Any?]) -> AllNullableTypes? { - let aNullableBool = list[0] as? Bool - let aNullableInt = list[1] as? Int32 - let aNullableDouble = list[2] as? Double - let aNullableByteArray = list[3] as? FlutterStandardTypedData - let aNullable4ByteArray = list[4] as? FlutterStandardTypedData - let aNullable8ByteArray = list[5] as? FlutterStandardTypedData - let aNullableFloatArray = list[6] as? FlutterStandardTypedData - let aNullableList = list[7] as? [Any?] - let aNullableMap = list[8] as? [AnyHashable: Any?] - let nullableNestedList = list[9] as? [[Bool?]?] - let nullableMapWithAnnotations = list[10] as? [String?: String?] - let nullableMapWithObject = list[11] as? [String?: Any?] + let aNullableBool = list[0] as! Bool? + let aNullableInt = list[1] as! Int32? + let aNullableDouble = list[2] as! Double? + let aNullableByteArray = list[3] as! FlutterStandardTypedData? + let aNullable4ByteArray = list[4] as! FlutterStandardTypedData? + let aNullable8ByteArray = list[5] as! FlutterStandardTypedData? + let aNullableFloatArray = list[6] as! FlutterStandardTypedData? + let aNullableList = list[7] as! [Any?]? + let aNullableMap = list[8] as! [AnyHashable: Any?]? + let nullableNestedList = list[9] as! [[Bool?]?]? + let nullableMapWithAnnotations = list[10] as! [String?: String?]? + let nullableMapWithObject = list[11] as! [String?: Any?]? var aNullableEnum: AnEnum? = nil if let aNullableEnumRawValue = list[12] as? Int { aNullableEnum = AnEnum(rawValue: aNullableEnumRawValue) } - let aNullableString = list[13] as? String + let aNullableString = list[13] as! String? return AllNullableTypes( aNullableBool: aNullableBool, @@ -197,7 +197,7 @@ struct TestMessage { var testList: [Any?]? = nil static func fromList(_ list: [Any?]) -> TestMessage? { - let testList = list[0] as? [Any?] + let testList = list[0] as! [Any?]? return TestMessage( testList: testList diff --git a/packages/pigeon/platform_tests/test_plugin/ios/Classes/TestPlugin.swift b/packages/pigeon/platform_tests/test_plugin/ios/Classes/TestPlugin.swift index 91962e19cbb5..6c718e9e5038 100644 --- a/packages/pigeon/platform_tests/test_plugin/ios/Classes/TestPlugin.swift +++ b/packages/pigeon/platform_tests/test_plugin/ios/Classes/TestPlugin.swift @@ -326,4 +326,4 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { completion(.success($0)) } } -} \ No newline at end of file +} diff --git a/packages/pigeon/platform_tests/test_plugin/macos/Classes/CoreTests.gen.swift b/packages/pigeon/platform_tests/test_plugin/macos/Classes/CoreTests.gen.swift index 3f3d3bbd6b19..af2260bc175c 100644 --- a/packages/pigeon/platform_tests/test_plugin/macos/Classes/CoreTests.gen.swift +++ b/packages/pigeon/platform_tests/test_plugin/macos/Classes/CoreTests.gen.swift @@ -117,23 +117,23 @@ struct AllNullableTypes { var aNullableString: String? = nil static func fromList(_ list: [Any?]) -> AllNullableTypes? { - let aNullableBool = list[0] as? Bool - let aNullableInt = list[1] as? Int32 - let aNullableDouble = list[2] as? Double - let aNullableByteArray = list[3] as? FlutterStandardTypedData - let aNullable4ByteArray = list[4] as? FlutterStandardTypedData - let aNullable8ByteArray = list[5] as? FlutterStandardTypedData - let aNullableFloatArray = list[6] as? FlutterStandardTypedData - let aNullableList = list[7] as? [Any?] - let aNullableMap = list[8] as? [AnyHashable: Any?] - let nullableNestedList = list[9] as? [[Bool?]?] - let nullableMapWithAnnotations = list[10] as? [String?: String?] - let nullableMapWithObject = list[11] as? [String?: Any?] + let aNullableBool = list[0] as! Bool? + let aNullableInt = list[1] as! Int32? + let aNullableDouble = list[2] as! Double? + let aNullableByteArray = list[3] as! FlutterStandardTypedData? + let aNullable4ByteArray = list[4] as! FlutterStandardTypedData? + let aNullable8ByteArray = list[5] as! FlutterStandardTypedData? + let aNullableFloatArray = list[6] as! FlutterStandardTypedData? + let aNullableList = list[7] as! [Any?]? + let aNullableMap = list[8] as! [AnyHashable: Any?]? + let nullableNestedList = list[9] as! [[Bool?]?]? + let nullableMapWithAnnotations = list[10] as! [String?: String?]? + let nullableMapWithObject = list[11] as! [String?: Any?]? var aNullableEnum: AnEnum? = nil if let aNullableEnumRawValue = list[12] as? Int { aNullableEnum = AnEnum(rawValue: aNullableEnumRawValue) } - let aNullableString = list[13] as? String + let aNullableString = list[13] as! String? return AllNullableTypes( aNullableBool: aNullableBool, @@ -197,7 +197,7 @@ struct TestMessage { var testList: [Any?]? = nil static func fromList(_ list: [Any?]) -> TestMessage? { - let testList = list[0] as? [Any?] + let testList = list[0] as! [Any?]? return TestMessage( testList: testList From 4331ba1c263df971739580e028fd5700455056be Mon Sep 17 00:00:00 2001 From: tarrinneal Date: Wed, 22 Feb 2023 09:44:44 -0800 Subject: [PATCH 2/6] change most instances of [Any?] to [Any] --- packages/pigeon/lib/swift_generator.dart | 10 ++++----- .../ios/RunnerTests/PrimitiveTests.swift | 2 +- .../ios/Classes/CoreTests.gen.swift | 22 +++++++++---------- .../macos/Classes/CoreTests.gen.swift | 22 +++++++++---------- .../pigeon/test/swift_generator_test.dart | 8 +++---- 5 files changed, 32 insertions(+), 32 deletions(-) diff --git a/packages/pigeon/lib/swift_generator.dart b/packages/pigeon/lib/swift_generator.dart index 45ce382d9b18..6f8bbc179717 100644 --- a/packages/pigeon/lib/swift_generator.dart +++ b/packages/pigeon/lib/swift_generator.dart @@ -171,7 +171,7 @@ import FlutterMacOS Set customEnumNames, ) { final String className = klass.name; - indent.write('static func fromList(_ list: [Any?]) -> $className? '); + indent.write('static func fromList(_ list: [Any]) -> $className? '); indent.addScoped('{', '}', () { enumerate(getFieldsInSerializationOrder(klass), @@ -185,10 +185,10 @@ import FlutterMacOS if (!hostDatatype.isBuiltin && customClassNames.contains(field.type.baseName)) { indent.writeln('var ${field.name}: $fieldType? = nil'); - indent.write('if let ${field.name}List = $listValue as? [Any?] '); + indent.write('if let ${field.name}List = $listValue as? [Any] '); indent.addScoped('{', '}', () { indent.writeln( - '${field.name} = $fieldType.fromList(${field.name}List)'); + '${field.name} = $fieldType.fromList(${field.name}List as [Any])'); }); } else if (!hostDatatype.isBuiltin && customEnumNames.contains(field.type.baseName)) { @@ -205,7 +205,7 @@ import FlutterMacOS if (!hostDatatype.isBuiltin && customClassNames.contains(field.type.baseName)) { indent.writeln( - 'let ${field.name} = $fieldType.fromList($listValue as! [Any?])!'); + 'let ${field.name} = $fieldType.fromList($listValue as! [Any])!'); } else if (!hostDatatype.isBuiltin && customEnumNames.contains(field.type.baseName)) { indent.writeln( @@ -691,7 +691,7 @@ String _flattenTypeArguments(List args) { String _swiftTypeForBuiltinGenericDartType(TypeDeclaration type) { if (type.typeArguments.isEmpty) { if (type.baseName == 'List') { - return '[Any?]'; + return '[Any]'; } else if (type.baseName == 'Map') { return '[AnyHashable: Any?]'; } else { diff --git a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/PrimitiveTests.swift b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/PrimitiveTests.swift index 2734f3c359e6..1f3f0851fb70 100644 --- a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/PrimitiveTests.swift +++ b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/PrimitiveTests.swift @@ -12,7 +12,7 @@ class MockPrimitiveHostApi: PrimitiveHostApi { func aString(value: String) -> String { value } func aDouble(value: Double) -> Double { value } func aMap(value: [AnyHashable: Any?]) -> [AnyHashable: Any?] { value } - func aList(value: [Any?]) -> [Any?] { value } + func aList(value: [Any]) -> [Any] { value } func anInt32List(value: FlutterStandardTypedData) -> FlutterStandardTypedData { value } func aBoolList(value: [Bool?]) -> [Bool?] { value } func aStringIntMap(value: [String?: Int32?]) -> [String?: Int32?] { value } diff --git a/packages/pigeon/platform_tests/test_plugin/ios/Classes/CoreTests.gen.swift b/packages/pigeon/platform_tests/test_plugin/ios/Classes/CoreTests.gen.swift index af2260bc175c..b2a495ef9da8 100644 --- a/packages/pigeon/platform_tests/test_plugin/ios/Classes/CoreTests.gen.swift +++ b/packages/pigeon/platform_tests/test_plugin/ios/Classes/CoreTests.gen.swift @@ -50,12 +50,12 @@ struct AllTypes { var a4ByteArray: FlutterStandardTypedData var a8ByteArray: FlutterStandardTypedData var aFloatArray: FlutterStandardTypedData - var aList: [Any?] + var aList: [Any] var aMap: [AnyHashable: Any?] var anEnum: AnEnum var aString: String - static func fromList(_ list: [Any?]) -> AllTypes? { + static func fromList(_ list: [Any]) -> AllTypes? { let aBool = list[0] as! Bool let anInt = list[1] as! Int32 let aDouble = list[2] as! Double @@ -63,7 +63,7 @@ struct AllTypes { let a4ByteArray = list[4] as! FlutterStandardTypedData let a8ByteArray = list[5] as! FlutterStandardTypedData let aFloatArray = list[6] as! FlutterStandardTypedData - let aList = list[7] as! [Any?] + let aList = list[7] as! [Any] let aMap = list[8] as! [AnyHashable: Any?] let anEnum = AnEnum(rawValue: list[9] as! Int)! let aString = list[10] as! String @@ -108,7 +108,7 @@ struct AllNullableTypes { var aNullable4ByteArray: FlutterStandardTypedData? = nil var aNullable8ByteArray: FlutterStandardTypedData? = nil var aNullableFloatArray: FlutterStandardTypedData? = nil - var aNullableList: [Any?]? = nil + var aNullableList: [Any]? = nil var aNullableMap: [AnyHashable: Any?]? = nil var nullableNestedList: [[Bool?]?]? = nil var nullableMapWithAnnotations: [String?: String?]? = nil @@ -116,7 +116,7 @@ struct AllNullableTypes { var aNullableEnum: AnEnum? = nil var aNullableString: String? = nil - static func fromList(_ list: [Any?]) -> AllNullableTypes? { + static func fromList(_ list: [Any]) -> AllNullableTypes? { let aNullableBool = list[0] as! Bool? let aNullableInt = list[1] as! Int32? let aNullableDouble = list[2] as! Double? @@ -124,7 +124,7 @@ struct AllNullableTypes { let aNullable4ByteArray = list[4] as! FlutterStandardTypedData? let aNullable8ByteArray = list[5] as! FlutterStandardTypedData? let aNullableFloatArray = list[6] as! FlutterStandardTypedData? - let aNullableList = list[7] as! [Any?]? + let aNullableList = list[7] as! [Any]? let aNullableMap = list[8] as! [AnyHashable: Any?]? let nullableNestedList = list[9] as! [[Bool?]?]? let nullableMapWithAnnotations = list[10] as! [String?: String?]? @@ -176,8 +176,8 @@ struct AllNullableTypes { struct AllNullableTypesWrapper { var values: AllNullableTypes - static func fromList(_ list: [Any?]) -> AllNullableTypesWrapper? { - let values = AllNullableTypes.fromList(list[0] as! [Any?])! + static func fromList(_ list: [Any]) -> AllNullableTypesWrapper? { + let values = AllNullableTypes.fromList(list[0] as! [Any])! return AllNullableTypesWrapper( values: values @@ -194,10 +194,10 @@ struct AllNullableTypesWrapper { /// /// Generated class from Pigeon that represents data sent in messages. struct TestMessage { - var testList: [Any?]? = nil + var testList: [Any]? = nil - static func fromList(_ list: [Any?]) -> TestMessage? { - let testList = list[0] as! [Any?]? + static func fromList(_ list: [Any]) -> TestMessage? { + let testList = list[0] as! [Any]? return TestMessage( testList: testList diff --git a/packages/pigeon/platform_tests/test_plugin/macos/Classes/CoreTests.gen.swift b/packages/pigeon/platform_tests/test_plugin/macos/Classes/CoreTests.gen.swift index af2260bc175c..b2a495ef9da8 100644 --- a/packages/pigeon/platform_tests/test_plugin/macos/Classes/CoreTests.gen.swift +++ b/packages/pigeon/platform_tests/test_plugin/macos/Classes/CoreTests.gen.swift @@ -50,12 +50,12 @@ struct AllTypes { var a4ByteArray: FlutterStandardTypedData var a8ByteArray: FlutterStandardTypedData var aFloatArray: FlutterStandardTypedData - var aList: [Any?] + var aList: [Any] var aMap: [AnyHashable: Any?] var anEnum: AnEnum var aString: String - static func fromList(_ list: [Any?]) -> AllTypes? { + static func fromList(_ list: [Any]) -> AllTypes? { let aBool = list[0] as! Bool let anInt = list[1] as! Int32 let aDouble = list[2] as! Double @@ -63,7 +63,7 @@ struct AllTypes { let a4ByteArray = list[4] as! FlutterStandardTypedData let a8ByteArray = list[5] as! FlutterStandardTypedData let aFloatArray = list[6] as! FlutterStandardTypedData - let aList = list[7] as! [Any?] + let aList = list[7] as! [Any] let aMap = list[8] as! [AnyHashable: Any?] let anEnum = AnEnum(rawValue: list[9] as! Int)! let aString = list[10] as! String @@ -108,7 +108,7 @@ struct AllNullableTypes { var aNullable4ByteArray: FlutterStandardTypedData? = nil var aNullable8ByteArray: FlutterStandardTypedData? = nil var aNullableFloatArray: FlutterStandardTypedData? = nil - var aNullableList: [Any?]? = nil + var aNullableList: [Any]? = nil var aNullableMap: [AnyHashable: Any?]? = nil var nullableNestedList: [[Bool?]?]? = nil var nullableMapWithAnnotations: [String?: String?]? = nil @@ -116,7 +116,7 @@ struct AllNullableTypes { var aNullableEnum: AnEnum? = nil var aNullableString: String? = nil - static func fromList(_ list: [Any?]) -> AllNullableTypes? { + static func fromList(_ list: [Any]) -> AllNullableTypes? { let aNullableBool = list[0] as! Bool? let aNullableInt = list[1] as! Int32? let aNullableDouble = list[2] as! Double? @@ -124,7 +124,7 @@ struct AllNullableTypes { let aNullable4ByteArray = list[4] as! FlutterStandardTypedData? let aNullable8ByteArray = list[5] as! FlutterStandardTypedData? let aNullableFloatArray = list[6] as! FlutterStandardTypedData? - let aNullableList = list[7] as! [Any?]? + let aNullableList = list[7] as! [Any]? let aNullableMap = list[8] as! [AnyHashable: Any?]? let nullableNestedList = list[9] as! [[Bool?]?]? let nullableMapWithAnnotations = list[10] as! [String?: String?]? @@ -176,8 +176,8 @@ struct AllNullableTypes { struct AllNullableTypesWrapper { var values: AllNullableTypes - static func fromList(_ list: [Any?]) -> AllNullableTypesWrapper? { - let values = AllNullableTypes.fromList(list[0] as! [Any?])! + static func fromList(_ list: [Any]) -> AllNullableTypesWrapper? { + let values = AllNullableTypes.fromList(list[0] as! [Any])! return AllNullableTypesWrapper( values: values @@ -194,10 +194,10 @@ struct AllNullableTypesWrapper { /// /// Generated class from Pigeon that represents data sent in messages. struct TestMessage { - var testList: [Any?]? = nil + var testList: [Any]? = nil - static func fromList(_ list: [Any?]) -> TestMessage? { - let testList = list[0] as! [Any?]? + static func fromList(_ list: [Any]) -> TestMessage? { + let testList = list[0] as! [Any]? return TestMessage( testList: testList diff --git a/packages/pigeon/test/swift_generator_test.dart b/packages/pigeon/test/swift_generator_test.dart index e4b1b4cd4bb1..a3f81e5ea033 100644 --- a/packages/pigeon/test/swift_generator_test.dart +++ b/packages/pigeon/test/swift_generator_test.dart @@ -31,7 +31,7 @@ void main() { final String code = sink.toString(); expect(code, contains('struct Foobar')); expect(code, contains('var field1: Int32? = nil')); - expect(code, contains('static func fromList(_ list: [Any?]) -> Foobar?')); + expect(code, contains('static func fromList(_ list: [Any]) -> Foobar?')); expect(code, contains('func toList() -> [Any?]')); }); @@ -392,7 +392,7 @@ void main() { generator.generate(swiftOptions, root, sink); final String code = sink.toString(); expect(code, contains('struct Foobar')); - expect(code, contains('var field1: [Any?]? = nil')); + expect(code, contains('var field1: [Any]? = nil')); }); test('gen map', () { @@ -451,8 +451,8 @@ void main() { expect(code, contains('struct Outer')); expect(code, contains('struct Nested')); expect(code, contains('var nested: Nested? = nil')); - expect(code, contains('static func fromList(_ list: [Any?]) -> Outer?')); - expect(code, contains('nested = Nested.fromList(nestedList)')); + expect(code, contains('static func fromList(_ list: [Any]) -> Outer?')); + expect(code, contains('nested = Nested.fromList(nestedList as [Any])')); expect(code, contains('func toList() -> [Any?]')); }); From 2772e955c411d82ed5440ce4627c5970cf24d9ca Mon Sep 17 00:00:00 2001 From: tarrinneal Date: Wed, 22 Feb 2023 22:37:39 -0800 Subject: [PATCH 3/6] kotlin, changelog, generate, format --- packages/pigeon/CHANGELOG.md | 5 +++ packages/pigeon/lib/generator_tools.dart | 2 +- packages/pigeon/lib/kotlin_generator.dart | 8 ++--- packages/pigeon/lib/swift_generator.dart | 2 +- .../mock_handler_tester/test/message.dart | 2 +- .../pigeon/mock_handler_tester/test/test.dart | 2 +- .../CoreTests.java | 2 +- .../ios/Classes/CoreTests.gen.h | 2 +- .../ios/Classes/CoreTests.gen.m | 2 +- .../lib/core_tests.gen.dart | 2 +- .../lib/flutter_unittests.gen.dart | 2 +- .../lib/multiple_arity.gen.dart | 2 +- .../lib/non_null_fields.gen.dart | 2 +- .../lib/null_fields.gen.dart | 2 +- .../lib/nullable_returns.gen.dart | 2 +- .../lib/primitive.gen.dart | 2 +- .../lib/src/generated/core_tests.gen.dart | 2 +- .../com/example/test_plugin/CoreTests.gen.kt | 32 +++++++++---------- .../ios/Classes/CoreTests.gen.swift | 4 +-- .../macos/Classes/CoreTests.gen.swift | 4 +-- .../windows/pigeon/core_tests.gen.cpp | 2 +- .../windows/pigeon/core_tests.gen.h | 2 +- packages/pigeon/pubspec.yaml | 2 +- .../pigeon/test/kotlin_generator_test.dart | 4 +-- 24 files changed, 49 insertions(+), 44 deletions(-) diff --git a/packages/pigeon/CHANGELOG.md b/packages/pigeon/CHANGELOG.md index 21e3938dcbf0..baaca24b23d2 100644 --- a/packages/pigeon/CHANGELOG.md +++ b/packages/pigeon/CHANGELOG.md @@ -1,3 +1,8 @@ +## 9.0.1 + +* [swift] Removes safe casting from decode process. +* [kotlin] Removes safe casting from decode process. + ## 9.0.0 * **Breaking Change** Updates `DartOptions` to be immutable and adds const to the constructor. diff --git a/packages/pigeon/lib/generator_tools.dart b/packages/pigeon/lib/generator_tools.dart index abc1250af5f4..7065903cb5b0 100644 --- a/packages/pigeon/lib/generator_tools.dart +++ b/packages/pigeon/lib/generator_tools.dart @@ -11,7 +11,7 @@ import 'ast.dart'; /// The current version of pigeon. /// /// This must match the version in pubspec.yaml. -const String pigeonVersion = '9.0.0'; +const String pigeonVersion = '9.0.1'; /// Read all the content from [stdin] to a String. String readStdin() { diff --git a/packages/pigeon/lib/kotlin_generator.dart b/packages/pigeon/lib/kotlin_generator.dart index 7c45dec6e171..80823ca2ed59 100644 --- a/packages/pigeon/lib/kotlin_generator.dart +++ b/packages/pigeon/lib/kotlin_generator.dart @@ -228,23 +228,23 @@ class KotlinGenerator extends StructuredGenerator { if (!hostDatatype.isBuiltin && customClassNames.contains(field.type.baseName)) { indent.write('val ${field.name}: $fieldType? = '); - indent.add('($listValue as? List)?.let '); + indent.add('($listValue as List)?.let '); indent.addScoped('{', '}', () { indent.writeln('$fieldType.fromList(it)'); }); } else if (!hostDatatype.isBuiltin && customEnumNames.contains(field.type.baseName)) { indent.write('val ${field.name}: $fieldType? = '); - indent.add('($listValue as? Int)?.let '); + indent.add('($listValue as Int?)?.let '); indent.addScoped('{', '}', () { indent.writeln('$fieldType.ofRaw(it)'); }); } else if (isInt) { indent.write('val ${field.name} = $listValue'); indent.addln( - '.let { if (it is Int) it.toLong() else it as? Long }'); + '.let { if (it is Int) it.toLong() else it as Long? }'); } else { - indent.writeln('val ${field.name} = $listValue as? $fieldType'); + indent.writeln('val ${field.name} = $listValue as $fieldType?'); } } else { if (!hostDatatype.isBuiltin && diff --git a/packages/pigeon/lib/swift_generator.dart b/packages/pigeon/lib/swift_generator.dart index 6f8bbc179717..35d081ccb4d6 100644 --- a/packages/pigeon/lib/swift_generator.dart +++ b/packages/pigeon/lib/swift_generator.dart @@ -193,7 +193,7 @@ import FlutterMacOS } else if (!hostDatatype.isBuiltin && customEnumNames.contains(field.type.baseName)) { indent.writeln('var ${field.name}: $fieldType? = nil'); - indent.write('if let ${field.name}RawValue = $listValue as? Int '); + indent.write('if let ${field.name}RawValue = $listValue as! Int? '); indent.addScoped('{', '}', () { indent.writeln( '${field.name} = $fieldType(rawValue: ${field.name}RawValue)'); diff --git a/packages/pigeon/mock_handler_tester/test/message.dart b/packages/pigeon/mock_handler_tester/test/message.dart index 18557c30f905..a55f0c90c6f2 100644 --- a/packages/pigeon/mock_handler_tester/test/message.dart +++ b/packages/pigeon/mock_handler_tester/test/message.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Autogenerated from Pigeon (v9.0.0), do not edit directly. +// Autogenerated from Pigeon (v9.0.1), do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import diff --git a/packages/pigeon/mock_handler_tester/test/test.dart b/packages/pigeon/mock_handler_tester/test/test.dart index 9e9d240a8d15..10a3112bd7fc 100644 --- a/packages/pigeon/mock_handler_tester/test/test.dart +++ b/packages/pigeon/mock_handler_tester/test/test.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Autogenerated from Pigeon (v9.0.0), do not edit directly. +// Autogenerated from Pigeon (v9.0.1), do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, unnecessary_import // ignore_for_file: avoid_relative_lib_imports diff --git a/packages/pigeon/platform_tests/alternate_language_test_plugin/android/src/main/java/com/example/alternate_language_test_plugin/CoreTests.java b/packages/pigeon/platform_tests/alternate_language_test_plugin/android/src/main/java/com/example/alternate_language_test_plugin/CoreTests.java index bedbf244ec37..aa77a4c7731b 100644 --- a/packages/pigeon/platform_tests/alternate_language_test_plugin/android/src/main/java/com/example/alternate_language_test_plugin/CoreTests.java +++ b/packages/pigeon/platform_tests/alternate_language_test_plugin/android/src/main/java/com/example/alternate_language_test_plugin/CoreTests.java @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Autogenerated from Pigeon (v9.0.0), do not edit directly. +// Autogenerated from Pigeon (v9.0.1), do not edit directly. // See also: https://pub.dev/packages/pigeon package com.example.alternate_language_test_plugin; diff --git a/packages/pigeon/platform_tests/alternate_language_test_plugin/ios/Classes/CoreTests.gen.h b/packages/pigeon/platform_tests/alternate_language_test_plugin/ios/Classes/CoreTests.gen.h index c0f834cfa831..1744498a8764 100644 --- a/packages/pigeon/platform_tests/alternate_language_test_plugin/ios/Classes/CoreTests.gen.h +++ b/packages/pigeon/platform_tests/alternate_language_test_plugin/ios/Classes/CoreTests.gen.h @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Autogenerated from Pigeon (v9.0.0), do not edit directly. +// Autogenerated from Pigeon (v9.0.1), do not edit directly. // See also: https://pub.dev/packages/pigeon #import diff --git a/packages/pigeon/platform_tests/alternate_language_test_plugin/ios/Classes/CoreTests.gen.m b/packages/pigeon/platform_tests/alternate_language_test_plugin/ios/Classes/CoreTests.gen.m index b3f948a4617e..4e752b08ef79 100644 --- a/packages/pigeon/platform_tests/alternate_language_test_plugin/ios/Classes/CoreTests.gen.m +++ b/packages/pigeon/platform_tests/alternate_language_test_plugin/ios/Classes/CoreTests.gen.m @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Autogenerated from Pigeon (v9.0.0), do not edit directly. +// Autogenerated from Pigeon (v9.0.1), do not edit directly. // See also: https://pub.dev/packages/pigeon #import "CoreTests.gen.h" diff --git a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/core_tests.gen.dart b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/core_tests.gen.dart index a4f08bc5f3e8..e8b25be86401 100644 --- a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/core_tests.gen.dart +++ b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/core_tests.gen.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Autogenerated from Pigeon (v9.0.0), do not edit directly. +// Autogenerated from Pigeon (v9.0.1), do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import diff --git a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/flutter_unittests.gen.dart b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/flutter_unittests.gen.dart index 4f83dd981e56..81caf4e4c86b 100644 --- a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/flutter_unittests.gen.dart +++ b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/flutter_unittests.gen.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Autogenerated from Pigeon (v9.0.0), do not edit directly. +// Autogenerated from Pigeon (v9.0.1), do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import diff --git a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/multiple_arity.gen.dart b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/multiple_arity.gen.dart index 42f623b75e68..adb653a0b4c0 100644 --- a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/multiple_arity.gen.dart +++ b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/multiple_arity.gen.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Autogenerated from Pigeon (v9.0.0), do not edit directly. +// Autogenerated from Pigeon (v9.0.1), do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import diff --git a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/non_null_fields.gen.dart b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/non_null_fields.gen.dart index 2b9197cbd874..0f1524fca074 100644 --- a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/non_null_fields.gen.dart +++ b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/non_null_fields.gen.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Autogenerated from Pigeon (v9.0.0), do not edit directly. +// Autogenerated from Pigeon (v9.0.1), do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import diff --git a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/null_fields.gen.dart b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/null_fields.gen.dart index 32c7f070df8a..8595fcd31207 100644 --- a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/null_fields.gen.dart +++ b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/null_fields.gen.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Autogenerated from Pigeon (v9.0.0), do not edit directly. +// Autogenerated from Pigeon (v9.0.1), do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import diff --git a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/nullable_returns.gen.dart b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/nullable_returns.gen.dart index 9a6952239c21..74ffb9c1eda9 100644 --- a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/nullable_returns.gen.dart +++ b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/nullable_returns.gen.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Autogenerated from Pigeon (v9.0.0), do not edit directly. +// Autogenerated from Pigeon (v9.0.1), do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import diff --git a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/primitive.gen.dart b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/primitive.gen.dart index 821033e34e38..50b7567b608b 100644 --- a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/primitive.gen.dart +++ b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/primitive.gen.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Autogenerated from Pigeon (v9.0.0), do not edit directly. +// Autogenerated from Pigeon (v9.0.1), do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import diff --git a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/core_tests.gen.dart b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/core_tests.gen.dart index a4f08bc5f3e8..e8b25be86401 100644 --- a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/core_tests.gen.dart +++ b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/core_tests.gen.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Autogenerated from Pigeon (v9.0.0), do not edit directly. +// Autogenerated from Pigeon (v9.0.1), do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import diff --git a/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/CoreTests.gen.kt b/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/CoreTests.gen.kt index dffa64725cc0..9f71854672b8 100644 --- a/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/CoreTests.gen.kt +++ b/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/CoreTests.gen.kt @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Autogenerated from Pigeon (v9.0.0), do not edit directly. +// Autogenerated from Pigeon (v9.0.1), do not edit directly. // See also: https://pub.dev/packages/pigeon package com.example.test_plugin @@ -109,22 +109,22 @@ data class AllNullableTypes ( companion object { @Suppress("UNCHECKED_CAST") fun fromList(list: List): AllNullableTypes { - val aNullableBool = list[0] as? Boolean - val aNullableInt = list[1].let { if (it is Int) it.toLong() else it as? Long } - val aNullableDouble = list[2] as? Double - val aNullableByteArray = list[3] as? ByteArray - val aNullable4ByteArray = list[4] as? IntArray - val aNullable8ByteArray = list[5] as? LongArray - val aNullableFloatArray = list[6] as? DoubleArray - val aNullableList = list[7] as? List - val aNullableMap = list[8] as? Map - val nullableNestedList = list[9] as? List?> - val nullableMapWithAnnotations = list[10] as? Map - val nullableMapWithObject = list[11] as? Map - val aNullableEnum: AnEnum? = (list[12] as? Int)?.let { + val aNullableBool = list[0] as Boolean? + val aNullableInt = list[1].let { if (it is Int) it.toLong() else it as Long? } + val aNullableDouble = list[2] as Double? + val aNullableByteArray = list[3] as ByteArray? + val aNullable4ByteArray = list[4] as IntArray? + val aNullable8ByteArray = list[5] as LongArray? + val aNullableFloatArray = list[6] as DoubleArray? + val aNullableList = list[7] as List? + val aNullableMap = list[8] as Map? + val nullableNestedList = list[9] as List?>? + val nullableMapWithAnnotations = list[10] as Map? + val nullableMapWithObject = list[11] as Map? + val aNullableEnum: AnEnum? = (list[12] as Int?)?.let { AnEnum.ofRaw(it) } - val aNullableString = list[13] as? String + val aNullableString = list[13] as String? return AllNullableTypes(aNullableBool, aNullableInt, aNullableDouble, aNullableByteArray, aNullable4ByteArray, aNullable8ByteArray, aNullableFloatArray, aNullableList, aNullableMap, nullableNestedList, nullableMapWithAnnotations, nullableMapWithObject, aNullableEnum, aNullableString) } } @@ -179,7 +179,7 @@ data class TestMessage ( companion object { @Suppress("UNCHECKED_CAST") fun fromList(list: List): TestMessage { - val testList = list[0] as? List + val testList = list[0] as List? return TestMessage(testList) } } diff --git a/packages/pigeon/platform_tests/test_plugin/ios/Classes/CoreTests.gen.swift b/packages/pigeon/platform_tests/test_plugin/ios/Classes/CoreTests.gen.swift index b2a495ef9da8..91bf44d16bf5 100644 --- a/packages/pigeon/platform_tests/test_plugin/ios/Classes/CoreTests.gen.swift +++ b/packages/pigeon/platform_tests/test_plugin/ios/Classes/CoreTests.gen.swift @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Autogenerated from Pigeon (v9.0.0), do not edit directly. +// Autogenerated from Pigeon (v9.0.1), do not edit directly. // See also: https://pub.dev/packages/pigeon import Foundation @@ -130,7 +130,7 @@ struct AllNullableTypes { let nullableMapWithAnnotations = list[10] as! [String?: String?]? let nullableMapWithObject = list[11] as! [String?: Any?]? var aNullableEnum: AnEnum? = nil - if let aNullableEnumRawValue = list[12] as? Int { + if let aNullableEnumRawValue = list[12] as! Int? { aNullableEnum = AnEnum(rawValue: aNullableEnumRawValue) } let aNullableString = list[13] as! String? diff --git a/packages/pigeon/platform_tests/test_plugin/macos/Classes/CoreTests.gen.swift b/packages/pigeon/platform_tests/test_plugin/macos/Classes/CoreTests.gen.swift index b2a495ef9da8..91bf44d16bf5 100644 --- a/packages/pigeon/platform_tests/test_plugin/macos/Classes/CoreTests.gen.swift +++ b/packages/pigeon/platform_tests/test_plugin/macos/Classes/CoreTests.gen.swift @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Autogenerated from Pigeon (v9.0.0), do not edit directly. +// Autogenerated from Pigeon (v9.0.1), do not edit directly. // See also: https://pub.dev/packages/pigeon import Foundation @@ -130,7 +130,7 @@ struct AllNullableTypes { let nullableMapWithAnnotations = list[10] as! [String?: String?]? let nullableMapWithObject = list[11] as! [String?: Any?]? var aNullableEnum: AnEnum? = nil - if let aNullableEnumRawValue = list[12] as? Int { + if let aNullableEnumRawValue = list[12] as! Int? { aNullableEnum = AnEnum(rawValue: aNullableEnumRawValue) } let aNullableString = list[13] as! String? diff --git a/packages/pigeon/platform_tests/test_plugin/windows/pigeon/core_tests.gen.cpp b/packages/pigeon/platform_tests/test_plugin/windows/pigeon/core_tests.gen.cpp index d390add49136..7cfd6d00307e 100644 --- a/packages/pigeon/platform_tests/test_plugin/windows/pigeon/core_tests.gen.cpp +++ b/packages/pigeon/platform_tests/test_plugin/windows/pigeon/core_tests.gen.cpp @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Autogenerated from Pigeon (v9.0.0), do not edit directly. +// Autogenerated from Pigeon (v9.0.1), do not edit directly. // See also: https://pub.dev/packages/pigeon #undef _HAS_EXCEPTIONS diff --git a/packages/pigeon/platform_tests/test_plugin/windows/pigeon/core_tests.gen.h b/packages/pigeon/platform_tests/test_plugin/windows/pigeon/core_tests.gen.h index 513bae6682f8..7ded620e918b 100644 --- a/packages/pigeon/platform_tests/test_plugin/windows/pigeon/core_tests.gen.h +++ b/packages/pigeon/platform_tests/test_plugin/windows/pigeon/core_tests.gen.h @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Autogenerated from Pigeon (v9.0.0), do not edit directly. +// Autogenerated from Pigeon (v9.0.1), do not edit directly. // See also: https://pub.dev/packages/pigeon #ifndef PIGEON_CORE_TESTS_GEN_H_ diff --git a/packages/pigeon/pubspec.yaml b/packages/pigeon/pubspec.yaml index de995b5a0a7d..2d9ff9a78086 100644 --- a/packages/pigeon/pubspec.yaml +++ b/packages/pigeon/pubspec.yaml @@ -2,7 +2,7 @@ name: pigeon description: Code generator tool to make communication between Flutter and the host platform type-safe and easier. repository: https://github.com/flutter/packages/tree/main/packages/pigeon issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3Apigeon -version: 9.0.0 # This must match the version in lib/generator_tools.dart +version: 9.0.1 # This must match the version in lib/generator_tools.dart environment: sdk: ">=2.12.0 <3.0.0" diff --git a/packages/pigeon/test/kotlin_generator_test.dart b/packages/pigeon/test/kotlin_generator_test.dart index 7ec7ae3c41c7..338a5ea7392a 100644 --- a/packages/pigeon/test/kotlin_generator_test.dart +++ b/packages/pigeon/test/kotlin_generator_test.dart @@ -348,7 +348,7 @@ void main() { expect( code, contains( - 'val aNullableInt = list[9].let { if (it is Int) it.toLong() else it as? Long }')); + 'val aNullableInt = list[9].let { if (it is Int) it.toLong() else it as Long? }')); }); test('gen one flutter api', () { @@ -617,7 +617,7 @@ void main() { expect(code, contains('val nested: Nested? = null')); expect(code, contains('fun fromList(list: List): Outer')); expect( - code, contains('val nested: Nested? = (list[0] as? List)?.let')); + code, contains('val nested: Nested? = (list[0] as List)?.let')); expect(code, contains('Nested.fromList(it)')); expect(code, contains('fun toList(): List')); }); From 1ac0aee28ca441d44be98bf6562cc432b5331c17 Mon Sep 17 00:00:00 2001 From: tarrinneal Date: Thu, 23 Feb 2023 11:19:24 -0800 Subject: [PATCH 4/6] gen --- packages/pigeon/lib/generator_tools.dart | 2 +- packages/pigeon/mock_handler_tester/test/message.dart | 2 +- packages/pigeon/mock_handler_tester/test/test.dart | 2 +- .../com/example/alternate_language_test_plugin/CoreTests.java | 2 +- .../alternate_language_test_plugin/ios/Classes/CoreTests.gen.h | 2 +- .../alternate_language_test_plugin/ios/Classes/CoreTests.gen.m | 2 +- .../flutter_null_safe_unit_tests/lib/core_tests.gen.dart | 2 +- .../flutter_null_safe_unit_tests/lib/flutter_unittests.gen.dart | 2 +- .../flutter_null_safe_unit_tests/lib/multiple_arity.gen.dart | 2 +- .../flutter_null_safe_unit_tests/lib/non_null_fields.gen.dart | 2 +- .../flutter_null_safe_unit_tests/lib/null_fields.gen.dart | 2 +- .../flutter_null_safe_unit_tests/lib/nullable_returns.gen.dart | 2 +- .../flutter_null_safe_unit_tests/lib/primitive.gen.dart | 2 +- .../lib/src/generated/core_tests.gen.dart | 2 +- .../src/main/kotlin/com/example/test_plugin/CoreTests.gen.kt | 2 +- .../platform_tests/test_plugin/ios/Classes/CoreTests.gen.swift | 2 +- .../test_plugin/macos/Classes/CoreTests.gen.swift | 2 +- .../test_plugin/windows/pigeon/core_tests.gen.cpp | 2 +- .../platform_tests/test_plugin/windows/pigeon/core_tests.gen.h | 2 +- packages/pigeon/pubspec.yaml | 2 +- 20 files changed, 20 insertions(+), 20 deletions(-) diff --git a/packages/pigeon/lib/generator_tools.dart b/packages/pigeon/lib/generator_tools.dart index 7065903cb5b0..b7f3b24fc754 100644 --- a/packages/pigeon/lib/generator_tools.dart +++ b/packages/pigeon/lib/generator_tools.dart @@ -11,7 +11,7 @@ import 'ast.dart'; /// The current version of pigeon. /// /// This must match the version in pubspec.yaml. -const String pigeonVersion = '9.0.1'; +const String pigeonVersion = '9.0.2'; /// Read all the content from [stdin] to a String. String readStdin() { diff --git a/packages/pigeon/mock_handler_tester/test/message.dart b/packages/pigeon/mock_handler_tester/test/message.dart index a55f0c90c6f2..71699ed7d164 100644 --- a/packages/pigeon/mock_handler_tester/test/message.dart +++ b/packages/pigeon/mock_handler_tester/test/message.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Autogenerated from Pigeon (v9.0.1), do not edit directly. +// Autogenerated from Pigeon (v9.0.2), do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import diff --git a/packages/pigeon/mock_handler_tester/test/test.dart b/packages/pigeon/mock_handler_tester/test/test.dart index 10a3112bd7fc..88c1c1ee092b 100644 --- a/packages/pigeon/mock_handler_tester/test/test.dart +++ b/packages/pigeon/mock_handler_tester/test/test.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Autogenerated from Pigeon (v9.0.1), do not edit directly. +// Autogenerated from Pigeon (v9.0.2), do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, unnecessary_import // ignore_for_file: avoid_relative_lib_imports diff --git a/packages/pigeon/platform_tests/alternate_language_test_plugin/android/src/main/java/com/example/alternate_language_test_plugin/CoreTests.java b/packages/pigeon/platform_tests/alternate_language_test_plugin/android/src/main/java/com/example/alternate_language_test_plugin/CoreTests.java index aa77a4c7731b..4cf7c13551bf 100644 --- a/packages/pigeon/platform_tests/alternate_language_test_plugin/android/src/main/java/com/example/alternate_language_test_plugin/CoreTests.java +++ b/packages/pigeon/platform_tests/alternate_language_test_plugin/android/src/main/java/com/example/alternate_language_test_plugin/CoreTests.java @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Autogenerated from Pigeon (v9.0.1), do not edit directly. +// Autogenerated from Pigeon (v9.0.2), do not edit directly. // See also: https://pub.dev/packages/pigeon package com.example.alternate_language_test_plugin; diff --git a/packages/pigeon/platform_tests/alternate_language_test_plugin/ios/Classes/CoreTests.gen.h b/packages/pigeon/platform_tests/alternate_language_test_plugin/ios/Classes/CoreTests.gen.h index 1744498a8764..61dc902f2a8b 100644 --- a/packages/pigeon/platform_tests/alternate_language_test_plugin/ios/Classes/CoreTests.gen.h +++ b/packages/pigeon/platform_tests/alternate_language_test_plugin/ios/Classes/CoreTests.gen.h @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Autogenerated from Pigeon (v9.0.1), do not edit directly. +// Autogenerated from Pigeon (v9.0.2), do not edit directly. // See also: https://pub.dev/packages/pigeon #import diff --git a/packages/pigeon/platform_tests/alternate_language_test_plugin/ios/Classes/CoreTests.gen.m b/packages/pigeon/platform_tests/alternate_language_test_plugin/ios/Classes/CoreTests.gen.m index 4e752b08ef79..64681f92bd53 100644 --- a/packages/pigeon/platform_tests/alternate_language_test_plugin/ios/Classes/CoreTests.gen.m +++ b/packages/pigeon/platform_tests/alternate_language_test_plugin/ios/Classes/CoreTests.gen.m @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Autogenerated from Pigeon (v9.0.1), do not edit directly. +// Autogenerated from Pigeon (v9.0.2), do not edit directly. // See also: https://pub.dev/packages/pigeon #import "CoreTests.gen.h" diff --git a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/core_tests.gen.dart b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/core_tests.gen.dart index e8b25be86401..5e38b604c857 100644 --- a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/core_tests.gen.dart +++ b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/core_tests.gen.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Autogenerated from Pigeon (v9.0.1), do not edit directly. +// Autogenerated from Pigeon (v9.0.2), do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import diff --git a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/flutter_unittests.gen.dart b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/flutter_unittests.gen.dart index 81caf4e4c86b..16d19678aec6 100644 --- a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/flutter_unittests.gen.dart +++ b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/flutter_unittests.gen.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Autogenerated from Pigeon (v9.0.1), do not edit directly. +// Autogenerated from Pigeon (v9.0.2), do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import diff --git a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/multiple_arity.gen.dart b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/multiple_arity.gen.dart index adb653a0b4c0..103dd5b6092f 100644 --- a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/multiple_arity.gen.dart +++ b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/multiple_arity.gen.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Autogenerated from Pigeon (v9.0.1), do not edit directly. +// Autogenerated from Pigeon (v9.0.2), do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import diff --git a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/non_null_fields.gen.dart b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/non_null_fields.gen.dart index 0f1524fca074..061ee32a7d9f 100644 --- a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/non_null_fields.gen.dart +++ b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/non_null_fields.gen.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Autogenerated from Pigeon (v9.0.1), do not edit directly. +// Autogenerated from Pigeon (v9.0.2), do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import diff --git a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/null_fields.gen.dart b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/null_fields.gen.dart index 8595fcd31207..7d7f3376fc8a 100644 --- a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/null_fields.gen.dart +++ b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/null_fields.gen.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Autogenerated from Pigeon (v9.0.1), do not edit directly. +// Autogenerated from Pigeon (v9.0.2), do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import diff --git a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/nullable_returns.gen.dart b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/nullable_returns.gen.dart index 74ffb9c1eda9..8a09cb33c4d0 100644 --- a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/nullable_returns.gen.dart +++ b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/nullable_returns.gen.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Autogenerated from Pigeon (v9.0.1), do not edit directly. +// Autogenerated from Pigeon (v9.0.2), do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import diff --git a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/primitive.gen.dart b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/primitive.gen.dart index 50b7567b608b..c6189e3f39f0 100644 --- a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/primitive.gen.dart +++ b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/primitive.gen.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Autogenerated from Pigeon (v9.0.1), do not edit directly. +// Autogenerated from Pigeon (v9.0.2), do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import diff --git a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/core_tests.gen.dart b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/core_tests.gen.dart index e8b25be86401..5e38b604c857 100644 --- a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/core_tests.gen.dart +++ b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/core_tests.gen.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Autogenerated from Pigeon (v9.0.1), do not edit directly. +// Autogenerated from Pigeon (v9.0.2), do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import diff --git a/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/CoreTests.gen.kt b/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/CoreTests.gen.kt index 9f71854672b8..032f6dab440b 100644 --- a/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/CoreTests.gen.kt +++ b/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/CoreTests.gen.kt @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Autogenerated from Pigeon (v9.0.1), do not edit directly. +// Autogenerated from Pigeon (v9.0.2), do not edit directly. // See also: https://pub.dev/packages/pigeon package com.example.test_plugin diff --git a/packages/pigeon/platform_tests/test_plugin/ios/Classes/CoreTests.gen.swift b/packages/pigeon/platform_tests/test_plugin/ios/Classes/CoreTests.gen.swift index 91bf44d16bf5..75aecc422bbc 100644 --- a/packages/pigeon/platform_tests/test_plugin/ios/Classes/CoreTests.gen.swift +++ b/packages/pigeon/platform_tests/test_plugin/ios/Classes/CoreTests.gen.swift @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Autogenerated from Pigeon (v9.0.1), do not edit directly. +// Autogenerated from Pigeon (v9.0.2), do not edit directly. // See also: https://pub.dev/packages/pigeon import Foundation diff --git a/packages/pigeon/platform_tests/test_plugin/macos/Classes/CoreTests.gen.swift b/packages/pigeon/platform_tests/test_plugin/macos/Classes/CoreTests.gen.swift index 91bf44d16bf5..75aecc422bbc 100644 --- a/packages/pigeon/platform_tests/test_plugin/macos/Classes/CoreTests.gen.swift +++ b/packages/pigeon/platform_tests/test_plugin/macos/Classes/CoreTests.gen.swift @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Autogenerated from Pigeon (v9.0.1), do not edit directly. +// Autogenerated from Pigeon (v9.0.2), do not edit directly. // See also: https://pub.dev/packages/pigeon import Foundation diff --git a/packages/pigeon/platform_tests/test_plugin/windows/pigeon/core_tests.gen.cpp b/packages/pigeon/platform_tests/test_plugin/windows/pigeon/core_tests.gen.cpp index 7cfd6d00307e..2ca8f4d43be8 100644 --- a/packages/pigeon/platform_tests/test_plugin/windows/pigeon/core_tests.gen.cpp +++ b/packages/pigeon/platform_tests/test_plugin/windows/pigeon/core_tests.gen.cpp @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Autogenerated from Pigeon (v9.0.1), do not edit directly. +// Autogenerated from Pigeon (v9.0.2), do not edit directly. // See also: https://pub.dev/packages/pigeon #undef _HAS_EXCEPTIONS diff --git a/packages/pigeon/platform_tests/test_plugin/windows/pigeon/core_tests.gen.h b/packages/pigeon/platform_tests/test_plugin/windows/pigeon/core_tests.gen.h index 7ded620e918b..42ac51a02e76 100644 --- a/packages/pigeon/platform_tests/test_plugin/windows/pigeon/core_tests.gen.h +++ b/packages/pigeon/platform_tests/test_plugin/windows/pigeon/core_tests.gen.h @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Autogenerated from Pigeon (v9.0.1), do not edit directly. +// Autogenerated from Pigeon (v9.0.2), do not edit directly. // See also: https://pub.dev/packages/pigeon #ifndef PIGEON_CORE_TESTS_GEN_H_ diff --git a/packages/pigeon/pubspec.yaml b/packages/pigeon/pubspec.yaml index 2d9ff9a78086..70f92c630e21 100644 --- a/packages/pigeon/pubspec.yaml +++ b/packages/pigeon/pubspec.yaml @@ -2,7 +2,7 @@ name: pigeon description: Code generator tool to make communication between Flutter and the host platform type-safe and easier. repository: https://github.com/flutter/packages/tree/main/packages/pigeon issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3Apigeon -version: 9.0.1 # This must match the version in lib/generator_tools.dart +version: 9.0.2 # This must match the version in lib/generator_tools.dart environment: sdk: ">=2.12.0 <3.0.0" From 8d4cba50647dc3a77fd3793e404fb212fafb37b4 Mon Sep 17 00:00:00 2001 From: tarrinneal Date: Thu, 23 Feb 2023 16:56:59 -0800 Subject: [PATCH 5/6] remove Any? from maps --- packages/pigeon/lib/swift_generator.dart | 2 +- .../example/ios/RunnerTests/PrimitiveTests.swift | 2 +- .../test_plugin/ios/Classes/CoreTests.gen.swift | 8 ++++---- .../test_plugin/macos/Classes/CoreTests.gen.swift | 8 ++++---- packages/pigeon/test/swift_generator_test.dart | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/pigeon/lib/swift_generator.dart b/packages/pigeon/lib/swift_generator.dart index 35d081ccb4d6..3ee54a78a20f 100644 --- a/packages/pigeon/lib/swift_generator.dart +++ b/packages/pigeon/lib/swift_generator.dart @@ -693,7 +693,7 @@ String _swiftTypeForBuiltinGenericDartType(TypeDeclaration type) { if (type.baseName == 'List') { return '[Any]'; } else if (type.baseName == 'Map') { - return '[AnyHashable: Any?]'; + return '[AnyHashable: Any]'; } else { return 'Any'; } diff --git a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/PrimitiveTests.swift b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/PrimitiveTests.swift index 1f3f0851fb70..861bfa6d4d28 100644 --- a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/PrimitiveTests.swift +++ b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/PrimitiveTests.swift @@ -11,7 +11,7 @@ class MockPrimitiveHostApi: PrimitiveHostApi { func aBool(value: Bool) -> Bool { value } func aString(value: String) -> String { value } func aDouble(value: Double) -> Double { value } - func aMap(value: [AnyHashable: Any?]) -> [AnyHashable: Any?] { value } + func aMap(value: [AnyHashable: Any]) -> [AnyHashable: Any] { value } func aList(value: [Any]) -> [Any] { value } func anInt32List(value: FlutterStandardTypedData) -> FlutterStandardTypedData { value } func aBoolList(value: [Bool?]) -> [Bool?] { value } diff --git a/packages/pigeon/platform_tests/test_plugin/ios/Classes/CoreTests.gen.swift b/packages/pigeon/platform_tests/test_plugin/ios/Classes/CoreTests.gen.swift index 75aecc422bbc..9e1fa4bee614 100644 --- a/packages/pigeon/platform_tests/test_plugin/ios/Classes/CoreTests.gen.swift +++ b/packages/pigeon/platform_tests/test_plugin/ios/Classes/CoreTests.gen.swift @@ -51,7 +51,7 @@ struct AllTypes { var a8ByteArray: FlutterStandardTypedData var aFloatArray: FlutterStandardTypedData var aList: [Any] - var aMap: [AnyHashable: Any?] + var aMap: [AnyHashable: Any] var anEnum: AnEnum var aString: String @@ -64,7 +64,7 @@ struct AllTypes { let a8ByteArray = list[5] as! FlutterStandardTypedData let aFloatArray = list[6] as! FlutterStandardTypedData let aList = list[7] as! [Any] - let aMap = list[8] as! [AnyHashable: Any?] + let aMap = list[8] as! [AnyHashable: Any] let anEnum = AnEnum(rawValue: list[9] as! Int)! let aString = list[10] as! String @@ -109,7 +109,7 @@ struct AllNullableTypes { var aNullable8ByteArray: FlutterStandardTypedData? = nil var aNullableFloatArray: FlutterStandardTypedData? = nil var aNullableList: [Any]? = nil - var aNullableMap: [AnyHashable: Any?]? = nil + var aNullableMap: [AnyHashable: Any]? = nil var nullableNestedList: [[Bool?]?]? = nil var nullableMapWithAnnotations: [String?: String?]? = nil var nullableMapWithObject: [String?: Any?]? = nil @@ -125,7 +125,7 @@ struct AllNullableTypes { let aNullable8ByteArray = list[5] as! FlutterStandardTypedData? let aNullableFloatArray = list[6] as! FlutterStandardTypedData? let aNullableList = list[7] as! [Any]? - let aNullableMap = list[8] as! [AnyHashable: Any?]? + let aNullableMap = list[8] as! [AnyHashable: Any]? let nullableNestedList = list[9] as! [[Bool?]?]? let nullableMapWithAnnotations = list[10] as! [String?: String?]? let nullableMapWithObject = list[11] as! [String?: Any?]? diff --git a/packages/pigeon/platform_tests/test_plugin/macos/Classes/CoreTests.gen.swift b/packages/pigeon/platform_tests/test_plugin/macos/Classes/CoreTests.gen.swift index 75aecc422bbc..9e1fa4bee614 100644 --- a/packages/pigeon/platform_tests/test_plugin/macos/Classes/CoreTests.gen.swift +++ b/packages/pigeon/platform_tests/test_plugin/macos/Classes/CoreTests.gen.swift @@ -51,7 +51,7 @@ struct AllTypes { var a8ByteArray: FlutterStandardTypedData var aFloatArray: FlutterStandardTypedData var aList: [Any] - var aMap: [AnyHashable: Any?] + var aMap: [AnyHashable: Any] var anEnum: AnEnum var aString: String @@ -64,7 +64,7 @@ struct AllTypes { let a8ByteArray = list[5] as! FlutterStandardTypedData let aFloatArray = list[6] as! FlutterStandardTypedData let aList = list[7] as! [Any] - let aMap = list[8] as! [AnyHashable: Any?] + let aMap = list[8] as! [AnyHashable: Any] let anEnum = AnEnum(rawValue: list[9] as! Int)! let aString = list[10] as! String @@ -109,7 +109,7 @@ struct AllNullableTypes { var aNullable8ByteArray: FlutterStandardTypedData? = nil var aNullableFloatArray: FlutterStandardTypedData? = nil var aNullableList: [Any]? = nil - var aNullableMap: [AnyHashable: Any?]? = nil + var aNullableMap: [AnyHashable: Any]? = nil var nullableNestedList: [[Bool?]?]? = nil var nullableMapWithAnnotations: [String?: String?]? = nil var nullableMapWithObject: [String?: Any?]? = nil @@ -125,7 +125,7 @@ struct AllNullableTypes { let aNullable8ByteArray = list[5] as! FlutterStandardTypedData? let aNullableFloatArray = list[6] as! FlutterStandardTypedData? let aNullableList = list[7] as! [Any]? - let aNullableMap = list[8] as! [AnyHashable: Any?]? + let aNullableMap = list[8] as! [AnyHashable: Any]? let nullableNestedList = list[9] as! [[Bool?]?]? let nullableMapWithAnnotations = list[10] as! [String?: String?]? let nullableMapWithObject = list[11] as! [String?: Any?]? diff --git a/packages/pigeon/test/swift_generator_test.dart b/packages/pigeon/test/swift_generator_test.dart index a3f81e5ea033..04d6016029a5 100644 --- a/packages/pigeon/test/swift_generator_test.dart +++ b/packages/pigeon/test/swift_generator_test.dart @@ -412,7 +412,7 @@ void main() { generator.generate(swiftOptions, root, sink); final String code = sink.toString(); expect(code, contains('struct Foobar')); - expect(code, contains('var field1: [AnyHashable: Any?]? = nil')); + expect(code, contains('var field1: [AnyHashable: Any]? = nil')); }); test('gen nested', () { From 307128f412c7af977cfeaddc83292ec33c897ed8 Mon Sep 17 00:00:00 2001 From: tarrinneal Date: Mon, 27 Feb 2023 16:46:59 -0800 Subject: [PATCH 6/6] ? --- packages/pigeon/lib/kotlin_generator.dart | 2 +- packages/pigeon/lib/swift_generator.dart | 2 +- packages/pigeon/test/kotlin_generator_test.dart | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/pigeon/lib/kotlin_generator.dart b/packages/pigeon/lib/kotlin_generator.dart index 80823ca2ed59..b775b3923cb2 100644 --- a/packages/pigeon/lib/kotlin_generator.dart +++ b/packages/pigeon/lib/kotlin_generator.dart @@ -228,7 +228,7 @@ class KotlinGenerator extends StructuredGenerator { if (!hostDatatype.isBuiltin && customClassNames.contains(field.type.baseName)) { indent.write('val ${field.name}: $fieldType? = '); - indent.add('($listValue as List)?.let '); + indent.add('($listValue as List?)?.let '); indent.addScoped('{', '}', () { indent.writeln('$fieldType.fromList(it)'); }); diff --git a/packages/pigeon/lib/swift_generator.dart b/packages/pigeon/lib/swift_generator.dart index 3ee54a78a20f..2ba822b97518 100644 --- a/packages/pigeon/lib/swift_generator.dart +++ b/packages/pigeon/lib/swift_generator.dart @@ -185,7 +185,7 @@ import FlutterMacOS if (!hostDatatype.isBuiltin && customClassNames.contains(field.type.baseName)) { indent.writeln('var ${field.name}: $fieldType? = nil'); - indent.write('if let ${field.name}List = $listValue as? [Any] '); + indent.write('if let ${field.name}List = $listValue as! [Any]? '); indent.addScoped('{', '}', () { indent.writeln( '${field.name} = $fieldType.fromList(${field.name}List as [Any])'); diff --git a/packages/pigeon/test/kotlin_generator_test.dart b/packages/pigeon/test/kotlin_generator_test.dart index 338a5ea7392a..2aae1029ea66 100644 --- a/packages/pigeon/test/kotlin_generator_test.dart +++ b/packages/pigeon/test/kotlin_generator_test.dart @@ -617,7 +617,7 @@ void main() { expect(code, contains('val nested: Nested? = null')); expect(code, contains('fun fromList(list: List): Outer')); expect( - code, contains('val nested: Nested? = (list[0] as List)?.let')); + code, contains('val nested: Nested? = (list[0] as List?)?.let')); expect(code, contains('Nested.fromList(it)')); expect(code, contains('fun toList(): List')); });