Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions packages/pigeon/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 26.3.4

* [kotlin] Updates generated error class to inherit from `RuntimeException`
instead of `Throwable`, for better Java interoperability.

## 26.3.3

* Updates `analyzer` dependency to support versions 10 through 12.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class FlutterError(
val code: String,
override val message: String? = null,
val details: Any? = null
) : Throwable()
) : RuntimeException()

enum class Code(val raw: Int) {
ONE(0),
Expand Down
2 changes: 1 addition & 1 deletion packages/pigeon/lib/src/generator_tools.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import 'generator.dart';
/// The current version of pigeon.
///
/// This must match the version in pubspec.yaml.
const String pigeonVersion = '26.3.3';
const String pigeonVersion = '26.3.4';

/// Default plugin package name.
const String defaultPluginPackageName = 'dev.flutter.pigeon';
Expand Down
2 changes: 1 addition & 1 deletion packages/pigeon/lib/src/kotlin/kotlin_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1350,7 +1350,7 @@ if (wrapped == null) {
indent.writeln('override val message: String? = null,');
indent.writeln('val details: Any? = null');
}, addTrailingNewline: false);
indent.addln(' : Throwable()');
indent.addln(' : RuntimeException()');
}

void _writeCreateConnectionError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ class FlutterError(
val code: String,
override val message: String? = null,
val details: Any? = null
) : Throwable()
) : RuntimeException()

enum class AnEnum(val raw: Int) {
ONE(0),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class EventChannelTestsError(
val code: String,
override val message: String? = null,
val details: Any? = null
) : Throwable()
) : RuntimeException()

enum class EventEnum(val raw: Int) {
ONE(0),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class ProxyApiTestsError(
val code: String,
override val message: String? = null,
val details: Any? = null
) : Throwable()
) : RuntimeException()
/**
* Maintains instances used to communicate with the corresponding objects in Dart.
*
Expand Down
3 changes: 1 addition & 2 deletions packages/pigeon/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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%3A%22p%3A+pigeon%22
version: 26.3.3 # This must match the version in lib/src/generator_tools.dart
version: 26.3.4 # This must match the version in lib/src/generator_tools.dart

environment:
sdk: ^3.9.0
Expand All @@ -27,4 +27,3 @@ topics:
- interop
- platform-channels
- plugin-development

39 changes: 39 additions & 0 deletions packages/pigeon/test/kotlin_generator_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1983,6 +1983,45 @@ void main() {
expect(code, isNot(contains('FlutterError')));
});

test('error class inherits from RuntimeException', () {
final root = Root(
apis: <Api>[
AstHostApi(
name: 'Api',
methods: <Method>[
Method(
name: 'method',
location: ApiLocation.host,
returnType: const TypeDeclaration.voidDeclaration(),
parameters: <Parameter>[
Parameter(
name: 'field',
type: const TypeDeclaration(
baseName: 'int',
isNullable: true,
),
),
],
),
],
),
],
classes: <Class>[],
enums: <Enum>[],
);
final sink = StringBuffer();
const kotlinOptions = InternalKotlinOptions(kotlinOut: '');
const generator = KotlinGenerator();
generator.generate(
kotlinOptions,
root,
sink,
dartPackageName: DEFAULT_PACKAGE_NAME,
);
final code = sink.toString();
expect(code, contains(': RuntimeException()'));
});

test('do not generate duplicated entries in writeValue', () {
final root = Root(
apis: <Api>[
Expand Down
Loading