Skip to content

Commit

Permalink
Fix cast error when debugging from VSCode (dart-lang#2303)
Browse files Browse the repository at this point in the history
  • Loading branch information
elliette committed Dec 27, 2023
1 parent 85d4e76 commit b147b56
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 4 additions & 0 deletions dwds/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 21.0.0+1

- Fix a null cast error when debugging a `Class` from VS Code. - [#2303](https://github.com/dart-lang/webdev/pull/2303)

## 21.0.0

- Update Dart SDK constraint to `>=3.2.0-36.0.dev <4.0.0`. - [#2207](https://github.com/dart-lang/webdev/pull/2207)
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 b147b56

Please sign in to comment.