// Copyright (c) 2016, 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=--no-reify-generic-functions /// Dart test on the usage of method type arguments in object creation. With /// '--no-reify-generic-functions', the type argument is /// available at runtime, but erased to `dynamic`. library generic_methods_new_test; import "package:expect/expect.dart"; class C { E e; C(this.e); } C f1(T t) => new C(t); List f2(T t) => [t]; Map f3(T t) => {t: 'hi'}; main() { C c = f1(42); List i = f2("Hello!"); Expect.isTrue(c is C && c is C); // C. Expect.isTrue(i is List && i is List); // List. Expect.equals(c.e, 42); Expect.equals(i[0], "Hello!"); Map m1 = f3(1); Expect.isTrue(m1 is Map && m1 is Map); Expect.isFalse(m1 is Map); Expect.equals('hi', m1[1]); }