mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 04:06:59 +00:00
Add cycle detection test cases for nonfunction type aliases.
Change-Id: I4375c3374ba5d51b4431dbe22a0e8c867a4eb03d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167720 Reviewed-by: Erik Ernst <eernst@google.com> Commit-Queue: Paul Berry <paulberry@google.com>
This commit is contained in:
parent
7c01226470
commit
f0052ef52e
|
@ -0,0 +1,65 @@
|
|||
// Copyright (c) 2020, 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
|
||||
|
||||
// This test verifies that cyclic type alias definitions cause a compile-time
|
||||
// error, when the cycle occurs via the bound.
|
||||
|
||||
typedef T1<X extends T1<Never>> = List<X>;
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
|
||||
// Note: when the cycle involves two typedefs, the CFE only reports an error for
|
||||
// one of them; that's ok.
|
||||
typedef T2<X extends T3> = List<X>;
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
|
||||
typedef T3 = T2<Never>;
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
|
||||
typedef T4<X extends List<T4<Never>>> = List<X>;
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
|
||||
typedef T5<X extends T5<Never> Function()> = List<X>;
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
|
||||
typedef T6<X extends void Function(T6<Never>)> = List<X>;
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
|
||||
// Note: not an error because T7 is the name of the parameter.
|
||||
typedef T7<X extends void Function(int T7)> = List<X>;
|
||||
|
||||
typedef T8<X extends void Function([T8<Never>])> = List<X>;
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
|
||||
// Note: not an error because T9 is the name of the parameter.
|
||||
typedef T9<X extends void Function([int T9])> = List<X>;
|
||||
|
||||
typedef T10<X extends void Function({T10<Never> x})> = List<X>;
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
|
||||
// Note: not an error because T11 is the name of the parameter.
|
||||
typedef T11<X extends void Function({int T11})> = List<X>;
|
||||
|
||||
// Note: we have to use `void Function<...>() Function()` because a generic
|
||||
// function can't directly be used as a bound.
|
||||
typedef T12<X extends void Function<Y extends T12<Never>>() Function()> = List<X>;
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
|
@ -0,0 +1,66 @@
|
|||
// Copyright (c) 2020, 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
|
||||
|
||||
// This test verifies that cyclic type alias definitions cause a compile-time
|
||||
// error, when the cycle occurs via the bound, even if the bound variable is not
|
||||
// used in the expansion.
|
||||
|
||||
typedef T1<X extends T1<Never>> = int;
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
|
||||
// Note: when the cycle involves two typedefs, the CFE only reports an error for
|
||||
// one of them; that's ok.
|
||||
typedef T2<X extends T3> = int;
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
|
||||
typedef T3 = T2<Never>;
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
|
||||
typedef T4<X extends List<T4<Never>>> = int;
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
|
||||
typedef T5<X extends T5<Never> Function()> = int;
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
|
||||
typedef T6<X extends void Function(T6<Never>)> = int;
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
|
||||
// Note: not an error because T7 is the name of the parameter.
|
||||
typedef T7<X extends void Function(int T7)> = int;
|
||||
|
||||
typedef T8<X extends void Function([T8<Never>])> = int;
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
|
||||
// Note: not an error because T9 is the name of the parameter.
|
||||
typedef T9<X extends void Function([int T9])> = int;
|
||||
|
||||
typedef T10<X extends void Function({T10<Never> x})> = int;
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
|
||||
// Note: not an error because T11 is the name of the parameter.
|
||||
typedef T11<X extends void Function({int T11})> = int;
|
||||
|
||||
// Note: we have to use `void Function<...>() Function()` because a generic
|
||||
// function can't directly be used as a bound.
|
||||
typedef T12<X extends void Function<Y extends T12<Never>>() Function()> = int;
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
|
@ -0,0 +1,70 @@
|
|||
// Copyright (c) 2020, 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
|
||||
|
||||
// This test verifies that cyclic type alias definitions cause a compile-time
|
||||
// error, when the cycle occurs via the expansion of the type.
|
||||
|
||||
typedef T1 = List<T1>;
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
|
||||
typedef T2 = List<T3>;
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
|
||||
// Note: when the cycle involves two typedefs, the CFE only reports an error for
|
||||
// one of them; that's ok.
|
||||
typedef T3 = List<T2>;
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
|
||||
typedef T4 = T4;
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
|
||||
typedef T5 = T5?;
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
|
||||
typedef T6 = List<T6 Function()>;
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
|
||||
typedef T7 = List<void Function(T7)>;
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
|
||||
// Note: not an error because T8 is the name of the parameter.
|
||||
typedef T8 = List<void Function(int T8)>;
|
||||
|
||||
typedef T9 = List<void Function([T9])>;
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
|
||||
// Note: not an error because T10 is the name of the parameter.
|
||||
typedef T10 = List<void Function([int T10])>;
|
||||
|
||||
typedef T11 = List<void Function({T11 x})>;
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
|
||||
// Note: not an error because T12 is the name of the parameter.
|
||||
typedef T12 = List<void Function({int T12})>;
|
||||
|
||||
// Note: we have to use `void Function<...>() Function()` because a generic
|
||||
// function can't directly be used as a type argument.
|
||||
typedef T13 = List<void Function<X extends T13>() Function()>;
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
Loading…
Reference in a new issue