575a8f8381
Until now the subtype-test cache mechanism did not work (i.e. could return the wrong result) for partially instantiated generic closures. Additionally, closures which close over generic methods were always handled in runtime. This caused a servere performance regression for any code hitting this (e.g. code which uses `package:stack_trace`). Fixes https://github.com/dart-lang/sdk/issues/34051 Fixes https://github.com/dart-lang/sdk/issues/34054 Change-Id: Idb73e6f348c2fe0c737f42c57009f5f7a636c9a6 Reviewed-on: https://dart-review.googlesource.com/68369 Commit-Queue: Martin Kustermann <kustermann@google.com> Reviewed-by: Régis Crelier <regis@google.com>
25 lines
704 B
Dart
25 lines
704 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.
|
|
|
|
import "package:expect/expect.dart";
|
|
|
|
main() {
|
|
// This is a regression test for http://dartbug.com/34051.
|
|
|
|
// Warm-up the subtype cache with a "(int) -> int" closure.
|
|
Expect.isTrue(fooClosure(partialInst(gen)));
|
|
|
|
// Test that the generic "(T) -> T" closure raises a type error.
|
|
Expect.throwsTypeError(() => fooClosure(gen));
|
|
}
|
|
|
|
FI partialInst(FI arg) => arg;
|
|
|
|
T gen<T>(T a) => a;
|
|
|
|
final dynamic fooClosure = foo;
|
|
bool foo(FI arg) => arg is FI;
|
|
|
|
typedef FI = int Function(int);
|