Add test case for type with partial parameterization by method type parameter

BUG=
R=eernst@google.com

Review URL: https://codereview.chromium.org/2257813003 .
This commit is contained in:
Stephen Adams 2016-08-23 10:45:22 -07:00
parent cdb7b03ee0
commit 3cec399d2c
2 changed files with 21 additions and 0 deletions

View file

@ -22,6 +22,8 @@ C<T> f1<T>(T t) => new C<T>(t);
List<T> f2<T>(T t) => <T>[t];
Map<T, String> f3<T>(T t) => <T, String>{t: 'hi'};
main() {
C c = f1<int>(42);
List i = f2<String>("Hello!");
@ -29,4 +31,9 @@ main() {
Expect.isTrue(i is List<String> && i is List<int>); // List<dynamic>.
Expect.equals(c.e, 42);
Expect.equals(i[0], "Hello!");
Map m1 = f3<int>(1);
Expect.isTrue(m1 is Map<int, String> && m1 is Map<String, String>);
Expect.isFalse(m1 is Map<int, int>);
Expect.equals('hi', m1[1]);
}

View file

@ -33,6 +33,13 @@ class TypeValue<X> {
Type f8<T>() => new TypeValue<List<T>>().value;
bool f9<T>(Object o) => o is Map<T, String>;
class IsMap<A> {
@NoInline()
bool check<B>(o) => o is Map<A, B>;
}
main() {
String s = "Hello!";
List<String> ss = <String>[s];
@ -50,4 +57,11 @@ main() {
Expect.equals(f6<int>(ss), ss); // `as List<dynamic>` succeeds.
Expect.throws(() => f7<int>(), (e) => e is TypeError);
Expect.equals(f8<int>(), List); // Returns `List<dynamic>`.
Expect.isTrue(f9<int>(<int,String>{}));
Expect.isTrue(f9<int>(<bool,String>{})); // `is Map<dynamic, String>` is true.
Expect.isFalse(f9<int>(<int,int>{}));
Expect.isTrue(new IsMap<int>().check<String>(<int,String>{}));
Expect.isTrue(new IsMap<int>().check<int>(<int,String>{}));
}