Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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.1.5

* [kotlin] Fixes a "bridge method" warning that occurs when a class uses `*PigeonEventChannelWrapper` as a
supertype without implementing all of its methods.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the "without implementing all of its methods" part right? The video_player code was implementing both of these methods.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am open to better wording but the class that implemented all the methods was an implementation of *EventsStreamHandler not the interface *PigeonEventChannelWrapper.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see. Since we don't expect Pigeon users to directly subclass the Wrapper class, let's just say "... warning when implementing an event stream handler."


## 26.1.4

* [swift][kotlin] Fixes crash that occurs when an object that is removed from the instance manager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,8 @@ abstract class StreamEventsStreamHandler :
.setStreamHandler(internalStreamHandler)
}
}
// Implement methods from EventChannelMessagesPigeonEventChannelWrapper
override open fun onListen(p0: Any?, sink: PigeonEventSink<PlatformEvent>) {}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does making these abstract instead of no-ops ({}) work and fix the warning? That would be an explicit statement of the intent here, which is to not implement the interface at this level but require subclasses to implement the type-specified version.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I repro'd locally and tried it, and this does indeed seem to work:

  override open abstract fun onListen(p0: Any?, sink: PigeonEventSink<PlatformVideoEvent>)
  override open abstract fun onCancel(p0: Any?)

That keeps the same semantics of forcing the subclasses to implement both methods, without tripping the warning.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modifying the pr to do this instead. My goal was not to change the semantics.


override open fun onCancel(p0: Any?) {}
}
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.1.4';
const String pigeonVersion = '26.1.5';

/// Read all the content from [stdin] to a String.
String readStdin() {
Expand Down
6 changes: 6 additions & 0 deletions packages/pigeon/lib/src/kotlin/kotlin_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1234,6 +1234,12 @@ if (wrapped == null) {
EventChannel(messenger, channelName, ${generatorOptions.fileSpecificClassNameComponent}$_pigeonMethodChannelCodec).setStreamHandler(internalStreamHandler)
}
}
// Implement methods from ${generatorOptions.fileSpecificClassNameComponent}PigeonEventChannelWrapper
override
open fun onListen(p0: Any?, sink: PigeonEventSink<${_kotlinTypeForDartType(func.returnType)}>) {}

override
open fun onCancel(p0: Any?) {}
}
''');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,10 @@ abstract class StreamIntsStreamHandler : EventChannelTestsPigeonEventChannelWrap
.setStreamHandler(internalStreamHandler)
}
}
// Implement methods from EventChannelTestsPigeonEventChannelWrapper
override open fun onListen(p0: Any?, sink: PigeonEventSink<Long>) {}

override open fun onCancel(p0: Any?) {}
}

abstract class StreamEventsStreamHandler :
Expand All @@ -595,6 +599,10 @@ abstract class StreamEventsStreamHandler :
.setStreamHandler(internalStreamHandler)
}
}
// Implement methods from EventChannelTestsPigeonEventChannelWrapper
override open fun onListen(p0: Any?, sink: PigeonEventSink<PlatformEvent>) {}

override open fun onCancel(p0: Any?) {}
}

abstract class StreamConsistentNumbersStreamHandler :
Expand All @@ -615,4 +623,8 @@ abstract class StreamConsistentNumbersStreamHandler :
.setStreamHandler(internalStreamHandler)
}
}
// Implement methods from EventChannelTestsPigeonEventChannelWrapper
override open fun onListen(p0: Any?, sink: PigeonEventSink<Long>) {}

override open fun onCancel(p0: Any?) {}
}
2 changes: 1 addition & 1 deletion 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.1.4 # This must match the version in lib/src/generator_tools.dart
version: 26.1.5 # This must match the version in lib/src/generator_tools.dart

environment:
sdk: ^3.9.0
Expand Down