From ad36a981bc5dc864d1877ed2042786a255d0b969 Mon Sep 17 00:00:00 2001 From: Ben Konyi Date: Fri, 29 Nov 2024 20:28:45 +0000 Subject: [PATCH] [ package:vm_service] Update CodeRef.function to have type dynamic The function property of a Code object can contain either a Function or a NativeFunction. This change updates the protocol specification to properly document existing behavior and regenerates package:vm_service to update `CodeRef.function` to have a `dynamic` type. This is a breaking change to `package:vm_service`, so this will be released as 15.0.0. Related to https://github.com/flutter/devtools/issues/8567 TEST=N/A Change-Id: Ie89723cdba8176be0d84a57a878fbedbca57f9c0 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/398260 Commit-Queue: Ben Konyi Reviewed-by: Derek Xu Auto-Submit: Ben Konyi --- pkg/vm_service/CHANGELOG.md | 6 ++++++ pkg/vm_service/lib/src/vm_service.dart | 16 ++++++++++------ pkg/vm_service/pubspec.yaml | 2 +- runtime/vm/service/service.md | 4 ++-- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/pkg/vm_service/CHANGELOG.md b/pkg/vm_service/CHANGELOG.md index b62301be59d5..fb32fdf3ebd9 100644 --- a/pkg/vm_service/CHANGELOG.md +++ b/pkg/vm_service/CHANGELOG.md @@ -1,3 +1,9 @@ +## 15.0.0 +- Update type of `CodeRef.function` from `FuncRef` to `dynamic` to allow for `NativeFunction` + functions ([flutter/devtools #8567]). + +[flutter/devtools #8567]: https://github.com/flutter/devtools/issues/8567 + ## 14.3.1 - Fix crash that could occur when trying to send a service extension response after the service connection had already been disposed of ([flutter/flutter #157296]). diff --git a/pkg/vm_service/lib/src/vm_service.dart b/pkg/vm_service/lib/src/vm_service.dart index 4cbfdc846017..dc2872b30f5e 100644 --- a/pkg/vm_service/lib/src/vm_service.dart +++ b/pkg/vm_service/lib/src/vm_service.dart @@ -3205,8 +3205,10 @@ class CodeRef extends ObjRef { /*CodeKind*/ String? kind; /// This code object's corresponding function. + /// + /// [function] can be one of [FuncRef] or [NativeFunction]. @optional - FuncRef? function; + dynamic function; CodeRef({ this.name, @@ -3220,8 +3222,8 @@ class CodeRef extends ObjRef { CodeRef._fromJson(Map json) : super._fromJson(json) { name = json['name'] ?? ''; kind = json['kind'] ?? ''; - function = - createServiceObject(json['function'], const ['FuncRef']) as FuncRef?; + function = createServiceObject( + json['function'], const ['FuncRef', 'NativeFunction']) as dynamic; } @override @@ -3261,9 +3263,11 @@ class Code extends Obj implements CodeRef { /*CodeKind*/ String? kind; /// This code object's corresponding function. + /// + /// [function] can be one of [FuncRef] or [NativeFunction]. @optional @override - FuncRef? function; + dynamic function; Code({ this.name, @@ -3277,8 +3281,8 @@ class Code extends Obj implements CodeRef { Code._fromJson(Map json) : super._fromJson(json) { name = json['name'] ?? ''; kind = json['kind'] ?? ''; - function = - createServiceObject(json['function'], const ['FuncRef']) as FuncRef?; + function = createServiceObject( + json['function'], const ['FuncRef', 'NativeFunction']) as dynamic; } @override diff --git a/pkg/vm_service/pubspec.yaml b/pkg/vm_service/pubspec.yaml index 9c29eea3d284..9e7519e3ef4e 100644 --- a/pkg/vm_service/pubspec.yaml +++ b/pkg/vm_service/pubspec.yaml @@ -1,5 +1,5 @@ name: vm_service -version: 14.3.1 +version: 15.0.0 description: >- A library to communicate with a service implementing the Dart VM service protocol. diff --git a/runtime/vm/service/service.md b/runtime/vm/service/service.md index 2f3a715d8d21..d21b5d772542 100644 --- a/runtime/vm/service/service.md +++ b/runtime/vm/service/service.md @@ -2228,7 +2228,7 @@ class @Code extends @Object { CodeKind kind; // This code object's corresponding function. - @Function function [optional]; + @Function|NativeFunction function [optional]; } ``` @@ -2243,7 +2243,7 @@ class Code extends Object { CodeKind kind; // This code object's corresponding function. - @Function function [optional]; + @Function|NativeFunction function [optional]; } ```