[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: https://github.com/dart-lang/sdk/issues/37382
Change-Id: I8f486b0b9a9120845349fe1734bbfcc35f1126a1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/108501
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Zichang Guo <zichangguo@google.com>
This commit is contained in:
Zichang Guo 2019-07-10 14:43:43 +00:00 committed by commit-bot@chromium.org
parent f743594375
commit 90088a386b
2 changed files with 15 additions and 3 deletions

View file

@ -0,0 +1,14 @@
// Copyright (c) 2019, 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.
import 'package:expect/expect.dart';
class A<X, Y> {
R f<R>(R Function<S, T>(A<S, T>) t) => t<X, Y>(this);
}
main() {
A<num, num> a = A<int, int>();
Expect.equals(a.f.runtimeType.toString(), '<R>(<S, T>(A<S, T>) => R) => R');
}

View file

@ -3124,9 +3124,7 @@ void TypeTranslator::SetupFunctionParameters(
function_node_helper->SetJustRead(FunctionNodeHelper::kTypeParameters);
}
ActiveTypeParametersScope scope(
active_class_, &function,
TypeArguments::Handle(Z, function.type_parameters()), Z);
ActiveTypeParametersScope scope(active_class_, function, Z);
function_node_helper->ReadUntilExcluding(
FunctionNodeHelper::kPositionalParameters);