Skip to content

Commit

Permalink
[ package:vm_service] Update CodeRef.function to have type dynamic
Browse files Browse the repository at this point in the history
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 flutter/devtools#8567

TEST=N/A

Change-Id: Ie89723cdba8176be0d84a57a878fbedbca57f9c0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/398260
Commit-Queue: Ben Konyi <[email protected]>
Reviewed-by: Derek Xu <[email protected]>
Auto-Submit: Ben Konyi <[email protected]>
  • Loading branch information
bkonyi authored and Commit Queue committed Nov 29, 2024
1 parent 4eca32f commit ad36a98
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
6 changes: 6 additions & 0 deletions pkg/vm_service/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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]).
Expand Down
16 changes: 10 additions & 6 deletions pkg/vm_service/lib/src/vm_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -3220,8 +3222,8 @@ class CodeRef extends ObjRef {
CodeRef._fromJson(Map<String, dynamic> 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
Expand Down Expand Up @@ -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,
Expand All @@ -3277,8 +3281,8 @@ class Code extends Obj implements CodeRef {
Code._fromJson(Map<String, dynamic> 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
Expand Down
2 changes: 1 addition & 1 deletion pkg/vm_service/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
4 changes: 2 additions & 2 deletions runtime/vm/service/service.md
Original file line number Diff line number Diff line change
Expand Up @@ -2228,7 +2228,7 @@ class @Code extends @Object {
CodeKind kind;
// This code object's corresponding function.
@Function function [optional];
@Function|NativeFunction function [optional];
}
```

Expand All @@ -2243,7 +2243,7 @@ class Code extends Object {
CodeKind kind;
// This code object's corresponding function.
@Function function [optional];
@Function|NativeFunction function [optional];
}
```

Expand Down

0 comments on commit ad36a98

Please sign in to comment.