dart-sdk/tests/language_2/nested_generic_closure_test.dart
Régis Crelier 390c80234a [VM generic functions] Properly instantiate generic signatures by providing the
number of free function type parameters.
Add test and mark status files.

Change-Id: I081de7674693c5ac2071a33948d25aadfc65f4ae
Reviewed-on: https://dart-review.googlesource.com/13901
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2017-10-16 21:57:05 +00:00

36 lines
1 KiB
Dart

// Copyright (c) 2017, 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.
// VMOptions=--reify-generic-functions
import 'package:expect/expect.dart';
void foo(F f<F>(F f)) {}
B bar<B>(B g<F>(F f)) => null;
Function baz<B>() {
B foo<F>(F f) => null;
return foo;
}
class C<T> {
void foo(F f<F>(T t, F f)) => null;
B bar<B>(B g<F>(T t, F f)) => null;
Function baz<B>() {
B foo<F>(T t, F f) => null;
return foo;
}
}
main() {
Expect.equals("(<F>(F) => F) => void", foo.runtimeType.toString());
Expect.equals("<B>(<F>(F) => B) => B", bar.runtimeType.toString());
Expect.equals("<F>(F) => int", baz<int>().runtimeType.toString());
var c = new C<bool>();
Expect.equals("(<F>(bool, F) => F) => void", c.foo.runtimeType.toString());
Expect.equals("<B>(<F>(bool, F) => B) => B", c.bar.runtimeType.toString());
Expect.equals("<F>(bool, F) => int", c.baz<int>().runtimeType.toString());
}