blob: 873a429b1ba4529ac1891fc81d02dc6be6338f69 [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 For an expression of the form e<typeArgs>, which is not followed
/// by an argument list (that would turn it into a generic function invocation),
/// the meaning of e<typeArgs> depends on the expression e:
/// ...
/// - Otherwise the expression is a compile-time error.
/// This includes e having the static type dynamic or Function. We do not
/// support implicit or explicit instantiation of functions where we do not know
/// the number and bounds of the type parameters at compile-time.
/// It also includes e denoting a constructor. (We reserve this syntax for
/// denoting instantiation of generic constructors, should the language add
/// generic constructors in the future. Instead just write (<typeArgs> or
/// C<typeArgs>.name.)
/// @description Checks that it is a compile-time error if e has a type Function
/// @author
// SharedOptions=--enable-experiment=constructor-tearoffs
class C {
static T foo<T>(T t) => t;
T bar<T>(T t) => t;
main() {
Function func1 =;
var c1 = func1<int>;
// ^^^^^
// [analyzer] unspecified
// [cfe] unspecified
Function func2 = C().bar;
var c2 = func2<int>;
// ^^^^^
// [analyzer] unspecified
// [cfe] unspecified