Skip to content

Commit a12368f

Browse files
authored
Fix cast error when debugging from VSCode (#2303)
1 parent b339a50 commit a12368f

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

dwds/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
- Restructure `LoadStrategy` to provide build settings. - [#2270](https://github.com/dart-lang/webdev/pull/2270)
33
- Add `FrontendServerLegacyStrategyProvider` and update bootstrap generation logic for `LegacyStrategy` - [#2285](https://github.com/dart-lang/webdev/pull/2285)
44
- Tolerate failures to detect a dart execution context. - [#2286](https://github.com/dart-lang/webdev/pull/2286)
5+
- Fix a null cast error when debugging a `Class` from VS Code. - [#2303](https://github.com/dart-lang/webdev/pull/2303)
56

67
## 22.1.0
78
- Update `package:vm_service` constraint to `^13.0.0`. - [#2265](https://github.com/dart-lang/webdev/pull/2265)

dwds/lib/src/debugging/classes.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,9 @@ class ClassHelper extends Domain {
9696
throw ChromeDebugException(e.json, evalContents: expression);
9797
}
9898

99-
final classDescriptor = result.value as Map<String, dynamic>;
99+
final classDescriptor = _mapify(result.value);
100100
final methodRefs = <FuncRef>[];
101-
final methodDescriptors =
102-
classDescriptor['methods'] as Map<String, dynamic>;
101+
final methodDescriptors = _mapify(classDescriptor['methods']);
103102
methodDescriptors.forEach((name, descriptor) {
104103
final methodId = 'methods|$classId|$name';
105104
methodRefs.add(
@@ -118,7 +117,7 @@ class ClassHelper extends Domain {
118117
});
119118
final fieldRefs = <FieldRef>[];
120119

121-
final fieldDescriptors = classDescriptor['fields'] as Map<String, dynamic>;
120+
final fieldDescriptors = _mapify(classDescriptor['fields']);
122121
fieldDescriptors.forEach((name, descriptor) {
123122
final classMetaData = ClassMetaData(
124123
runtimeKind: RuntimeObjectKind.type,
@@ -168,4 +167,7 @@ class ClassHelper extends Domain {
168167
superClass: superClassRef,
169168
);
170169
}
170+
171+
Map<String, dynamic> _mapify(dynamic map) =>
172+
(map as Map<String, dynamic>?) ?? <String, dynamic>{};
171173
}

0 commit comments

Comments
 (0)