mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 23:39:48 +00:00
17ccbecc61
Closes https://github.com/dart-lang/sdk/pull/50763 GitOrigin-RevId: ee6187bc11c8211402b6aa722eb2c0826cba3d5b Change-Id: I598004024a89e25710b9f16749ffb7c6fd6753c2 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/276340 Reviewed-by: Erik Ernst <eernst@google.com> Commit-Queue: Erik Ernst <eernst@google.com>
237 lines
4.2 KiB
Dart
237 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);
|
|
}
|