Skip to content

Commit 90088a3

Browse files
zichanggcommit-bot@chromium.org
authored andcommitted
[vm/kernel] Remove Function parameters from Local type parameters
When calling SetupFunctionParameters, Function type arguments were copied into local type parameters. Local type parameters = previous type parameter + function type parameters. At BuildTypeParameterType(), local type parameters contains duplicated type parameter from function, which ends up with returning wrong type. Bug: dart-lang#37382 Change-Id: I8f486b0b9a9120845349fe1734bbfcc35f1126a1 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/108501 Reviewed-by: Alexander Markov <[email protected]> Commit-Queue: Zichang Guo <[email protected]>
1 parent f743594 commit 90088a3

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright (c) 2019, 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 'package:expect/expect.dart';
6+
7+
class A<X, Y> {
8+
R f<R>(R Function<S, T>(A<S, T>) t) => t<X, Y>(this);
9+
}
10+
11+
main() {
12+
A<num, num> a = A<int, int>();
13+
Expect.equals(a.f.runtimeType.toString(), '<R>(<S, T>(A<S, T>) => R) => R');
14+
}

runtime/vm/compiler/frontend/kernel_translation_helper.cc

+1-3
Original file line numberDiff line numberDiff line change
@@ -3124,9 +3124,7 @@ void TypeTranslator::SetupFunctionParameters(
31243124
function_node_helper->SetJustRead(FunctionNodeHelper::kTypeParameters);
31253125
}
31263126

3127-
ActiveTypeParametersScope scope(
3128-
active_class_, &function,
3129-
TypeArguments::Handle(Z, function.type_parameters()), Z);
3127+
ActiveTypeParametersScope scope(active_class_, function, Z);
31303128

31313129
function_node_helper->ReadUntilExcluding(
31323130
FunctionNodeHelper::kPositionalParameters);

0 commit comments

Comments
 (0)