mirror of
https://github.com/dart-lang/sdk
synced 2024-09-06 00:59:09 +00:00
[dart2js] Fix scope visitor missing not visiting structural parameter default type.
By not visiting the default type of structural type parameters, the scope visitor was not registering the T type parameter as being potentially needed for RTI. So then the SSA RTI builder did not have the necessary scope info to create the RTI objects for the closures' signatures. Fixed: 54451 Change-Id: I96f2af985bd176e71a6779fd27b09efdd76fe6cf Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/343660 Commit-Queue: Nate Biggs <natebiggs@google.com> Reviewed-by: Stephen Adams <sra@google.com>
This commit is contained in:
parent
022f4ad837
commit
7e5ce1f688
|
@ -403,6 +403,9 @@ class ScopeModelBuilder extends ir.VisitorDefault<EvaluationComplexity>
|
|||
@override
|
||||
EvaluationComplexity visitStructuralParameter(
|
||||
ir.StructuralParameter typeParameter) {
|
||||
// Visit the default type to register any necessary type parameters that RTI
|
||||
// might need if the associated function is used as a generic tear off.
|
||||
visitNode(typeParameter.defaultType);
|
||||
return const EvaluationComplexity.constant();
|
||||
}
|
||||
|
||||
|
|
25
tests/web/regress/issue/54451_test.dart
Normal file
25
tests/web/regress/issue/54451_test.dart
Normal file
|
@ -0,0 +1,25 @@
|
|||
// Copyright (c) 2023, 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.
|
||||
|
||||
// Tests that the bounds for structural parameters of a Function type are
|
||||
// visited and any type variables RTI might need are registered.
|
||||
|
||||
class A<T> {
|
||||
void foo1() {
|
||||
void bar1<Z extends void Function<Y extends T>()>() {}
|
||||
print(bar1.runtimeType); // Crashes compiler if A.T is not accessible.
|
||||
}
|
||||
}
|
||||
|
||||
extension<T> on T {
|
||||
void foo2() {
|
||||
void bar2<Z extends void Function<Y extends T>()>() {}
|
||||
print(bar2.runtimeType); // Crashes compiler if T is not accessible.
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
A<int>().foo1();
|
||||
1.foo2();
|
||||
}
|
Loading…
Reference in a new issue