From 8ea06ae96e5bc2c468a69d0efe9144e73be070c0 Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Tue, 12 Dec 2023 17:14:15 -0800 Subject: [PATCH 1/2] Fix cast error --- dwds/lib/src/debugging/classes.dart | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/dwds/lib/src/debugging/classes.dart b/dwds/lib/src/debugging/classes.dart index 7f4de281d..3b939ec99 100644 --- a/dwds/lib/src/debugging/classes.dart +++ b/dwds/lib/src/debugging/classes.dart @@ -96,10 +96,9 @@ class ClassHelper extends Domain { throw ChromeDebugException(e.json, evalContents: expression); } - final classDescriptor = result.value as Map; + final classDescriptor = _mapify(result.value); final methodRefs = []; - final methodDescriptors = - classDescriptor['methods'] as Map; + final methodDescriptors = _mapify(classDescriptor['methods']); methodDescriptors.forEach((name, descriptor) { final methodId = 'methods|$classId|$name'; methodRefs.add( @@ -118,7 +117,7 @@ class ClassHelper extends Domain { }); final fieldRefs = []; - final fieldDescriptors = classDescriptor['fields'] as Map; + final fieldDescriptors = _mapify(classDescriptor['fields']); fieldDescriptors.forEach((name, descriptor) { final classMetaData = ClassMetaData( runtimeKind: RuntimeObjectKind.type, @@ -168,4 +167,7 @@ class ClassHelper extends Domain { superClass: superClassRef, ); } + + Map _mapify(dynamic map) => + (map as Map?) ?? {}; } From 780d5791c3c861048c655725d75baa5ac9871df0 Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Tue, 12 Dec 2023 17:17:34 -0800 Subject: [PATCH 2/2] Update CHANGELOG --- dwds/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/dwds/CHANGELOG.md b/dwds/CHANGELOG.md index 77f341200..da911f1d0 100644 --- a/dwds/CHANGELOG.md +++ b/dwds/CHANGELOG.md @@ -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)