mirror of
https://github.com/dart-lang/sdk
synced 2024-09-18 20:11:19 +00:00
d49d5a96f7
The rti-need of an instantiation is not the same as the rti-need of the instantiated generic function. The generic function might not use its type arguments but the instantiation still needs the type arguments for equality. dart2js implements generic function instantiation by creating instances of a helper class that is a subclass of `Closure`. The helper class needs its type parameters since they are used in `==` and `toString()` methods. The fix for #47054 is to add the dependency of the helper class type parameters on the instantiation type arguments. Change-Id: I9ecb18e1b61a8ad6549f35b572476b1ed7ebb88d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212037 Reviewed-by: Sigmund Cherem <sigmund@google.com> Reviewed-by: Mayank Patke <fishythefish@google.com> Commit-Queue: Stephen Adams <sra@google.com>
24 lines
853 B
Dart
24 lines
853 B
Dart
// Copyright (c) 2018, 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.
|
|
|
|
// dart2jsOptions=--strong --omit-implicit-checks --lax-runtime-type-to-string
|
|
|
|
import 'package:expect/expect.dart';
|
|
|
|
main() {
|
|
T id<T>(T t) => t;
|
|
int Function(int) x = id;
|
|
var toString = "${x.runtimeType}";
|
|
if ('$Object' == 'Object') {
|
|
// `true` if non-minified.
|
|
// The signature of `id` is not otherwise needed so the instantiation
|
|
// wrapper doesn't have a function type.
|
|
// The type parameter is present since it is required because `==`
|
|
// distinguishes instantiations of the same generic function with different
|
|
// types.
|
|
Expect.equals("Instantiation1<int>", toString);
|
|
}
|
|
print(toString);
|
|
}
|