Skip to content

Fix cast error when debugging from VSCode #2303

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
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>{};
}