dart-sdk/pkg/vm_service/test/regress_48279_test.dart
Alexander Markov 0cf751215e [vm] Correct token position for AssertAssignable in implicit field setters
The real token position is required in case debugger stopped on
an exception thrown from AssertAssignable and trying to evaluate
an expression which uses receiver. Without token position all local
variables (including receiver) are considered out of scope
(as frame's token position is out of range).

TEST=runtime/observatory/tests/service/regress_48279_test.dart
Fixes https://github.com/dart-lang/sdk/issues/48279

Change-Id: Idb6a8e12185367ceac2034269b8f046272384006
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231748
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-02-08 19:28:36 +00:00

46 lines
1.4 KiB
Dart

// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// This test verifies that generic type argument ('T') can be evaluated
// when stopped on an exception which is thrown during type check in
// the implicit field setter.
// Regression test for https://github.com/dart-lang/sdk/issues/48279.
import 'package:test/test.dart';
import 'package:vm_service/vm_service.dart';
import 'common/service_test_common.dart';
import 'common/test_helper.dart';
class A<T, U, V> {
List<T> foo = [];
}
testeeMain() {
A<num, Object, Object> object = A<int, String, String>();
object.foo = <double>[];
}
var tests = <IsolateTest>[
hasStoppedWithUnhandledException,
(VmService? service, IsolateRef? isolateRef) async {
print("We stopped!");
final isolateId = isolateRef!.id!;
final stack = await service!.getStack(isolateId);
final topFrame = stack.frames![0];
expect(topFrame.function!.name, equals('foo='));
final result = await service.evaluateInFrame(isolateId, 0, 'T');
print(result);
expect((result as InstanceRef).name, equals("int"));
}
];
main(args) => runIsolateTests(
args,
tests,
'regress_48279_test.dart',
pause_on_unhandled_exceptions: true,
testeeConcurrent: testeeMain,
);