Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pigeon]fix a crash when casting NSNull to an Array #4289

Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/pigeon/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 10.1.2

* [swift] Fixes a crash when casting `NSNull` to an array.
tarrinneal marked this conversation as resolved.
Show resolved Hide resolved

## 10.1.1

* Updates README to better reflect modern usage.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Autogenerated from Pigeon (v10.1.1), do not edit directly.
// Autogenerated from Pigeon (v10.1.2), do not edit directly.
// See also: https://pub.dev/packages/pigeon

import android.util.Log;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Autogenerated from Pigeon (v10.1.1), do not edit directly.
// Autogenerated from Pigeon (v10.1.2), do not edit directly.
// See also: https://pub.dev/packages/pigeon


Expand Down
2 changes: 1 addition & 1 deletion packages/pigeon/example/app/ios/Runner/Messages.g.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Autogenerated from Pigeon (v10.1.1), do not edit directly.
// Autogenerated from Pigeon (v10.1.2), do not edit directly.
// See also: https://pub.dev/packages/pigeon

import Foundation
Expand Down
2 changes: 1 addition & 1 deletion packages/pigeon/example/app/lib/src/messages.g.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Autogenerated from Pigeon (v10.1.1), do not edit directly.
// Autogenerated from Pigeon (v10.1.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

Expand Down
2 changes: 1 addition & 1 deletion packages/pigeon/example/app/macos/Runner/messages.g.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Autogenerated from Pigeon (v10.1.1), do not edit directly.
// Autogenerated from Pigeon (v10.1.2), do not edit directly.
// See also: https://pub.dev/packages/pigeon

#import <Foundation/Foundation.h>
Expand Down
2 changes: 1 addition & 1 deletion packages/pigeon/example/app/macos/Runner/messages.g.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Autogenerated from Pigeon (v10.1.1), do not edit directly.
// Autogenerated from Pigeon (v10.1.2), do not edit directly.
// See also: https://pub.dev/packages/pigeon

#import "messages.g.h"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Autogenerated from Pigeon (v10.1.1), do not edit directly.
// Autogenerated from Pigeon (v10.1.2), do not edit directly.
// See also: https://pub.dev/packages/pigeon

#undef _HAS_EXCEPTIONS
Expand Down
2 changes: 1 addition & 1 deletion packages/pigeon/example/app/windows/runner/messages.g.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Autogenerated from Pigeon (v10.1.1), do not edit directly.
// Autogenerated from Pigeon (v10.1.2), do not edit directly.
// See also: https://pub.dev/packages/pigeon

#ifndef PIGEON_MESSAGES_G_H_
Expand Down
2 changes: 1 addition & 1 deletion packages/pigeon/lib/generator_tools.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'ast.dart';
/// The current version of pigeon.
///
/// This must match the version in pubspec.yaml.
const String pigeonVersion = '10.1.1';
const String pigeonVersion = '10.1.2';

/// Read all the content from [stdin] to a String.
String readStdin() {
Expand Down
3 changes: 2 additions & 1 deletion packages/pigeon/lib/swift_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,8 @@ import FlutterMacOS
if (listEncodedClassNames != null &&
listEncodedClassNames.contains(type.baseName)) {
indent.writeln('var $variableName: $fieldType? = nil');
indent.write('if let ${variableName}List = $value as! [Any?]? ');
indent
.write('if let ${variableName}List: [Any?] = nilOrValue($value) ');
stuartmorgan marked this conversation as resolved.
Show resolved Hide resolved
indent.addScoped('{', '}', () {
indent.writeln(
'$variableName = $fieldType.fromList(${variableName}List)');
Expand Down
2 changes: 1 addition & 1 deletion packages/pigeon/mock_handler_tester/test/message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.2.5), do not edit directly.
// Autogenerated from Pigeon (v10.1.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

Expand Down
2 changes: 1 addition & 1 deletion packages/pigeon/mock_handler_tester/test/test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.2.5), do not edit directly.
// Autogenerated from Pigeon (v10.1.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
Expand Down
16 changes: 11 additions & 5 deletions packages/pigeon/pigeons/core_tests.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@ class AllNullableTypes {
}

// A class for testing nested object handling.
class AllNullableTypesWrapper {
AllNullableTypesWrapper(this.values);
AllNullableTypes values;
class AllClassesWrapper {
AllClassesWrapper(this.allNullableTypes, this.allTypes);
AllNullableTypes allNullableTypes;
AllTypes? allTypes;
tarrinneal marked this conversation as resolved.
Show resolved Hide resolved
}

/// The core interface that each host language plugin must implement in
Expand Down Expand Up @@ -152,6 +153,11 @@ abstract class HostIntegrationCoreApi {
@SwiftFunction('echo(_:)')
Map<String?, Object?> echoMap(Map<String?, Object?> aMap);

/// Returns the passed map to test nested class serialization and deserialization.
@ObjCSelector('echoClassWrapper:')
@SwiftFunction('echo(_:)')
AllClassesWrapper echoClassWrapper(AllClassesWrapper wrapper);

// ========== Synchronous nullable method tests ==========

/// Returns the passed object, to test serialization and deserialization.
Expand All @@ -163,13 +169,13 @@ abstract class HostIntegrationCoreApi {
/// sending of nested objects.
@ObjCSelector('extractNestedNullableStringFrom:')
@SwiftFunction('extractNestedNullableString(from:)')
String? extractNestedNullableString(AllNullableTypesWrapper wrapper);
String? extractNestedNullableString(AllClassesWrapper wrapper);

/// Returns the inner `aString` value from the wrapped object, to test
/// sending of nested objects.
@ObjCSelector('createNestedObjectWithNullableString:')
@SwiftFunction('createNestedObject(with:)')
AllNullableTypesWrapper createNestedNullableString(String? nullableString);
AllClassesWrapper createNestedNullableString(String? nullableString);

/// Returns passed in arguments of multiple types.
@ObjCSelector('sendMultipleNullableTypesABool:anInt:aString:')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.example.alternate_language_test_plugin.CoreTests.AllClassesWrapper;
import com.example.alternate_language_test_plugin.CoreTests.AllNullableTypes;
import com.example.alternate_language_test_plugin.CoreTests.AllNullableTypesWrapper;
import com.example.alternate_language_test_plugin.CoreTests.AllTypes;
import com.example.alternate_language_test_plugin.CoreTests.FlutterIntegrationCoreApi;
import com.example.alternate_language_test_plugin.CoreTests.HostIntegrationCoreApi;
Expand Down Expand Up @@ -99,17 +99,21 @@ public void throwErrorFromVoid() {
return aMap;
}

@NonNull
public AllClassesWrapper echoClassWrapper(@NonNull AllClassesWrapper wrapper) {
return wrapper;
}

@Override
public @Nullable String extractNestedNullableString(@NonNull AllNullableTypesWrapper wrapper) {
return wrapper.getValues().getANullableString();
public @Nullable String extractNestedNullableString(@NonNull AllClassesWrapper wrapper) {
return wrapper.getAllNullableTypes().getANullableString();
}

@Override
public @NonNull AllNullableTypesWrapper createNestedNullableString(
@Nullable String nullableString) {
public @NonNull AllClassesWrapper createNestedNullableString(@Nullable String nullableString) {
AllNullableTypes innerObject =
new AllNullableTypes.Builder().setANullableString(nullableString).build();
return new AllNullableTypesWrapper.Builder().setValues(innerObject).build();
return new AllClassesWrapper.Builder().setAllNullableTypes(innerObject).build();
}

@Override
Expand Down
Loading