Skip to content

Commit

Permalink
Fix cast error when debugging from VSCode (#2303)
Browse files Browse the repository at this point in the history
  • Loading branch information
elliette authored Dec 14, 2023
1 parent b339a50 commit a12368f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions dwds/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
- Restructure `LoadStrategy` to provide build settings. - [#2270](https://github.com/dart-lang/webdev/pull/2270)
- Add `FrontendServerLegacyStrategyProvider` and update bootstrap generation logic for `LegacyStrategy` - [#2285](https://github.com/dart-lang/webdev/pull/2285)
- Tolerate failures to detect a dart execution context. - [#2286](https://github.com/dart-lang/webdev/pull/2286)
- Fix a null cast error when debugging a `Class` from VS Code. - [#2303](https://github.com/dart-lang/webdev/pull/2303)

## 22.1.0
- Update `package:vm_service` constraint to `^13.0.0`. - [#2265](https://github.com/dart-lang/webdev/pull/2265)
Expand Down
10 changes: 6 additions & 4 deletions dwds/lib/src/debugging/classes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,9 @@ class ClassHelper extends Domain {
throw ChromeDebugException(e.json, evalContents: expression);
}

final classDescriptor = result.value as Map<String, dynamic>;
final classDescriptor = _mapify(result.value);
final methodRefs = <FuncRef>[];
final methodDescriptors =
classDescriptor['methods'] as Map<String, dynamic>;
final methodDescriptors = _mapify(classDescriptor['methods']);
methodDescriptors.forEach((name, descriptor) {
final methodId = 'methods|$classId|$name';
methodRefs.add(
Expand All @@ -118,7 +117,7 @@ class ClassHelper extends Domain {
});
final fieldRefs = <FieldRef>[];

final fieldDescriptors = classDescriptor['fields'] as Map<String, dynamic>;
final fieldDescriptors = _mapify(classDescriptor['fields']);
fieldDescriptors.forEach((name, descriptor) {
final classMetaData = ClassMetaData(
runtimeKind: RuntimeObjectKind.type,
Expand Down Expand Up @@ -168,4 +167,7 @@ class ClassHelper extends Domain {
superClass: superClassRef,
);
}

Map<String, dynamic> _mapify(dynamic map) =>
(map as Map<String, dynamic>?) ?? <String, dynamic>{};
}

0 comments on commit a12368f

Please sign in to comment.