blob: 5dd8202a53427ce759a59e3fc5a7b6feefebfe3e [file] [log] [blame]
// Copyright (c) 2021, 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.
/// @assertion In general, a non-generic type alias is just expanded to its
/// aliased type, then the tear-off happens on that type. Tearing off
/// [IntList.filled] will act like tearing off [List<int>.filled], it
/// automatically instantiates the class type parameter to the specified type.
///
/// @description Checks that tearing-off automatically instantiates the class
/// type parameter to the specified type for non-generic type alias. Test
/// negative static case for [List<int>].
/// @author iarkh@unipro.ru
// SharedOptions=--enable-experiment=constructor-tearoffs
typedef MyList = List<int>;
main() {
MyList<int>.filled;
// ^
// [analyzer] unspecified
// [cfe] unspecified
MyList<String>.filled;
// ^
// [analyzer] unspecified
// [cfe] unspecified
MyList<dynamic>.filled;
// ^
// [analyzer] unspecified
// [cfe] unspecified
MyList<Object?>.filled;
// ^
// [analyzer] unspecified
// [cfe] unspecified
MyList<Never>.filled;
// ^
// [analyzer] unspecified
// [cfe] unspecified
var v = MyList.filled;
v(1, 1.5);
// ^
// [analyzer] unspecified
// [cfe] unspecified
v(1, null);
// ^
// [analyzer] unspecified
// [cfe] unspecified
v(2, "");
// ^
// [analyzer] unspecified
// [cfe] unspecified
}