// 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. // SharedOptions=--enable-experiment=generic-metadata // Check that metadata constructor invocations can have type arguments. @A(0) library generic_metadata_test; @A(0) import "dart:core"; @A(0) export "dart:core"; // The annotation to use. class A { final T value; const A(this.value); } // Annotations on various declarations. // Library declarations. @A(0) const c = 0; @A(0) final f = 0; @A(0) void mp(@A(0) Object x, [@A(0) int y = 0]) {} @A(0) void mn(@A(0) Object x, {@A(0) int y = 0}) {} @A(0) int get g => 0; @A(0) void set s(@A(0) int x) {} // Class declaration and members. @A(0) class C<@A(0) T> { final value; // Constructor and initializing formal. @A(0) const C(@A(0) this.value); @A(0) C.genRed(@A(0) int x) : this(x); @A(0) factory C.fac(@A(0) int x) => C(x); @A(0) factory C.facRed(@A(0) int x) = C; // Instance (virtual) declartions. @A(0) final f = 0; @A(0) void mp(@A(0) Object x, [@A(0) int y = 0]) {} @A(0) void mn(@A(0) Object x, {@A(0) int y = 0}) {} @A(0) int get g => 0; @A(0) void set s(@A(0) int x) {} @A(0) int operator +(@A(0) int x) => x; // Static declartions. @A(0) static const sc = C(0); @A(0) static final sf = C(0); @A(0) static void smp(@A(0) Object x, [@A(0) int y = 0]) {} @A(0) static void smn(@A(0) Object x, {@A(0) int y = 0}) {} @A(0) static int get sg => 0; @A(0) static void set ss(@A(0) int x) {} } @A(0) abstract class AC<@A(0) T> { // Instance (virtual) declartions. @A(0) abstract final f; @A(0) void mp(@A(0) Object x, [@A(0) int y = 0]); @A(0) void mn(@A(0) Object x, {@A(0) int y = 0}); @A(0) int get g; @A(0) void set s(@A(0) int x); @A(0) int operator +(@A(0) int x); } @A(0) extension E<@A(0) T> on T { // Instance extension member declartions. @A(0) void mp(@A(0) Object x, [@A(0) int y = 0]) {} @A(0) void mn(@A(0) Object x, {@A(0) int y = 0}) {} @A(0) int get g => 0; @A(0) void set s(@A(0) int x) {} @A(0) int operator +(@A(0) int x) => x; // Static declartions. @A(0) static const sc = C(0); @A(0) static final sf = C(0); @A(0) static void smp(@A(0) Object x, [@A(0) int y = 0]) {} @A(0) static void smn(@A(0) Object x, {@A(0) int y = 0}) {} @A(0) static int get sg => 0; @A(0) static void set ss(@A(0) int x) {} } @A(0) mixin M<@A(0) T> { // Instance member declartions. @A(0) final f = 0; @A(0) void mp(@A(0) Object x, [@A(0) int y = 0]) {} @A(0) void mn(@A(0) Object x, {@A(0) int y = 0}) {} @A(0) int get g => 0; @A(0) void set s(@A(0) int x) {} @A(0) int operator +(@A(0) int x) => x; // Static declartions. @A(0) static const sc = C(0); @A(0) static final sf = C(0); @A(0) static void smp(@A(0) Object x, [@A(0) int y = 0]) {} @A(0) static void smn(@A(0) Object x, {@A(0) int y = 0}) {} @A(0) static int get sg => 0; @A(0) static void set ss(@A(0) int x) {} } @A(0) enum En { @A(0) foo } @A(0) typedef F<@A(0) T> = int Function<@A(0) X>(@A(0) int); void main() { // Function body declarations. @A(0) const c = 0; @A(0) final f = 0; @A(0) void mp(@A(0) Object x, [@A(0) int y = 0]) {} @A(0) void mn(@A(0) Object x, {@A(0) int y = 0}) {} @A(0) void Function<@A(0) X>(@A(0) int y)? fv = null; // Recursive annotations. @A(0) int)?>(null) var x = 0; mn(c); mp(f); fv?.call(x); }