Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2386. Rename well-bounded tests. Update descriptions #2405

Merged
merged 4 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions Language/Generics/Superbounded_types/class_A01_t09.dart

This file was deleted.

22 changes: 0 additions & 22 deletions Language/Generics/Superbounded_types/typedef3_A01_t05.dart

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,26 @@
// 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.

/// @assertion Any use of a type [T] which is not well-bounded is a
/// @assertion Any use of a type `T` which is not well-bounded is a
/// compile-time error.
/// @description Checks that compile error is not thrown when variable with super
/// bounded type parameter is declared
///
/// @description Checks that it is not an error if a variable with a
/// well-bounded type parameter is declared
/// @Issue 42415, 42429
/// @author iarkh@unipro.ru


class A<T extends A<T>> {}

main() {
A a1;

A<dynamic> a2;
A<Object?> a3;
A<Object> a4;
// ^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

A<void> a5;
A<Never> a6;

A<A<dynamic>> a7;
A<A<Object?>> a8;
A<A<Object>> a9;
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

A<A<void>> a10;
A<A<Never>> a11;

A<A> a12;
A<A<A>> a13;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@
// 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.

/// @assertion Any use of a type [T] which is not well-bounded is a
/// @assertion Any use of a type `T` which is not well-bounded is a
/// compile-time error.
/// @description Checks that compile error is thrown if variable type is not well
/// bounded
///
/// @description Checks that it is a compile-time error to declare a variable
/// with a type parameter which is not well-bounded
/// @author iarkh@unipro.ru

class A<T extends A<T>> {}

main() {
A<Object> a0;
// ^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
A<int> a1;
// ^^^
// [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
Expand All @@ -23,5 +28,9 @@ main() {
A<A<A<int>>> a3;
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
A<A<Object>> a4;
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,41 @@
// 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.

/// @assertion Any use of a type [T] which is not well-bounded is a
/// @assertion Any use of a type `T` which is not well-bounded is a
/// compile-time error.
/// @description Checks that compile error is thrown when class with not well
/// bounded type parameter is declared
///
/// @description Checks that it is a compile-time error when a class has a type
/// parameter bound which is a raw type that does not have simple bounds, and
/// when a class has a type parameter bound which is malbounded.
/// @author iarkh@unipro.ru

class A<T extends A<T>> {}

// Here `B1` is a well-bounded type, but the bound is a raw type `A` that
// doesn't have simple bounds, and that's a compile-time error.
class B1<X extends A> {}
// ^
// [cfe] Generic type 'A' can't be used without type arguments in a type variable bound.
// ^
// [analyzer] COMPILE_TIME_ERROR.NOT_INSTANTIATED_BOUND

// Same for B2, it's well-bounded but the bound is a raw type without simple
// bound
class B2<X extends A<A>> {}
// ^
// [cfe] Generic type 'A' can't be used without type arguments in a type variable bound.
// ^
// [analyzer] COMPILE_TIME_ERROR.NOT_INSTANTIATED_BOUND
class B3<X extends A<int>> {}

class B3<X extends A<int>> {} // A<int> is a malbounded type
// ^
// [cfe] Type argument 'int' doesn't conform to the bound 'A<T>' of the type variable 'T' on 'A'.
// ^^^
// [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS

main() {
print(A);
print(B1);
print(B2);
print(B3);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
// 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.

/// @assertion Any use of a type [T] which is not well-bounded is a
/// @assertion Any use of a type `T` which is not well-bounded is a
/// compile-time error.
/// @description Checks that compile error is not thrown when class with type
/// parameter which extends super bounded type is declared
///
/// @description Checks that it is not an error to declare a class with a type
/// parameter whose bound is a super-bounded type
/// @Issue 37034
/// @author iarkh@unipro.ru


class A<T extends A<T>> {}

class B1<X extends A<Object?>> {}
Expand All @@ -18,4 +18,8 @@ class B3<X extends A<void>> {}
class B4<X extends A<Never>> {}

main() {
B1();
B2();
B3();
B4();
}
27 changes: 27 additions & 0 deletions Language/Generics/Superbounded_types/well_bounded_A01_t05.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// 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.

/// @assertion Any use of a type `T` which is not well-bounded is a
/// compile-time error.
///
/// @description Checks that it is not an error to have a class with a
/// super-bounded type parameter whose bound is a super-bounded type.
/// @Issue 37034, 37050
/// @author iarkh@unipro.ru

class A<T extends A<T>> {}

class B1<X extends A<X>> {}
class B2<X extends A<A<Object?>>> {}
class B3<X extends A<A<dynamic>>> {}
class B4<X extends A<A<void>>> {}
class B5<X extends A<A<Never>>> {}

main() {
B1<Never>();
B2();
B3();
B4();
B5();
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,41 @@
// 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.

/// @assertion Any use of a type [T] which is not well-bounded is a
/// @assertion Any use of a type `T` which is not well-bounded is a
/// compile-time error.
/// @description Checks that compile error is thrown when function with not well
/// bounded type parameter is declared
///
/// @description Checks that it is a compile-time error when a function has a
/// type parameter bound which is a raw type that does not have simple bounds,
/// and when a function has a type parameter bound which is malbounded.
/// @author iarkh@unipro.ru

class A<T extends A<T>> {}

// Here the function is a well-bounded but the bound is a raw type A<A<dynamic>>
// that doesn't have simple bounds
void testme1<X extends A>() {}
// ^
// [cfe] Generic type 'A' can't be used without type arguments in a type variable bound.
// ^
// [analyzer] COMPILE_TIME_ERROR.NOT_INSTANTIATED_BOUND

// Same here, the function is a well-bounded but the bound is a raw type without
// simple bound
void testme2<X extends A<A>>() {}
// ^
// [cfe] Generic type 'A' can't be used without type arguments in a type variable bound.
// ^
// [analyzer] COMPILE_TIME_ERROR.NOT_INSTANTIATED_BOUND
void testme3<X extends A<int>>() {}


void testme3<X extends A<int>>() {} // A<int> is a malbounded type
// ^
// [cfe] Type argument 'int' doesn't conform to the bound 'A<T>' of the type variable 'T' on 'A'.
// ^^^
// [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS

main() {
print(testme1);
print(testme2);
print(testme3);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
// 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.

/// @assertion Any use of a type [T] which is not well-bounded is a
/// @assertion Any use of a type `T` which is not well-bounded is a
/// compile-time error.
/// @description Checks that compile error is not thrown when function with well
/// bounded type parameter is declared
///
/// @description Checks that it is not an error when a function with a type
/// parameter whose bound is super-bounded type is declared
/// @Issue 36959, 37028, 37050
/// @author iarkh@unipro.ru


class A<T extends A<T>> {}

void testme1<X extends A<dynamic>>() {}
Expand All @@ -22,4 +22,13 @@ void testme6<X extends A<A<Object?>>>() {}
void testme7<X extends A<A<Never>>>() {}
void testme8<X extends A<A<void>>>() {}

main() {}
main() {
testme1();
testme2();
testme3();
testme4();
testme5();
testme6();
testme7();
testme8();
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
// 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.

/// @assertion Any use of a type [T] which is not well-bounded is a
/// @assertion Any use of a type `T` which is not well-bounded is a
/// compile-time error.
/// @description Checks that compile error is not thrown when call generic
/// function with well bounded type parameter
///
/// @description Checks that it is not an error to call a generic function with
/// a well-bounded type parameter
/// @author iarkh@unipro.ru


class A<T> {}
void testme<X extends num>() {}

main() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
// 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.

/// @assertion Any use of a type [T] which is not well-bounded is a
/// @assertion Any use of a type `T` which is not well-bounded is a
/// compile-time error.
/// @description Checks that compile error is thrown when call generic
/// function with type parameter which is not well bounded
///
/// @description Checks that it is a compile-time error to call a generic
/// function with an actual type argument which does not satisfy the bounds.
/// @author iarkh@unipro.ru


class A<T> {}
void testme<X extends num>() {}

main() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
// 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.

/// @assertion Any use of a type [T] which is not well-bounded is a
/// @assertion Any use of a type `T` which is not well-bounded is a
/// compile-time error.
/// @description Checks that compile error is not thrown when call generic
/// function with two dependant well bounded type parameters
///
/// @description Checks that it is not an error to call a generic function with
/// two dependent type arguments that satisfy the bounds.
/// @author iarkh@unipro.ru


class A<X extends A<X>> {}
void testme<X extends Y, Y extends A<X>>() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
// 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.

/// @assertion Any use of a type [T] which is not well-bounded is a
/// @assertion Any use of a type `T` which is not well-bounded is a
/// compile-time error.
/// @description Checks that compile error is thrown when call generic
/// function with two dependant type parameters which are not bounded well.
///
/// @description Checks that it is a compile-time to call a generic function
/// with two dependent type arguments that do not satisfy the bounds.
/// @Issue 37061
/// @author iarkh@unipro.ru


class A<X extends A<X>> {}
void testme<X extends Y, Y extends A<X>>() {}

Expand Down
Loading