Use createMessage() of type GeneratedMessage Function() in Dart protoc compiler#1093
Use createMessage() of type GeneratedMessage Function() in Dart protoc compiler#1093mkustermann wants to merge 11 commits into
createMessage() of type GeneratedMessage Function() in Dart protoc compiler#1093Conversation
Often apps use extensive numbers of protos. The `BuilderInfo` of a proto will refer to sub proto messages via using `Foo.create` tear-offs. Big apps can end up with tens of thousands of those `<name>.create` closures. All of them currently have a unique `<name> Function()` function type. Though the actual usage of those closures is only in contexts where the caller of the closure expects a `GeneratedMessage` as return type. If a caller knew the actual return type, then the caller could call the constructor directly. To avoid having to create potentially tens of thousands of unique function types, we make those closures have the `GeneratedMessage Function()` type.
a18614c to
60cf071
Compare
… SDK info-ing about it)
786ce2e to
b9bf0fe
Compare
sigurdm
left a comment
There was a problem hiding this comment.
LGTM
This is probably a breaking change though.
|
@sigurdm Do you know how I can fix the PR failures? I formatted locally before pushing, but it still seems fail. Maybe the bot uses a slightly different Dart SDK with slightly different analyzer infos? |
I will try this in g3 before landing & measure impact on some apps before landing. In reality I hope this doesn't break anyone as it'd be strange to use |
Package publishing
Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation. |
|
Yeah it would be strange, but people do the strangest things... If we cannot find any breakages I'm ok with a minor release At least we should try see how this fares against google3. The protoc_plugin pubspec should have its constraint on protobuf updated to require at least this new version. |
|
/cc @rakudrama |
create() functions have GeneratedMessage Function() typecreateMessage() of type GeneratedMessage Function() in Dart protoc compiler
Often apps use extensive numbers of protos. The
BuilderInfoof a proto will refer to sub proto messages via usingFoo.createtear-offs.Big apps can end up with tens of thousands of those
<name>.createclosures. All of them currently have a unique<name> Function()function type.Though the actual usage of those closures is only in contexts where the caller of the closure expects a
GeneratedMessageas return type. If a caller knew the actual return type, then the caller could call the constructor directly.To avoid having to create potentially tens of thousands of unique function types, we make those closures have the
GeneratedMessage Function()type.