From 90088a386b2f1457e8579ff7197df85f90677fc4 Mon Sep 17 00:00:00 2001 From: Zichang Guo Date: Wed, 10 Jul 2019 14:43:43 +0000 Subject: [PATCH] [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 Commit-Queue: Zichang Guo --- runtime/tests/vm/dart/regress_37382_test.dart | 14 ++++++++++++++ .../compiler/frontend/kernel_translation_helper.cc | 4 +--- 2 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 runtime/tests/vm/dart/regress_37382_test.dart diff --git a/runtime/tests/vm/dart/regress_37382_test.dart b/runtime/tests/vm/dart/regress_37382_test.dart new file mode 100644 index 00000000000..e0d818cc74d --- /dev/null +++ b/runtime/tests/vm/dart/regress_37382_test.dart @@ -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 { + R f(R Function(A) t) => t(this); +} + +main() { + A a = A(); + Expect.equals(a.f.runtimeType.toString(), '((A) => R) => R'); +} diff --git a/runtime/vm/compiler/frontend/kernel_translation_helper.cc b/runtime/vm/compiler/frontend/kernel_translation_helper.cc index 938a22ac1af..ea6cf244105 100644 --- a/runtime/vm/compiler/frontend/kernel_translation_helper.cc +++ b/runtime/vm/compiler/frontend/kernel_translation_helper.cc @@ -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);