36f0c3209a
Change-Id: I7cfc51c22e98cc368ec59af3a7125f1d0c0419d8 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/407140 Auto-Submit: Bob Nystrom <rnystrom@google.com> Reviewed-by: Lasse Nielsen <lrn@google.com> Commit-Queue: Lasse Nielsen <lrn@google.com>
236 lines
4.2 KiB
Dart
236 lines
4.2 KiB
Dart
// 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.
|
|
|
|
// Check that metadata constructor invocations can have type arguments.
|
|
|
|
@A<int>(0)
|
|
library generic_metadata_test;
|
|
|
|
@A<int>(0)
|
|
import "dart:core";
|
|
|
|
@A<int>(0)
|
|
export "dart:core";
|
|
|
|
// The annotation to use.
|
|
class A<T> {
|
|
final T value;
|
|
|
|
const A(this.value);
|
|
}
|
|
|
|
// Annotations on various declarations.
|
|
|
|
// Library declarations.
|
|
@A<int>(0)
|
|
const c = 0;
|
|
|
|
@A<int>(0)
|
|
final f = 0;
|
|
|
|
@A<int>(0)
|
|
void mp(@A<int>(0) Object x, [@A<int>(0) int y = 0]) {}
|
|
|
|
@A<int>(0)
|
|
void mn(@A<int>(0) Object x, {@A<int>(0) int y = 0}) {}
|
|
|
|
@A<int>(0)
|
|
int get g => 0;
|
|
|
|
@A<int>(0)
|
|
void set s(@A<int>(0) int x) {}
|
|
|
|
// Class declaration and members.
|
|
@A<int>(0)
|
|
class C<@A<int>(0) T> {
|
|
final value;
|
|
|
|
// Constructor and initializing formal.
|
|
@A<int>(0)
|
|
const C(@A<int>(0) this.value);
|
|
|
|
@A<int>(0)
|
|
C.genRed(@A<int>(0) int x) : this(x);
|
|
|
|
@A<int>(0)
|
|
factory C.fac(@A<int>(0) int x) => C(x);
|
|
|
|
@A<int>(0)
|
|
factory C.facRed(@A<int>(0) int x) = C;
|
|
|
|
// Instance (virtual) declarations.
|
|
@A<int>(0)
|
|
final f = 0;
|
|
|
|
@A<int>(0)
|
|
void mp(@A<int>(0) Object x, [@A<int>(0) int y = 0]) {}
|
|
|
|
@A<int>(0)
|
|
void mn(@A<int>(0) Object x, {@A<int>(0) int y = 0}) {}
|
|
|
|
@A<int>(0)
|
|
int get g => 0;
|
|
|
|
@A<int>(0)
|
|
void set s(@A<int>(0) int x) {}
|
|
|
|
@A<int>(0)
|
|
int operator +(@A<int>(0) int x) => x;
|
|
|
|
// Static declarations.
|
|
@A<int>(0)
|
|
static const sc = C<int>(0);
|
|
|
|
@A<int>(0)
|
|
static final sf = C<int>(0);
|
|
|
|
@A<int>(0)
|
|
static void smp(@A<int>(0) Object x, [@A<int>(0) int y = 0]) {}
|
|
|
|
@A<int>(0)
|
|
static void smn(@A<int>(0) Object x, {@A<int>(0) int y = 0}) {}
|
|
|
|
@A<int>(0)
|
|
static int get sg => 0;
|
|
|
|
@A<int>(0)
|
|
static void set ss(@A<int>(0) int x) {}
|
|
}
|
|
|
|
@A<int>(0)
|
|
abstract class AC<@A<int>(0) T> {
|
|
// Instance (virtual) declarations.
|
|
@A<int>(0)
|
|
abstract final f;
|
|
|
|
@A<int>(0)
|
|
void mp(@A<int>(0) Object x, [@A<int>(0) int y = 0]);
|
|
|
|
@A<int>(0)
|
|
void mn(@A<int>(0) Object x, {@A<int>(0) int y = 0});
|
|
|
|
@A<int>(0)
|
|
int get g;
|
|
|
|
@A<int>(0)
|
|
void set s(@A<int>(0) int x);
|
|
|
|
@A<int>(0)
|
|
int operator +(@A<int>(0) int x);
|
|
}
|
|
|
|
@A<int>(0)
|
|
extension E<@A<int>(0) T> on T {
|
|
// Instance extension member declarations.
|
|
@A<int>(0)
|
|
void mp(@A<int>(0) Object x, [@A<int>(0) int y = 0]) {}
|
|
|
|
@A<int>(0)
|
|
void mn(@A<int>(0) Object x, {@A<int>(0) int y = 0}) {}
|
|
|
|
@A<int>(0)
|
|
int get g => 0;
|
|
|
|
@A<int>(0)
|
|
void set s(@A<int>(0) int x) {}
|
|
|
|
@A<int>(0)
|
|
int operator +(@A<int>(0) int x) => x;
|
|
|
|
// Static declarations.
|
|
@A<int>(0)
|
|
static const sc = C<int>(0);
|
|
|
|
@A<int>(0)
|
|
static final sf = C<int>(0);
|
|
|
|
@A<int>(0)
|
|
static void smp(@A<int>(0) Object x, [@A<int>(0) int y = 0]) {}
|
|
|
|
@A<int>(0)
|
|
static void smn(@A<int>(0) Object x, {@A<int>(0) int y = 0}) {}
|
|
|
|
@A<int>(0)
|
|
static int get sg => 0;
|
|
|
|
@A<int>(0)
|
|
static void set ss(@A<int>(0) int x) {}
|
|
}
|
|
|
|
@A<int>(0)
|
|
mixin M<@A<int>(0) T> {
|
|
// Instance member declarations.
|
|
@A<int>(0)
|
|
final f = 0;
|
|
|
|
@A<int>(0)
|
|
void mp(@A<int>(0) Object x, [@A<int>(0) int y = 0]) {}
|
|
|
|
@A<int>(0)
|
|
void mn(@A<int>(0) Object x, {@A<int>(0) int y = 0}) {}
|
|
|
|
@A<int>(0)
|
|
int get g => 0;
|
|
|
|
@A<int>(0)
|
|
void set s(@A<int>(0) int x) {}
|
|
|
|
@A<int>(0)
|
|
int operator +(@A<int>(0) int x) => x;
|
|
|
|
// Static declarations.
|
|
@A<int>(0)
|
|
static const sc = C<int>(0);
|
|
|
|
@A<int>(0)
|
|
static final sf = C<int>(0);
|
|
|
|
@A<int>(0)
|
|
static void smp(@A<int>(0) Object x, [@A<int>(0) int y = 0]) {}
|
|
|
|
@A<int>(0)
|
|
static void smn(@A<int>(0) Object x, {@A<int>(0) int y = 0}) {}
|
|
|
|
@A<int>(0)
|
|
static int get sg => 0;
|
|
|
|
@A<int>(0)
|
|
static void set ss(@A<int>(0) int x) {}
|
|
}
|
|
|
|
@A<int>(0)
|
|
enum En {
|
|
@A<int>(0)
|
|
foo,
|
|
}
|
|
|
|
@A<int>(0)
|
|
typedef F<@A<int>(0) T> = int Function<@A<int>(0) X>(@A<int>(0) int);
|
|
|
|
void main() {
|
|
// Function body declarations.
|
|
@A<int>(0)
|
|
const c = 0;
|
|
|
|
@A<int>(0)
|
|
final f = 0;
|
|
|
|
@A<int>(0)
|
|
void mp(@A<int>(0) Object x, [@A<int>(0) int y = 0]) {}
|
|
|
|
@A<int>(0)
|
|
void mn(@A<int>(0) Object x, {@A<int>(0) int y = 0}) {}
|
|
|
|
@A<int>(0)
|
|
void Function<@A<int>(0) X>(@A<int>(0) int y)? fv = null;
|
|
|
|
// Recursive annotations.
|
|
@A<void Function(@A<int>(0) int)?>(null)
|
|
var x = 0;
|
|
|
|
mn(c);
|
|
mp(f);
|
|
fv?.call(x);
|
|
}
|