Skip to content

Commit 1ab82de

Browse files
munificentcommit-bot@chromium.org
authored andcommitted
Migrate language_2/nonfunction_type_aliases to NNBD.
Change-Id: I2cf8ebe11b86549488fa04f18d5e92c1bf9c3a15 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152585 Auto-Submit: Bob Nystrom <rnystrom@google.com> Reviewed-by: Nicholas Shahan <nshahan@google.com> Commit-Queue: Bob Nystrom <rnystrom@google.com>
1 parent 648b5e9 commit 1ab82de

File tree

46 files changed

+2238
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2238
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
// SharedOptions=--enable-experiment=nonfunction-type-aliases
6+
7+
typedef T = C;
8+
9+
class C extends T {}
10+
// ^
11+
// [analyzer] unspecified
12+
// [cfe] unspecified
13+
14+
main() => C();
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
// SharedOptions=--enable-experiment=nonfunction-type-aliases
6+
7+
class A<X> {}
8+
9+
typedef A1<Y> = A<Y>;
10+
typedef A2<U, Z> = A1<A<Z>>;
11+
typedef A3<W> = A2<int, A<W>>;
12+
13+
class B extends A3<B> {}
14+
15+
void f(A<A<A<B>>> a) {}
16+
17+
void main() {
18+
f(B());
19+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
// SharedOptions=--enable-experiment=nonfunction-type-aliases
6+
7+
import 'dart:async';
8+
9+
// Introduce an aliased type.
10+
11+
class A<X> {
12+
A();
13+
A.named();
14+
static void staticMethod<Y>() {}
15+
}
16+
17+
typedef T<X> = A<X>;
18+
19+
// Use the aliased type.
20+
21+
abstract class C {}
22+
23+
abstract class D2 extends C with T<int> {}
24+
// ^
25+
// [analyzer] unspecified
26+
// [cfe] unspecified
27+
28+
abstract class D4 = C with T<void>;
29+
// ^
30+
// [analyzer] unspecified
31+
// [cfe] unspecified
32+
33+
main() {
34+
T<List<List<List<List>>>>.staticMethod<T<int>>();
35+
// ^
36+
// [analyzer] unspecified
37+
// [cfe] unspecified
38+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
// SharedOptions=--enable-experiment=nonfunction-type-aliases
6+
7+
import 'dart:async';
8+
9+
// Introduce an aliased type.
10+
11+
class A<X> {
12+
A();
13+
A.named();
14+
static void staticMethod<Y>() {}
15+
}
16+
17+
typedef T<X> = A<X>;
18+
19+
// Use the aliased type.
20+
21+
T<int>? v1;
22+
List<T<void>> v2 = [];
23+
final T<String> v3 = throw "Anything";
24+
const List<T<C>> v4 = [];
25+
const v5 = <Type, Type>{T: T};
26+
27+
abstract class C {
28+
static T<C>? v1;
29+
static List<T<T>> v2 = [];
30+
static final T<Null> v3 = throw "Anything";
31+
static const List<T<List>> v4 = [];
32+
33+
T<C>? v5;
34+
List<T<T>> v6 = [];
35+
final T<Null> v7;
36+
37+
C(): v7 = T<Null>();
38+
C.name1(this.v5, this.v7);
39+
factory C.name2(T<C> arg1, T<Null> arg2) = C.name1;
40+
41+
T<double> operator +(T<double> other);
42+
T<FutureOr<FutureOr<void>>> get g;
43+
set g(T<FutureOr<FutureOr<void>>> value);
44+
Map<T<C>, T<C>> m1(covariant T<C> arg1, [Set<Set<T<C>>> arg2]);
45+
void m2({T arg1, Map<T, T> arg2(T Function(T) arg21, T arg22)});
46+
}
47+
48+
class D1<X> extends T<X> {}
49+
abstract class D3<X, Y> implements T<T> {}
50+
51+
extension E on T<dynamic> {
52+
T<dynamic> foo(T<dynamic> t) => t;
53+
}
54+
55+
X foo<X>(X x) => x;
56+
57+
T<Object> Function(T<Object>) id = (x) => x;
58+
59+
main() {
60+
var v8 = <T<C>>[];
61+
var v9 = <Set<T<T>>, Set<T<T>>>{{}: {}};
62+
var v10 = {v8};
63+
v9[{}] = {T<T>()};
64+
Set<List<T<C>>> v11 = v10;
65+
v10 = v11;
66+
T<Null>();
67+
T<Null>.named();
68+
T<Object> v12 = foo<T<bool>>(T<bool>());
69+
id(v12);
70+
T.staticMethod<T<int>>();
71+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
// SharedOptions=--enable-experiment=nonfunction-type-aliases
6+
7+
import 'dart:async';
8+
9+
// Introduce an aliased type.
10+
11+
typedef T<X> = dynamic;
12+
13+
// Use the aliased type.
14+
15+
abstract class C {
16+
final T<Null> v7;
17+
18+
C(): v7 = T();
19+
// ^
20+
// [analyzer] unspecified
21+
// [cfe] unspecified
22+
}
23+
24+
class D1<X> extends T<X> {}
25+
// ^
26+
// [analyzer] unspecified
27+
// [cfe] unspecified
28+
29+
abstract class D2 extends C with T<int> {}
30+
// ^
31+
// [analyzer] unspecified
32+
// [cfe] unspecified
33+
34+
abstract class D3<X, Y> implements T<T> {}
35+
// ^
36+
// [analyzer] unspecified
37+
// [cfe] unspecified
38+
39+
abstract class D4 = C with T<void>;
40+
// ^
41+
// [analyzer] unspecified
42+
// [cfe] unspecified
43+
44+
X foo<X>(X x) => x;
45+
46+
main() {
47+
var v9 = <Set<T<T>>, Set<T<T>>>{{}: {}};
48+
v9[{}] = {T<T>()};
49+
// ^
50+
// [analyzer] unspecified
51+
// [cfe] unspecified
52+
53+
T<Null>();
54+
//^
55+
// [analyzer] unspecified
56+
// [cfe] unspecified
57+
58+
T<Null>.named();
59+
//^
60+
// [analyzer] unspecified
61+
// [cfe] unspecified
62+
63+
T<Object> v12 = foo<T<bool>>(T<bool>());
64+
// ^
65+
// [analyzer] unspecified
66+
// [cfe] unspecified
67+
68+
T<List<List<List<List>>>>.staticMethod<T<int>>();
69+
//^
70+
// [analyzer] unspecified
71+
// [cfe] unspecified
72+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
// SharedOptions=--enable-experiment=nonfunction-type-aliases
6+
7+
import 'dart:async';
8+
9+
// Introduce an aliased type.
10+
11+
typedef T<X> = dynamic;
12+
13+
// Use the aliased type.
14+
15+
T<int>? v1;
16+
List<T<void>> v2 = [];
17+
final T<String> v3 = throw "Anything";
18+
const List<T<C>> v4 = [];
19+
const v5 = <Type, Type>{T: T};
20+
21+
abstract class C {
22+
static T<C>? v1;
23+
static List<T<T>> v2 = [];
24+
static final T<Null> v3 = throw "Anything";
25+
static const List<T<List>> v4 = [];
26+
27+
T<C>? v5;
28+
List<T<T>> v6 = [];
29+
final T<Null> v7;
30+
31+
C.name1(this.v5, this.v7);
32+
factory C.name2(T<C> arg1, T<Null> arg2) = C.name1;
33+
34+
T<double> operator +(T<double> other);
35+
T<FutureOr<FutureOr<void>>> get g;
36+
set g(T<FutureOr<FutureOr<void>>> value);
37+
Map<T<C>, T<C>> m1(covariant T<C> arg1, [Set<Set<T<C>>> arg2]);
38+
void m2({T arg1, Map<T, T> arg2(T Function(T) arg21, T arg22)});
39+
}
40+
41+
extension E on T<dynamic> {
42+
T<dynamic> foo(T<dynamic> t) => t;
43+
}
44+
45+
X foo<X>(X x) => x;
46+
47+
T<Type> Function(T<Type>)? id;
48+
49+
main() {
50+
var v8 = <T<C>>[];
51+
var v9 = <Set<T<T>>, Set<T<T>>>{{}: {}};
52+
var v10 = {v8};
53+
v9[{}] = {};
54+
Set<List<T<C>>> v11 = v10;
55+
v10 = v11;
56+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
// SharedOptions=--enable-experiment=nonfunction-type-aliases
6+
7+
import 'dart:async';
8+
9+
// Introduce an aliased type.
10+
11+
typedef T<X> = Function;
12+
13+
// Use the aliased type.
14+
15+
abstract class C {
16+
final T<Null> v7;
17+
18+
C(): v7 = T();
19+
// ^
20+
// [analyzer] unspecified
21+
// [cfe] unspecified
22+
}
23+
24+
X foo<X>(X x) => x;
25+
26+
main() {
27+
var v9 = <Set<T<T>>, Set<T<T>>>{{}: {}};
28+
v9[{}] = {T<T>()};
29+
// ^
30+
// [analyzer] unspecified
31+
// [cfe] unspecified
32+
33+
T<Null>();
34+
//^
35+
// [analyzer] unspecified
36+
// [cfe] unspecified
37+
38+
T<Null>.named();
39+
//^
40+
// [analyzer] unspecified
41+
// [cfe] unspecified
42+
43+
T<Object> v12 = foo<T<bool>>(T<bool>());
44+
// ^
45+
// [analyzer] unspecified
46+
// [cfe] unspecified
47+
48+
T<List<List<List<List>>>>.staticMethod<T<int>>();
49+
// ^^^^^^^^^^^^
50+
// [analyzer] unspecified
51+
// [cfe] unspecified
52+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
// SharedOptions=--enable-experiment=nonfunction-type-aliases
6+
7+
import 'dart:async';
8+
9+
// Introduce an aliased type.
10+
11+
typedef T<X> = Function;
12+
13+
// Use the aliased type.
14+
15+
T<int>? v1;
16+
List<T<void>> v2 = [];
17+
final T<String> v3 = throw "Anything";
18+
const List<T<C>> v4 = [];
19+
const v5 = <Type, Type>{T: T};
20+
21+
abstract class C {
22+
static T<C>? v1;
23+
static List<T<T>> v2 = [];
24+
static final T<Null> v3 = throw "Anything";
25+
static const List<T<List>> v4 = [];
26+
27+
T<C>? v5;
28+
List<T<T>> v6 = [];
29+
final T<Null> v7;
30+
31+
C(): v7 = print;
32+
C.name1(this.v5, this.v7);
33+
factory C.name2(T<C> arg1, T<Null> arg2) = C.name1;
34+
35+
T<double> operator +(T<double> other);
36+
T<FutureOr<FutureOr<void>>> get g;
37+
set g(T<FutureOr<FutureOr<void>>> value);
38+
Map<T<C>, T<C>> m1(covariant T<C> arg1, [Set<Set<T<C>>> arg2]);
39+
void m2({T arg1, Map<T, T> arg2(T Function(T) arg21, T arg22)});
40+
}
41+
42+
class D1<X> extends T<X> {}
43+
abstract class D2 extends C with T<int> {}
44+
abstract class D3<X, Y> implements T<T> {}
45+
abstract class D4 = C with T<void>;
46+
47+
extension E on T<dynamic> {
48+
T<dynamic> foo(T<dynamic> t) => t;
49+
}
50+
51+
X foo<X>(X x) => x;
52+
53+
T<Type> Function(T<Type>)? id;
54+
55+
main() {
56+
var v8 = <T<C>>[];
57+
var v9 = <Set<T<T>>, Set<T<T>>>{{}: {}};
58+
var v10 = {v8};
59+
v9[{}] = {};
60+
Set<List<T<C>>> v11 = v10;
61+
v10 = v11;
62+
}

0 commit comments

Comments
 (0)