Correct non-function type alias tests

Change-Id: I49a04bc294a65a252ba1d99a1c5aac3835632449
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/140659
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
This commit is contained in:
Erik Ernst 2020-03-25 10:19:39 +00:00 committed by commit-bot@chromium.org
parent cd162ea78e
commit 81f5bf98b1
20 changed files with 321 additions and 497 deletions

View file

@ -0,0 +1,14 @@
// 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.
// SharedOptions=--enable-experiment=nonfunction-type-aliases
typedef T = C;
class C extends T {}
// ^
// [analyzer] unspecified
// [cfe] unspecified
main() => C();

View file

@ -0,0 +1,19 @@
// 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.
// SharedOptions=--enable-experiment=nonfunction-type-aliases
class A<X> {}
typedef A1<Y> = A<Y>;
typedef A2<U, Z> = A1<A<Z>>;
typedef A3<W> = A2<int, A<W>>;
class B extends A3<B> {}
void f(A<A<A<B>>> a) {}
void main() {
f(B());
}

View file

@ -4,9 +4,6 @@
// SharedOptions=--enable-experiment=nonfunction-type-aliases
// Test that a non-function type alias can be used as the denoted type in
// many situations.
import 'dart:async';
// Introduce an aliased type.
@ -21,56 +18,21 @@ typedef T<X> = A<X>;
// Use the aliased type.
T<int> v1;
List<T<void>> v2 = [];
final T<String> v3 = throw "Anything";
const List<T<C>> v4 = [];
const v5 = <Type, Type>{T: T};
abstract class C {}
abstract class C {
static T<C> v1;
static List<T<T>> v2 = [];
static final T<Null> v3 = throw "Anything";
static const List<T<List>> v4 = [];
T<C> v5;
List<T<T>> v6 = [];
final T<Null> v7;
C(): v7 = T();
C.name1(this.v5, this.v7);
factory C.name2(T<C> arg1, T<Null> arg2) = C.name1;
T<double> operator +(T<double> other);
T<FutureOr<FutureOr<void>>> get g;
set g(T<FutureOr<FutureOr<void>>> value);
Map<T<C>, T<C>> m1(covariant T<C> arg1, [Set<Set<T<C>>> arg2]);
void m2({T arg1, Map<T, T> arg2(T Function(T) arg21, T arg22)});
}
class D1<X> extends T<X> {}
abstract class D2 extends C with T<int> {}
abstract class D3<X, Y> implements T<T> {}
// ^
// [analyzer] unspecified
// [cfe] unspecified
abstract class D4 = C with T<void>;
extension E on T<dynamic> {
T<dynamic> foo(T<dynamic> t) => t;
}
X foo<X>(X x) => x;
T<Type> Function(T<Type>) id;
// ^
// [analyzer] unspecified
// [cfe] unspecified
main() {
var v8 = <T<C>>[];
var v9 = <Set<T<T>>, Set<T<T>>>{{}: {}};
var v10 = {v8};
v9[{}] = {T<T>()};
Set<List<T<C>>> v11 = v10;
v10 = v11;
T<Null>();
T<Null>.named();
T<Object> v12 = foo<T<bool>>(T<bool>());
id(v12);
T<List<List<List<List>>>>.staticMethod<T<int>>();
// ^
// [analyzer] unspecified
// [cfe] unspecified
}

View file

@ -4,9 +4,6 @@
// SharedOptions=--enable-experiment=nonfunction-type-aliases
// Test that a non-function type alias can be used as the denoted type in
// many situations.
import 'dart:async';
// Introduce an aliased type.
@ -49,9 +46,7 @@ abstract class C {
}
class D1<X> extends T<X> {}
abstract class D2 extends C with T<int> {}
abstract class D3<X, Y> implements T<T> {}
abstract class D4 = C with T<void>;
extension E on T<dynamic> {
T<dynamic> foo(T<dynamic> t) => t;
@ -72,5 +67,5 @@ main() {
T<Null>.named();
T<Object> v12 = foo<T<bool>>(T<bool>());
id(v12);
T<List<List<List<List>>>>.staticMethod<T<int>>();
T.staticMethod<T<int>>();
}

View file

@ -4,9 +4,6 @@
// SharedOptions=--enable-experiment=nonfunction-type-aliases
// Test that a non-function type alias can be used as the denoted type in
// many situations.
import 'dart:async';
// Introduce an aliased type.
@ -15,56 +12,61 @@ typedef T<X> = dynamic;
// Use the aliased type.
T<int> v1;
List<T<void>> v2 = [];
final T<String> v3 = throw "Anything";
const List<T<C>> v4 = [];
const v5 = <Type, Type>{T: T};
abstract class C {
static T<C> v1;
static List<T<T>> v2 = [];
static final T<Null> v3 = throw "Anything";
static const List<T<List>> v4 = [];
T<C> v5;
List<T<T>> v6 = [];
final T<Null> v7;
C(): v7 = T();
C.name1(this.v5, this.v7);
factory C.name2(T<C> arg1, T<Null> arg2) = C.name1;
T<double> operator +(T<double> other);
T<FutureOr<FutureOr<void>>> get g;
set g(T<FutureOr<FutureOr<void>>> value);
Map<T<C>, T<C>> m1(covariant T<C> arg1, [Set<Set<T<C>>> arg2]);
void m2({T arg1, Map<T, T> arg2(T Function(T) arg21, T arg22)});
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
class D1<X> extends T<X> {}
abstract class D2 extends C with T<int> {}
abstract class D3<X, Y> implements T<T> {}
abstract class D4 = C with T<void>;
// ^
// [analyzer] unspecified
// [cfe] unspecified
extension E on T<dynamic> {
T<dynamic> foo(T<dynamic> t) => t;
}
abstract class D2 extends C with T<int> {}
// ^
// [analyzer] unspecified
// [cfe] unspecified
abstract class D3<X, Y> implements T<T> {}
// ^
// [analyzer] unspecified
// [cfe] unspecified
abstract class D4 = C with T<void>;
// ^
// [analyzer] unspecified
// [cfe] unspecified
X foo<X>(X x) => x;
T<Type> Function(T<Type>) id;
main() {
var v8 = <T<C>>[];
var v9 = <Set<T<T>>, Set<T<T>>>{{}: {}};
var v10 = {v8};
v9[{}] = {T<T>()};
Set<List<T<C>>> v11 = v10;
v10 = v11;
// ^
// [analyzer] unspecified
// [cfe] unspecified
T<Null>();
//^
// [analyzer] unspecified
// [cfe] unspecified
T<Null>.named();
//^
// [analyzer] unspecified
// [cfe] unspecified
T<Object> v12 = foo<T<bool>>(T<bool>());
id(v12);
// ^
// [analyzer] unspecified
// [cfe] unspecified
T<List<List<List<List>>>>.staticMethod<T<int>>();
//^
// [analyzer] unspecified
// [cfe] unspecified
}

View file

@ -4,9 +4,6 @@
// SharedOptions=--enable-experiment=nonfunction-type-aliases
// Test that a non-function type alias can be used as the denoted type in
// many situations.
import 'dart:async';
// Introduce an aliased type.
@ -31,7 +28,6 @@ abstract class C {
List<T<T>> v6 = [];
final T<Null> v7;
C(): v7 = T();
C.name1(this.v5, this.v7);
factory C.name2(T<C> arg1, T<Null> arg2) = C.name1;
@ -42,11 +38,6 @@ abstract class C {
void m2({T arg1, Map<T, T> arg2(T Function(T) arg21, T arg22)});
}
class D1<X> extends T<X> {}
abstract class D2 extends C with T<int> {}
abstract class D3<X, Y> implements T<T> {}
abstract class D4 = C with T<void>;
extension E on T<dynamic> {
T<dynamic> foo(T<dynamic> t) => t;
}
@ -59,12 +50,7 @@ main() {
var v8 = <T<C>>[];
var v9 = <Set<T<T>>, Set<T<T>>>{{}: {}};
var v10 = {v8};
v9[{}] = {T<T>()};
v9[{}] = {};
Set<List<T<C>>> v11 = v10;
v10 = v11;
T<Null>();
T<Null>.named();
T<Object> v12 = foo<T<bool>>(T<bool>());
id(v12);
T<List<List<List<List>>>>.staticMethod<T<int>>();
}

View file

@ -4,9 +4,6 @@
// SharedOptions=--enable-experiment=nonfunction-type-aliases
// Test that a non-function type alias can be used as the denoted type in
// many situations.
import 'dart:async';
// Introduce an aliased type.
@ -15,56 +12,41 @@ typedef T<X> = Function;
// Use the aliased type.
T<int> v1;
List<T<void>> v2 = [];
final T<String> v3 = throw "Anything";
const List<T<C>> v4 = [];
const v5 = <Type, Type>{T: T};
abstract class C {
static T<C> v1;
static List<T<T>> v2 = [];
static final T<Null> v3 = throw "Anything";
static const List<T<List>> v4 = [];
T<C> v5;
List<T<T>> v6 = [];
final T<Null> v7;
C(): v7 = T();
C.name1(this.v5, this.v7);
factory C.name2(T<C> arg1, T<Null> arg2) = C.name1;
T<double> operator +(T<double> other);
T<FutureOr<FutureOr<void>>> get g;
set g(T<FutureOr<FutureOr<void>>> value);
Map<T<C>, T<C>> m1(covariant T<C> arg1, [Set<Set<T<C>>> arg2]);
void m2({T arg1, Map<T, T> arg2(T Function(T) arg21, T arg22)});
}
class D1<X> extends T<X> {}
abstract class D2 extends C with T<int> {}
abstract class D3<X, Y> implements T<T> {}
abstract class D4 = C with T<void>;
extension E on T<dynamic> {
T<dynamic> foo(T<dynamic> t) => t;
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
X foo<X>(X x) => x;
T<Type> Function(T<Type>) id;
main() {
var v8 = <T<C>>[];
var v9 = <Set<T<T>>, Set<T<T>>>{{}: {}};
var v10 = {v8};
v9[{}] = {T<T>()};
Set<List<T<C>>> v11 = v10;
v10 = v11;
// ^
// [analyzer] unspecified
// [cfe] unspecified
T<Null>();
//^
// [analyzer] unspecified
// [cfe] unspecified
T<Null>.named();
//^
// [analyzer] unspecified
// [cfe] unspecified
T<Object> v12 = foo<T<bool>>(T<bool>());
id(v12);
// ^
// [analyzer] unspecified
// [cfe] unspecified
T<List<List<List<List>>>>.staticMethod<T<int>>();
// ^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

View file

@ -4,9 +4,6 @@
// SharedOptions=--enable-experiment=nonfunction-type-aliases
// Test that a non-function type alias can be used as the denoted type in
// many situations.
import 'dart:async';
// Introduce an aliased type.
@ -31,7 +28,7 @@ abstract class C {
List<T<T>> v6 = [];
final T<Null> v7;
C(): v7 = T();
C(): v7 = print;
C.name1(this.v5, this.v7);
factory C.name2(T<C> arg1, T<Null> arg2) = C.name1;
@ -59,12 +56,7 @@ main() {
var v8 = <T<C>>[];
var v9 = <Set<T<T>>, Set<T<T>>>{{}: {}};
var v10 = {v8};
v9[{}] = {T<T>()};
v9[{}] = {};
Set<List<T<C>>> v11 = v10;
v10 = v11;
T<Null>();
T<Null>.named();
T<Object> v12 = foo<T<bool>>(T<bool>());
id(v12);
T<List<List<List<List>>>>.staticMethod<T<int>>();
}

View file

@ -4,9 +4,6 @@
// SharedOptions=--enable-experiment=nonfunction-type-aliases
// Test that a non-function type alias can be used as the denoted type in
// many situations.
import 'dart:async';
// Introduce an aliased type.
@ -15,56 +12,62 @@ typedef T<X> = FutureOr<X>;
// Use the aliased type.
T<int> v1;
List<T<void>> v2 = [];
final T<String> v3 = throw "Anything";
const List<T<C>> v4 = [];
const v5 = <Type, Type>{T: T};
abstract class C {
static T<C> v1;
static List<T<T>> v2 = [];
static final T<Null> v3 = throw "Anything";
static const List<T<List>> v4 = [];
T<C> v5;
List<T<T>> v6 = [];
final T<Null> v7;
C(): v7 = T();
C.name1(this.v5, this.v7);
factory C.name2(T<C> arg1, T<Null> arg2) = C.name1;
T<double> operator +(T<double> other);
T<FutureOr<FutureOr<void>>> get g;
set g(T<FutureOr<FutureOr<void>>> value);
Map<T<C>, T<C>> m1(covariant T<C> arg1, [Set<Set<T<C>>> arg2]);
void m2({T arg1, Map<T, T> arg2(T Function(T) arg21, T arg22)});
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
class D1<X> extends T<X> {}
abstract class D2 extends C with T<int> {}
abstract class D3<X, Y> implements T<T> {}
abstract class D4 = C with T<void>;
// ^
// [analyzer] unspecified
// [cfe] unspecified
extension E on T<dynamic> {
T<dynamic> foo(T<dynamic> t) => t;
}
abstract class D2 extends C with T<int> {}
// ^
// [analyzer] unspecified
// [cfe] unspecified
abstract class D3<X, Y> implements T<T> {}
// ^
// [analyzer] unspecified
// [cfe] unspecified
abstract class D4 = C with T<void>;
// ^
// [analyzer] unspecified
// [cfe] unspecified
X foo<X>(X x) => x;
T<Type> Function(T<Type>) id;
main() {
var v8 = <T<C>>[];
var v9 = <Set<T<T>>, Set<T<T>>>{{}: {}};
var v10 = {v8};
v9[{}] = {T<T>()};
Set<List<T<C>>> v11 = v10;
v10 = v11;
// ^
// [analyzer] unspecified
// [cfe] unspecified
T<Null>();
//^
// [analyzer] unspecified
// [cfe] unspecified
T<Null>.named();
//^
// [analyzer] unspecified
// [cfe] unspecified
T<Object> v12 = foo<T<bool>>(T<bool>());
id(v12);
// ^
// [analyzer] unspecified
// [cfe] unspecified
T<List<List<List<List>>>>.staticMethod<T<int>>();
// ^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

View file

@ -4,9 +4,6 @@
// SharedOptions=--enable-experiment=nonfunction-type-aliases
// Test that a non-function type alias can be used as the denoted type in
// many situations.
import 'dart:async';
// Introduce an aliased type.
@ -31,7 +28,7 @@ abstract class C {
List<T<T>> v6 = [];
final T<Null> v7;
C(): v7 = T();
C(): v7 = null;
C.name1(this.v5, this.v7);
factory C.name2(T<C> arg1, T<Null> arg2) = C.name1;
@ -42,11 +39,6 @@ abstract class C {
void m2({T arg1, Map<T, T> arg2(T Function(T) arg21, T arg22)});
}
class D1<X> extends T<X> {}
abstract class D2 extends C with T<int> {}
abstract class D3<X, Y> implements T<T> {}
abstract class D4 = C with T<void>;
extension E on T<dynamic> {
T<dynamic> foo(T<dynamic> t) => t;
}
@ -59,12 +51,7 @@ main() {
var v8 = <T<C>>[];
var v9 = <Set<T<T>>, Set<T<T>>>{{}: {}};
var v10 = {v8};
v9[{}] = {T<T>()};
v9[{}] = {};
Set<List<T<C>>> v11 = v10;
v10 = v11;
T<Null>();
T<Null>.named();
T<Object> v12 = foo<T<bool>>(T<bool>());
id(v12);
T<List<List<List<List>>>>.staticMethod<T<int>>();
}

View file

@ -4,9 +4,6 @@
// SharedOptions=--enable-experiment=nonfunction-type-aliases
// Test that a non-function type alias can be used as the denoted type in
// many situations.
import 'dart:async';
// Introduce an aliased type.
@ -15,56 +12,61 @@ typedef T<X> = Null;
// Use the aliased type.
T<int> v1;
List<T<void>> v2 = [];
final T<String> v3 = throw "Anything";
const List<T<C>> v4 = [];
const v5 = <Type, Type>{T: T};
abstract class C {
static T<C> v1;
static List<T<T>> v2 = [];
static final T<Null> v3 = throw "Anything";
static const List<T<List>> v4 = [];
T<C> v5;
List<T<T>> v6 = [];
final T<Null> v7;
C(): v7 = T();
C.name1(this.v5, this.v7);
factory C.name2(T<C> arg1, T<Null> arg2) = C.name1;
T<double> operator +(T<double> other);
T<FutureOr<FutureOr<void>>> get g;
set g(T<FutureOr<FutureOr<void>>> value);
Map<T<C>, T<C>> m1(covariant T<C> arg1, [Set<Set<T<C>>> arg2]);
void m2({T arg1, Map<T, T> arg2(T Function(T) arg21, T arg22)});
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
class D1<X> extends T<X> {}
abstract class D2 extends C with T<int> {}
abstract class D3<X, Y> implements T<T> {}
abstract class D4 = C with T<void>;
// ^
// [analyzer] unspecified
// [cfe] unspecified
extension E on T<dynamic> {
T<dynamic> foo(T<dynamic> t) => t;
}
abstract class D2 extends C with T<int> {}
// ^
// [analyzer] unspecified
// [cfe] unspecified
abstract class D3<X, Y> implements T<T> {}
// ^
// [analyzer] unspecified
// [cfe] unspecified
abstract class D4 = C with T<void>;
// ^
// [analyzer] unspecified
// [cfe] unspecified
X foo<X>(X x) => x;
T<Type> Function(T<Type>) id;
main() {
var v8 = <T<C>>[];
var v9 = <Set<T<T>>, Set<T<T>>>{{}: {}};
var v10 = {v8};
v9[{}] = {T<T>()};
Set<List<T<C>>> v11 = v10;
v10 = v11;
// ^
// [analyzer] unspecified
// [cfe] unspecified
T<Null>();
//^
// [analyzer] unspecified
// [cfe] unspecified
T<Null>.named();
//^
// [analyzer] unspecified
// [cfe] unspecified
T<Object> v12 = foo<T<bool>>(T<bool>());
id(v12);
// ^
// [analyzer] unspecified
// [cfe] unspecified
T<List<List<List<List>>>>.staticMethod<T<int>>();
// ^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

View file

@ -4,9 +4,6 @@
// SharedOptions=--enable-experiment=nonfunction-type-aliases
// Test that a non-function type alias can be used as the denoted type in
// many situations.
import 'dart:async';
// Introduce an aliased type.
@ -31,7 +28,7 @@ abstract class C {
List<T<T>> v6 = [];
final T<Null> v7;
C(): v7 = T();
C(): v7 = null;
C.name1(this.v5, this.v7);
factory C.name2(T<C> arg1, T<Null> arg2) = C.name1;
@ -42,11 +39,6 @@ abstract class C {
void m2({T arg1, Map<T, T> arg2(T Function(T) arg21, T arg22)});
}
class D1<X> extends T<X> {}
abstract class D2 extends C with T<int> {}
abstract class D3<X, Y> implements T<T> {}
abstract class D4 = C with T<void>;
extension E on T<dynamic> {
T<dynamic> foo(T<dynamic> t) => t;
}
@ -59,12 +51,7 @@ main() {
var v8 = <T<C>>[];
var v9 = <Set<T<T>>, Set<T<T>>>{{}: {}};
var v10 = {v8};
v9[{}] = {T<T>()};
v9[{}] = {};
Set<List<T<C>>> v11 = v10;
v10 = v11;
T<Null>();
T<Null>.named();
T<Object> v12 = foo<T<bool>>(T<bool>());
id(v12);
T<List<List<List<List>>>>.staticMethod<T<int>>();
}

View file

@ -4,9 +4,6 @@
// SharedOptions=--enable-experiment=nonfunction-type-aliases
// Test that a non-function type alias can be used as the denoted type in
// many situations.
import 'dart:async';
// Introduce an aliased type.
@ -15,56 +12,26 @@ typedef T<X> = Object;
// Use the aliased type.
T<int> v1;
List<T<void>> v2 = [];
final T<String> v3 = throw "Anything";
const List<T<C>> v4 = [];
const v5 = <Type, Type>{T: T};
abstract class C {}
abstract class C {
static T<C> v1;
static List<T<T>> v2 = [];
static final T<Null> v3 = throw "Anything";
static const List<T<List>> v4 = [];
T<C> v5;
List<T<T>> v6 = [];
final T<Null> v7;
C(): v7 = T();
C.name1(this.v5, this.v7);
factory C.name2(T<C> arg1, T<Null> arg2) = C.name1;
T<double> operator +(T<double> other);
T<FutureOr<FutureOr<void>>> get g;
set g(T<FutureOr<FutureOr<void>>> value);
Map<T<C>, T<C>> m1(covariant T<C> arg1, [Set<Set<T<C>>> arg2]);
void m2({T arg1, Map<T, T> arg2(T Function(T) arg21, T arg22)});
}
class D1<X> extends T<X> {}
abstract class D2 extends C with T<int> {}
abstract class D3<X, Y> implements T<T> {}
// ^
// [analyzer] unspecified
// [cfe] unspecified
abstract class D4 = C with T<void>;
extension E on T<dynamic> {
T<dynamic> foo(T<dynamic> t) => t;
}
X foo<X>(X x) => x;
T<Type> Function(T<Type>) id;
// ^
// [analyzer] unspecified
// [cfe] unspecified
main() {
var v8 = <T<C>>[];
var v9 = <Set<T<T>>, Set<T<T>>>{{}: {}};
var v10 = {v8};
v9[{}] = {T<T>()};
Set<List<T<C>>> v11 = v10;
v10 = v11;
T<Null>();
T<Null>.named();
T<Object> v12 = foo<T<bool>>(T<bool>());
id(v12);
// ^
// [analyzer] unspecified
// [cfe] unspecified
T<List<List<List<List>>>>.staticMethod<T<int>>();
// ^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

View file

@ -4,9 +4,6 @@
// SharedOptions=--enable-experiment=nonfunction-type-aliases
// Test that a non-function type alias can be used as the denoted type in
// many situations.
import 'dart:async';
// Introduce an aliased type.
@ -22,17 +19,17 @@ const List<T<C>> v4 = [];
const v5 = <Type, Type>{T: T};
abstract class C {
static T<C> v1;
static List<T<T>> v2 = [];
static final T<Null> v3 = throw "Anything";
static const List<T<List>> v4 = [];
static T<C> v6;
static List<T<T>> v7 = [];
static final T<Null> v8 = throw "Anything";
static const List<T<List>> v9 = [];
T<C> v5;
List<T<T>> v6 = [];
final T<Null> v7;
T<C> v10;
List<T<T>> v11 = [];
final T<Null> v12;
C(): v7 = T();
C.name1(this.v5, this.v7);
C(): v12 = T();
C.name1(this.v10, this.v12);
factory C.name2(T<C> arg1, T<Null> arg2) = C.name1;
T<double> operator +(T<double> other);
@ -43,18 +40,17 @@ abstract class C {
}
class D1<X> extends T<X> {}
abstract class D2 extends C with T<int> {}
abstract class D3<X, Y> implements T<T> {}
abstract class D4 = C with T<void>;
abstract class D3<X, Y> extends C implements T<T> {}
extension E on T<dynamic> {
T<dynamic> foo(T<dynamic> t) => t;
}
X foo<X>(X x) => x;
T<Type> Function(T<Type>) id;
X foo<X>(X x) => x;
main() {
var v8 = <T<C>>[];
var v9 = <Set<T<T>>, Set<T<T>>>{{}: {}};
@ -63,8 +59,5 @@ main() {
Set<List<T<C>>> v11 = v10;
v10 = v11;
T<Null>();
T<Null>.named();
T<Object> v12 = foo<T<bool>>(T<bool>());
id(v12);
T<List<List<List<List>>>>.staticMethod<T<int>>();
}

View file

@ -4,9 +4,6 @@
// SharedOptions=--enable-experiment=nonfunction-type-aliases
// Test that a non-function type alias can be used as the denoted type in
// many situations.
import 'dart:async';
// Introduce an aliased type.
@ -15,56 +12,61 @@ typedef T<X> = X;
// Use the aliased type.
T<int> v1;
List<T<void>> v2 = [];
final T<String> v3 = throw "Anything";
const List<T<C>> v4 = [];
const v5 = <Type, Type>{T: T};
abstract class C {
static T<C> v1;
static List<T<T>> v2 = [];
static final T<Null> v3 = throw "Anything";
static const List<T<List>> v4 = [];
T<C> v5;
List<T<T>> v6 = [];
final T<Null> v7;
C(): v7 = T();
C.name1(this.v5, this.v7);
factory C.name2(T<C> arg1, T<Null> arg2) = C.name1;
T<double> operator +(T<double> other);
T<FutureOr<FutureOr<void>>> get g;
set g(T<FutureOr<FutureOr<void>>> value);
Map<T<C>, T<C>> m1(covariant T<C> arg1, [Set<Set<T<C>>> arg2]);
void m2({T arg1, Map<T, T> arg2(T Function(T) arg21, T arg22)});
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
class D1<X> extends T<X> {}
abstract class D2 extends C with T<int> {}
abstract class D3<X, Y> implements T<T> {}
abstract class D4 = C with T<void>;
// ^
// [analyzer] unspecified
// [cfe] unspecified
extension E on T<dynamic> {
T<dynamic> foo(T<dynamic> t) => t;
}
abstract class D2 extends C with T<int> {}
// ^
// [analyzer] unspecified
// [cfe] unspecified
abstract class D3<X, Y> implements T<T> {}
// ^
// [analyzer] unspecified
// [cfe] unspecified
abstract class D4 = C with T<void>;
// ^
// [analyzer] unspecified
// [cfe] unspecified
X foo<X>(X x) => x;
T<Type> Function(T<Type>) id;
main() {
var v8 = <T<C>>[];
var v9 = <Set<T<T>>, Set<T<T>>>{{}: {}};
var v10 = {v8};
v9[{}] = {T<T>()};
Set<List<T<C>>> v11 = v10;
v10 = v11;
// ^
// [analyzer] unspecified
// [cfe] unspecified
T<Null>();
//^
// [analyzer] unspecified
// [cfe] unspecified
T<Null>.named();
// ^
// [analyzer] unspecified
// [cfe] unspecified
T<Object> v12 = foo<T<bool>>(T<bool>());
id(v12);
// ^
// [analyzer] unspecified
// [cfe] unspecified
T<List<List<List<List>>>>.staticMethod<T<int>>();
// ^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

View file

@ -4,9 +4,6 @@
// SharedOptions=--enable-experiment=nonfunction-type-aliases
// Test that a non-function type alias can be used as the denoted type in
// many situations.
import 'dart:async';
// Introduce an aliased type.
@ -27,13 +24,13 @@ abstract class C {
static final T<Null> v3 = throw "Anything";
static const List<T<List>> v4 = [];
T<C> v5;
T<D> v5;
List<T<T>> v6 = [];
final T<Null> v7;
C(): v7 = T();
C(): v7 = T<D>();
C.name1(this.v5, this.v7);
factory C.name2(T<C> arg1, T<Null> arg2) = C.name1;
factory C.name2(T<D> arg1, T<Null> arg2) = C.name1;
T<double> operator +(T<double> other);
T<FutureOr<FutureOr<void>>> get g;
@ -42,29 +39,25 @@ abstract class C {
void m2({T arg1, Map<T, T> arg2(T Function(T) arg21, T arg22)});
}
class D1<X> extends T<X> {}
abstract class D2 extends C with T<int> {}
abstract class D3<X, Y> implements T<T> {}
abstract class D4 = C with T<void>;
class D {}
mixin M {}
abstract class D1<X> extends T<D> {}
abstract class D2 extends C with T<M> {}
abstract class D3<X, Y> implements T<T<D>> {}
abstract class D4 = C with T<D>;
extension E on T<dynamic> {
T<dynamic> foo(T<dynamic> t) => t;
}
X foo<X>(X x) => x;
T<Type> Function(T<Type>) id;
main() {
var v8 = <T<C>>[];
var v9 = <Set<T<T>>, Set<T<T>>>{{}: {}};
var v10 = {v8};
v9[{}] = {T<T>()};
v9[{}] = {T<D>()};
Set<List<T<C>>> v11 = v10;
v10 = v11;
T<Null>();
T<Null>.named();
T<Object> v12 = foo<T<bool>>(T<bool>());
id(v12);
T<List<List<List<List>>>>.staticMethod<T<int>>();
T<Object>();
T<C>.name1(D(), null);
}

View file

@ -4,9 +4,6 @@
// SharedOptions=--enable-experiment=nonfunction-type-aliases
// Test that a non-function type alias can be used as the denoted type in
// many situations.
import 'dart:async';
// Introduce an aliased type.
@ -15,37 +12,34 @@ typedef T<X> = void;
// Use the aliased type.
T<int> v1;
List<T<void>> v2 = [];
final T<String> v3 = throw "Anything";
const List<T<C>> v4 = [];
const v5 = <Type, Type>{T: T};
abstract class C {
static T<C> v1;
static List<T<T>> v2 = [];
static final T<Null> v3 = throw "Anything";
static const List<T<List>> v4 = [];
T<C> v5;
List<T<T>> v6 = [];
final T<Null> v7;
C(): v7 = T();
C.name1(this.v5, this.v7);
factory C.name2(T<C> arg1, T<Null> arg2) = C.name1;
T<double> operator +(T<double> other);
T<FutureOr<FutureOr<void>>> get g;
set g(T<FutureOr<FutureOr<void>>> value);
Map<T<C>, T<C>> m1(covariant T<C> arg1, [Set<Set<T<C>>> arg2]);
void m2({T arg1, Map<T, T> arg2(T Function(T) arg21, T arg22)});
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
class D1<X> extends T<X> {}
// ^
// [analyzer] unspecified
// [cfe] unspecified
abstract class D2 extends C with T<int> {}
// ^
// [analyzer] unspecified
// [cfe] unspecified
abstract class D3<X, Y> implements T<T> {}
// ^
// [analyzer] unspecified
// [cfe] unspecified
abstract class D4 = C with T<void>;
// ^
// [analyzer] unspecified
// [cfe] unspecified
extension E on T<dynamic> {
T<dynamic> foo(T<dynamic> t) => t;
@ -53,18 +47,35 @@ extension E on T<dynamic> {
X foo<X>(X x) => x;
T<Type> Function(T<Type>) id;
main() {
var v8 = <T<C>>[];
var v9 = <Set<T<T>>, Set<T<T>>>{{}: {}};
var v10 = {v8};
v9[{}] = {T<T>()};
// ^
// [analyzer] unspecified
// [cfe] unspecified
Set<List<T<C>>> v11 = v10;
v10 = v11;
T<Null>();
//^
// [analyzer] unspecified
// [cfe] unspecified
T<Null>.named();
//^
// [analyzer] unspecified
// [cfe] unspecified
T<Object> v12 = foo<T<bool>>(T<bool>());
id(v12);
// ^
// [analyzer] unspecified
// [cfe] unspecified
T<List<List<List<List>>>>.staticMethod<T<int>>();
// ^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

View file

@ -4,9 +4,6 @@
// SharedOptions=--enable-experiment=nonfunction-type-aliases
// Test that a non-function type alias can be used as the denoted type in
// many situations.
import 'dart:async';
// Introduce an aliased type.
@ -31,7 +28,7 @@ abstract class C {
List<T<T>> v6 = [];
final T<Null> v7;
C(): v7 = T();
C(): v7 = null;
C.name1(this.v5, this.v7);
factory C.name2(T<C> arg1, T<Null> arg2) = C.name1;
@ -42,11 +39,6 @@ abstract class C {
void m2({T arg1, Map<T, T> arg2(T Function(T) arg21, T arg22)});
}
class D1<X> extends T<X> {}
abstract class D2 extends C with T<int> {}
abstract class D3<X, Y> implements T<T> {}
abstract class D4 = C with T<void>;
extension E on T<dynamic> {
T<dynamic> foo(T<dynamic> t) => t;
}
@ -59,12 +51,7 @@ main() {
var v8 = <T<C>>[];
var v9 = <Set<T<T>>, Set<T<T>>>{{}: {}};
var v10 = {v8};
v9[{}] = {T<T>()};
v9[{}] = {};
Set<List<T<C>>> v11 = v10;
v10 = v11;
T<Null>();
T<Null>.named();
T<Object> v12 = foo<T<bool>>(T<bool>());
id(v12);
T<List<List<List<List>>>>.staticMethod<T<int>>();
}

View file

@ -1,18 +0,0 @@
// 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.
// SharedOptions=--enable-experiment=nonfunction-type-aliases,non-nullable
typedef T0 = Function?;
typedef T1<X> = List<X?>?;
typedef T2<X, Y> = Map<X?, Y?>?;
typedef T3 = Never? Function(void)?;
typedef T4<X> = X? Function(X?, {required X? name})?;
typedef T5<X extends String, Y extends List<X?>> =
X? Function(Y?, [Map<Y, Y?>]);
void main() {
// ignore:unused_local_variable
var ensure_usage = [T0, T1, T2, T3, T4, T5];
}

View file

@ -16,56 +16,14 @@ typedef T<X extends A> = X;
// 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 = T();
C.name1(this.v10, this.v12);
factory C.name2(T arg1, T arg2) = C.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 D1 extends T {}
abstract class D2 extends C with T {}
abstract class D3 implements T {}
abstract class D4 = C with 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[{}] = {T()};
var v15 = {v13};
Set<List<T>> v16 = v15;
v15 = v16;
T();
T.named();
T v17 = foo<T>(T());
id(v17);
T.staticMethod<T>();
T().unknownInstanceMethod();
// ^
// [analyzer] unspecified
// [cfe] unspecified
T.unknownStaticMethod();
// ^
// [analyzer] unspecified
// [cfe] unspecified
}