f205141a42
Change-Id: Ib798b9573ee8ec924f87104684934785fadc8189 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/141702 Auto-Submit: Bob Nystrom <rnystrom@google.com> Reviewed-by: Leaf Petersen <leafp@google.com> Reviewed-by: Erik Ernst <eernst@google.com> Reviewed-by: Nicholas Shahan <nshahan@google.com> Commit-Queue: Bob Nystrom <rnystrom@google.com>
50 lines
1.2 KiB
Dart
50 lines
1.2 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.
|
|
|
|
import 'package:expect/expect.dart';
|
|
|
|
void foo(F f<F>(F f)) {}
|
|
|
|
B bar<B>(B g<F>(F f)) => throw "uncalled";
|
|
|
|
Function baz<B>() {
|
|
B foo<F>(B b, F f) => throw "uncalled";
|
|
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)) => throw "uncalled";
|
|
Function baz<B>() {
|
|
B foo<F>(T t, F f) => throw "uncalled";
|
|
return foo;
|
|
}
|
|
}
|
|
|
|
main() {
|
|
// Check the run-time type of the functions with generic parameters.
|
|
|
|
Expect.type<void Function(X Function<X>(X))>(foo);
|
|
|
|
Expect.isTrue(bar is X1 Function<X1>(X1 Function<X2>(X2)));
|
|
|
|
Expect.isTrue(baz<int>() is int Function<X1>(int, X1));
|
|
Expect.isTrue(baz<Object>() is Object Function<X1>(Object, X1));
|
|
Expect.isTrue(baz<Null>() is Null Function<X1>(Null, X1));
|
|
|
|
void testC<T>() {
|
|
var c = new C<T>();
|
|
|
|
Expect.type<void Function(F Function<F>(T, F))>(c.foo);
|
|
|
|
Expect.isTrue(c.bar is X1 Function<X1>(X1 Function<X2>(T, X2)));
|
|
|
|
Expect.isTrue(c.baz<int>() is int Function<X1>(T, X1));
|
|
}
|
|
|
|
testC<bool>();
|
|
testC<Object>();
|
|
testC<Null>();
|
|
}
|