Skip to content

Commit 46c9c29

Browse files
jensjohaCommit Queue
authored and
Commit Queue
committed
[vm] Fix crash when expression evaluating with extension type with type parameter is available
Fixes #59653 Tested: Manually; added pkg/vm_service/test/issue_59653_test.dart and existing tests / CI. Change-Id: I0969720c4d7c50e8756406477abe791891877abb Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/405381 Commit-Queue: Jens Johansen <[email protected]> Reviewed-by: Alexander Markov <[email protected]> Reviewed-by: Derek Xu <[email protected]>
1 parent 663c55b commit 46c9c29

File tree

3 files changed

+73
-0
lines changed

3 files changed

+73
-0
lines changed

pkg/pkg.status

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ vm_service/test/issue_27287_test: SkipByDesign # Debugger is disabled in AOT mod
163163
vm_service/test/issue_30555_test: SkipByDesign # Debugger is disabled in AOT mode.
164164
vm_service/test/issue_56911_test: SkipByDesign # Debugger is disabled in AOT mode.
165165
vm_service/test/issue_57040_test: SkipByDesign # Debugger is disabled in AOT mode.
166+
vm_service/test/issue_59653_test: SkipByDesign # Debugger is disabled in AOT mode.
166167
vm_service/test/issue_59661_test: SkipByDesign # Debugger is disabled in AOT mode.
167168
vm_service/test/kill_paused_test: SkipByDesign # Debugger is disabled in AOT mode.
168169
vm_service/test/library_dependency_test: SkipByDesign # Uses 'dart:mirrors' library.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'dart:developer';
6+
import 'common/service_test_common.dart';
7+
import 'common/test_helper.dart';
8+
9+
// AUTOGENERATED START
10+
//
11+
// Update these constants by running:
12+
//
13+
// dart pkg/vm_service/test/update_line_numbers.dart pkg/vm_service/test/issue_59653_test.dart
14+
//
15+
const LINE_A = 36;
16+
// AUTOGENERATED END
17+
18+
abstract interface class SharedTypeStructure {}
19+
20+
extension type SharedTypeSchemaView<TypeStructure extends SharedTypeStructure>(
21+
TypeStructure _typeStructure) implements Object {}
22+
23+
class C extends SharedTypeStructure {
24+
@override
25+
String toString() => 'C!';
26+
}
27+
28+
class ClassWithTypeAnalyzer<TypeStructure extends SharedTypeStructure> {
29+
SharedTypeSchemaView<TypeStructure> dispatchExpression(
30+
SharedTypeSchemaView<TypeStructure> schema,
31+
) {
32+
return schema;
33+
}
34+
35+
void analyzeExpression(SharedTypeSchemaView<TypeStructure> schema) {
36+
debugger(); // LINE_A
37+
}
38+
}
39+
40+
void code() {
41+
final classWithTypeAnalyzer = ClassWithTypeAnalyzer<C>();
42+
classWithTypeAnalyzer.analyzeExpression(SharedTypeSchemaView(C()));
43+
}
44+
45+
final tests = <IsolateTest>[
46+
hasStoppedAtBreakpoint,
47+
stoppedAtLine(LINE_A),
48+
testExpressionEvaluationAndAvailableVariables('analyzeExpression', [
49+
'this',
50+
'schema',
51+
], [
52+
('1', '1'),
53+
('dispatchExpression(schema).toString()', 'C!'),
54+
]),
55+
];
56+
57+
void main([args = const <String>[]]) => runIsolateTests(
58+
args,
59+
tests,
60+
'issue_59653_test.dart',
61+
testeeConcurrent: code,
62+
pauseOnStart: false,
63+
pauseOnExit: true,
64+
);

runtime/vm/compiler/frontend/kernel_translation_helper.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3586,6 +3586,14 @@ void TypeTranslator::BuildTypeParameterType() {
35863586
const intptr_t class_type_parameter_count =
35873587
active_class_->klass->NumTypeParameters();
35883588
if (class_type_parameter_count > parameter_index) {
3589+
if (H.GetExpressionEvaluationClass().ptr() ==
3590+
active_class_->klass->ptr()) {
3591+
ASSERT(H.GetExpressionEvaluationClass().NumTypeParameters() ==
3592+
active_class_->klass->NumTypeParameters());
3593+
result_ = H.GetExpressionEvaluationRealClass().TypeParameterAt(
3594+
parameter_index, nullability);
3595+
return;
3596+
}
35893597
result_ =
35903598
active_class_->klass->TypeParameterAt(parameter_index, nullability);
35913599
return;

0 commit comments

Comments
 (0)