dart-sdk/runtime/observatory
Martin Kustermann 587e6308bf [vm] Fix expression evaluation in context of closures
When evaluating an expressino at a breakpoint that's inside a closure,
the closure may refer to anything it closes over. That includes the
`this` from an enclosing method.

So depending on whether a closure's parent chain is an instance method
or a static method, the expression evaluation function is going to be an
instance method or a static method.

=> We walk up the parent chain to determine the correct enclosing class.
=> This avoids making a Type object with a cid from a top-level class (see [0])

Handling this correctly will now try to get the `this` when invoking an
eval function that has an enclosing instance method. Though we may often
have "<optimized out>" the `this` (e.g. due to not capturing it in
closure context chain).

=> We still allow running the expression evaluation function in this
case, but only if the expression being evaluated doesn't access `this`.

A similar issue occurs when trying to use variables in the eval
expression that the closure didn't capture. This results in a confusing
CFE compile-time error. This is a separate issue and tracked in [1].

=> We update the test to distinuish the cases that this CL makes passing
and those that are failing due to [1].

Fixes [0] https://github.com/dart-lang/sdk/issues/53061
See also [1] https://github.com/dart-lang/sdk/issues/53087

TEST=Fixes part of service/evaluate_activation_test failures

Change-Id: I3bb24e7338c7b2f12d5340311d944cb59a455641
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/317540
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-08-04 11:07:46 +00:00
..
bin Replace Uri.scheme == with Uri.isScheme 2022-02-08 21:38:57 +00:00
lib [vm, service] Fix discrepancy between VM generating kind _TypeParameters and service.md claiming the existence of kind TypeParameters. 2023-08-01 20:34:21 +00:00
tests [vm] Fix expression evaluation in context of closures 2023-08-04 11:07:46 +00:00
tool Change references to "dartfmt" in runtime and tools to "dart format". 2021-10-01 18:16:27 +00:00
web Spelling runtime observatory 2023-01-20 14:29:08 +00:00
.gitignore [observatory] remove unused_imports and some unused variables 2023-02-15 16:49:58 +00:00
analysis_options.yaml Revert "Separate out UNUSED_ELEMENT_PARAMETER from UNUSED_ELEMENT" 2023-07-24 16:25:07 +00:00
BUILD.gn [build] Use relative paths. 2023-03-08 22:10:42 +00:00
HACKING.md [ VM / Service / Observatory ] The VM service now requires an authentication code by default. 2019-04-09 22:57:29 +00:00
observatory_sources.gni [ Observatory ] Remove footer with dead / irrelevant links 2021-10-11 23:30:24 +00:00
pubspec.yaml [observatory] remove unused_imports and some unused variables 2023-02-15 16:49:58 +00:00
update_sources.py [infra] Migrate scripts to python3 2021-04-15 10:10:20 +00:00