mirror of
https://github.com/dart-lang/sdk
synced 2024-09-18 22:11:19 +00:00
cc736dfb65
This reapplies commit0c05e33836
and reverts the revert029e0cec71
. Tested: Added few new tests, updated existing. Mainly regression testing. CoreLibraryReviewExempt: Reviewed in original CL. Change-Id: Ifcc79ce2f9375f607722643a04957b0961e6c295 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284304 Reviewed-by: Ömer Ağacan <omersa@google.com> Commit-Queue: Lasse Nielsen <lrn@google.com> Reviewed-by: Aske Simon Christensen <askesc@google.com> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
68 lines
1.4 KiB
Dart
68 lines
1.4 KiB
Dart
// Copyright (c) 2019, 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.
|
|
// @dart = 2.9
|
|
// Requirements=nnbd-weak
|
|
|
|
// Test that a type alias `T` denoting `Function` can be used.
|
|
|
|
import 'usage_function_lib.dart';
|
|
|
|
// Use the aliased type.
|
|
|
|
T v1;
|
|
List<T> v2 = [];
|
|
final T v3 = throw "Anything";
|
|
const List<T> v4 = [];
|
|
const v5 = <Type, Type>{T: T};
|
|
|
|
abstract class C {
|
|
static T v6;
|
|
static List<T> v7 = [];
|
|
static final T v8 = throw "Anything";
|
|
static const List<T> v9 = [];
|
|
|
|
T v10;
|
|
List<T> v11 = [];
|
|
final T v12;
|
|
|
|
C() : v12 = (() {});
|
|
C.name1(this.v10, this.v12);
|
|
factory C.name2(T arg1, T arg2) = C1.name1;
|
|
|
|
T operator +(T other);
|
|
T get g;
|
|
set g(T value);
|
|
Map<T, T> m1(covariant T arg1, [Set<Set<T>> arg2]);
|
|
void m2({T arg1, T arg2(T arg21, T arg22)});
|
|
}
|
|
|
|
class C1 implements C {
|
|
C1.name1(T arg1, T arg2);
|
|
noSuchMethod(Invocation invocation) => throw 0;
|
|
}
|
|
|
|
class D1 extends T {}
|
|
|
|
abstract class D3 implements T {}
|
|
|
|
extension E on T {
|
|
T foo(T t) => t;
|
|
}
|
|
|
|
X foo<X>(X x) => x;
|
|
|
|
T Function(T) id = (x) => x;
|
|
|
|
main() {
|
|
var v13 = <T>[];
|
|
var v14 = <Set<T>, Set<T>>{{}: {}};
|
|
v14[{}] = {};
|
|
var v15 = {v13};
|
|
Set<List<T>> v16 = v15;
|
|
v15 = v16;
|
|
T v17 = foo<T>(() {});
|
|
id(v17);
|
|
T.apply(() {}, []);
|
|
}
|