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

Fixes #2123. Update Superclasses tests. #2124

Merged
merged 2 commits into from
Jul 12, 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
10 changes: 6 additions & 4 deletions Language/Classes/Superclasses/extends_clause_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
// 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 The superclass of a class C that has a with clause with
/// M1,...,Mk and an extends clause extends S is the application of mixin
/// Mk*...*M1 to S. If no with clause is specified then the extends clause of a
/// class C specifies its superclass.
/// @assertion The superclass S′ of a class C whose declaration has a with
/// clause with M1, . . . , Mk and an extends clause extends S is the abstract
/// class obtained by application of mixin composition Mk ∗ · · · ∗ M1 to S. The
/// name S′ is a fresh identifier. If no with clause is specified then the
/// extends clause of a class C specifies its superclass.
///
/// @description Checks that a class can indeed specify a superclass using the
/// extends clause and an instance of this class is also an instance of that
/// superclass.
Expand Down
10 changes: 6 additions & 4 deletions Language/Classes/Superclasses/extends_clause_t02.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
// 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 The superclass of a class C that has a with clause with
/// M1,...,Mk and an extends clause extends S is the application of mixin
/// Mk*...*M1 to S. If no with clause is specified then the extends clause of a
/// class C specifies its superclass.
/// @assertion The superclass S′ of a class C whose declaration has a with
/// clause with M1, . . . , Mk and an extends clause extends S is the abstract
/// class obtained by application of mixin composition Mk ∗ · · · ∗ M1 to S. The
/// name S′ is a fresh identifier. If no with clause is specified then the
/// extends clause of a class C specifies its superclass.
///
/// @description Checks that a class can indeed specify a superclass using the
/// extends clause and an instance of this class is also an instance of that
/// superclass. Test type aliases
Expand Down
1 change: 1 addition & 0 deletions Language/Classes/Superclasses/no_extends_clause_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
/// @assertion If no extends clause is specified, then either:
/// - C is Object, which has no superclass. OR
/// - The superclass of C is Object.
///
/// @description Checks that in absence of an extends clause, a class still
/// extends Object.
/// @author msyabro
Expand Down
16 changes: 16 additions & 0 deletions Language/Classes/Superclasses/superclass_lib.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) 2023, 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 It is a compile-time error if the type in the extends clause of a
/// class C is a type variable, a type alias that does not denote a class, an
/// enumerated type, a deferred type, type dynamic, or type FutureOr<T> for any
/// T.
///
/// @description Checks that it is a compile-time error if a deferred type is
/// used as a superclass. This library will be used as the deferred import.
/// @author sgrekhov22@gmail.com

library superclass_lib;

class A {}
4 changes: 2 additions & 2 deletions Language/Classes/Superclasses/superclass_of_itself_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
// 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 It is a compile-time error if a class C is a superclass of itself.
/// @assertion It is a compile-time error if a class C is a superclass of itself
///
/// @description Checks that it is a compile-time error if a class references
/// itself in its extends clause.
/// @author pagolubev


class A extends A {}
// ^
// [analyzer] unspecified
Expand Down
4 changes: 2 additions & 2 deletions Language/Classes/Superclasses/superclass_of_itself_t02.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
// 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 It is a compile-time error if a class C is a superclass of itself.
/// @assertion It is a compile-time error if a class C is a superclass of itself
///
/// @description Checks that it is a compile-time error if a class attempts to
/// extend itself indirectly, by transition.
/// @author msyabro


class A extends D {}
// ^
// [analyzer] unspecified
Expand Down
3 changes: 2 additions & 1 deletion Language/Classes/Superclasses/superclass_of_itself_t03.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// 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 It is a compile-time error if a class C is a superclass of itself.
/// @assertion It is a compile-time error if a class C is a superclass of itself
///
/// @description Checks that it is a compile-time error if a class references
/// itself in its extends clause. Test type aliases
/// @author sgrekhov@unipro.ru
Expand Down
3 changes: 2 additions & 1 deletion Language/Classes/Superclasses/superclass_of_itself_t04.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// 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 It is a compile-time error if a class C is a superclass of itself.
/// @assertion It is a compile-time error if a class C is a superclass of itself
///
/// @description Checks that it is a compile-time error if a class attempts to
/// extend itself indirectly, by transition. Test type aliases
/// @author sgrekhov@unipro.ru
Expand Down
1 change: 1 addition & 0 deletions Language/Classes/Superclasses/transition_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
/// @assertion A class S is a superclass of a class C iff either:
/// - S is the superclass of C, or
/// - S is a superclass of a class S0 and S0 is a superclass of C.
///
/// @description Checks that the superclass-subclass relationship is transitive.
/// @author rodionov

Expand Down
1 change: 1 addition & 0 deletions Language/Classes/Superclasses/transition_t02.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
/// @assertion A class S is a superclass of a class C iff either:
/// - S is the superclass of C, or
/// - S is a superclass of a class S0 and S0 is a superclass of C.
///
/// @description Checks that the superclass-subclass relationship is transitive.
/// Test type aliases
/// @author sgrekhov@unipro.ru
Expand Down
15 changes: 8 additions & 7 deletions Language/Classes/Superclasses/wrong_superclass_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
// 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 It is a compile-time error if the extends clause of a class C
/// specifies an enumerated type, a malformed type or a deferred type as a
/// superclass.
/// @description Checks that it is a compile-time error when the type expression
/// in a class's extends clause denotes an unavailable type.
/// @assertion It is a compile-time error if the type in the extends clause of a
/// class C is a type variable, a type alias that does not denote a class, an
/// enumerated type, a deferred type, type dynamic, or type FutureOr<T> for any
/// T.
///
/// @description Checks that it is a compile-time error if a type expression in
/// a class's `extends` clause denotes an unavailable type.
/// @author pagolubev


class A extends Unavailable {}
// ^
// ^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

Expand Down
35 changes: 26 additions & 9 deletions Language/Classes/Superclasses/wrong_superclass_t02.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,38 @@
// 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 It is a compile-time error if the extends clause of a class C
/// specifies an enumerated type, a malformed type or a deferred type as a
/// superclass.
/// @description Checks that it is a compile-time error when the type expression
/// in a class's extends clause denotes a function type.
/// @assertion It is a compile-time error if the type in the extends clause of a
/// class C is a type variable, a type alias that does not denote a class, an
/// enumerated type, a deferred type, type dynamic, or type FutureOr<T> for any
/// T.
///
/// @description Checks that it is a compile-time error if a type expression in
/// a class's `extends` clause denotes a type alias that does not denote a class
/// @author rodionov

enum E {e1, e2}

typedef void foo();
typedef EAlias = E;
typedef void Foo();
typedef D = dynamic;

class A extends foo {}
// ^
class A1 extends Foo {}
// ^^^
// [analyzer] unspecified
// [cfe] unspecified

class A2 extends EAlias {}
// ^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

class A3 extends D {}
// ^
// [analyzer] unspecified
// [cfe] unspecified

main() {
new A();
A1();
A2();
A3();
}
17 changes: 9 additions & 8 deletions Language/Classes/Superclasses/wrong_superclass_t03.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@
// 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 It is a compile-time error if the extends clause of a class C
/// specifies an enumerated type, a malformed type or a deferred type as a
/// superclass.
/// @assertion It is a compile-time error if the type in the extends clause of a
/// class C is a type variable, a type alias that does not denote a class, an
/// enumerated type, a deferred type, type dynamic, or type FutureOr<T> for any
/// T.
///
/// @description Checks that it is a compile-time error when the type expression
/// in a class's extends clause denotes a variable name.
/// in a class's extends clause denotes a variable.
/// @author rodionov

int Foo = 42;

int foo = 42;

class A extends foo {}
// ^
class A extends Foo {}
// ^^^
// [analyzer] unspecified
// [cfe] unspecified

Expand Down
15 changes: 8 additions & 7 deletions Language/Classes/Superclasses/wrong_superclass_t04.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
// 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 It is a compile-time error if the extends clause of a class C
/// specifies an enumerated type, a malformed type or a deferred type as a
/// superclass.
/// @description Checks that it is a compile-time error if static type is used
/// @assertion It is a compile-time error if the type in the extends clause of a
/// class C is a type variable, a type alias that does not denote a class, an
/// enumerated type, a deferred type, type dynamic, or type FutureOr<T> for any
/// T.
///
/// @description Checks that it is a compile-time error if type dynamic is used
/// as a superclass
/// @author sgrekhov@unipro.ru


class A extends int {}
// ^
class A extends dynamic {}
// ^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

Expand Down
13 changes: 7 additions & 6 deletions Language/Classes/Superclasses/wrong_superclass_t05.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
// 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 It is a compile-time error if the extends clause of a class C
/// specifies an enumerated type, a malformed type or a deferred type as a
/// superclass.
/// @description Checks that it is a compile-time error when the type expression
/// in a class's extends clause denotes a type variable.
/// @assertion It is a compile-time error if the type in the extends clause of a
/// class C is a type variable, a type alias that does not denote a class, an
/// enumerated type, a deferred type, type dynamic, or type FutureOr<T> for any
/// T.
///
/// @description Checks that it is a compile-time error if a type expression
/// in a class's `extends` clause denotes a type variable.
/// @author rodionov


class A<T> extends T {}
// ^
// [analyzer] unspecified
Expand Down
29 changes: 19 additions & 10 deletions Language/Classes/Superclasses/wrong_superclass_t06.dart
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// Copyright (c) 2023, 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 It is a compile-time error if the extends clause of a class C
/// specifies an enumerated type, a malformed type or a deferred type as a
/// superclass.
/// @description Checks that it is a compile-time error if var is used as a
/// superclass
/// @author sgrekhov@unipro.ru
/// @assertion It is a compile-time error if the type in the extends clause of a
/// class C is a type variable, a type alias that does not denote a class, an
/// enumerated type, a deferred type, type dynamic, or type FutureOr<T> for any
/// T.
///
/// @description Checks that it is a compile-time error if `FutureOr<T>` is used
/// as a superclass
/// @author sgrekhov22@gmail.com

class A {}

class A extends var {}
// ^
class C1<T> extends FutureOr<T> {}
// ^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

class C2 extends FutureOr<A> {}
// ^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

main() {
new A();
C1();
C2();
}
14 changes: 7 additions & 7 deletions Language/Classes/Superclasses/wrong_superclass_t07.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
// 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 It is a compile-time error if the extends clause of a class C
/// specifies an enumerated type, a malformed type or a deferred type as a
/// superclass.
/// @description Checks that it is a compile-time error if enumeration is used
/// as a superclass
/// @assertion It is a compile-time error if the type in the extends clause of a
/// class C is a type variable, a type alias that does not denote a class, an
/// enumerated type, a deferred type, type dynamic, or type FutureOr<T> for any
/// T.
///
/// @description Checks that it is a compile-time error if an enumerated type is
/// used as a superclass
/// @author sgrekhov@unipro.ru



enum E {a, b, c}

class A extends E {}
Expand Down
25 changes: 11 additions & 14 deletions Language/Classes/Superclasses/wrong_superclass_t08.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,23 @@
// 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 It is a compile-time error if the extends clause of a class C
/// specifies an enumerated type, a malformed type or a deferred type as a
/// superclass.
/// @description Checks that it is a compile-time error if deferred type is used
/// as a superclass
/// @assertion It is a compile-time error if the type in the extends clause of a
/// class C is a type variable, a type alias that does not denote a class, an
/// enumerated type, a deferred type, type dynamic, or type FutureOr<T> for any
/// T.
///
/// @description Checks that it is a compile-time error if a deferred type is
/// used as a superclass
/// @Issue 42031
/// @author sgrekhov@unipro.ru

import "superclass_lib.dart" deferred as lib;


import "dart:core" deferred as core;
// ^
class C extends lib.A {}
// ^^^^^
// [analyzer] unspecified
// [cfe] unspecified

class A extends core.ArgumentError {}
// ^
// [analyzer] unspecified

main() {
new A();
new core.ArgumentError();
C();
}