Skip to content

Commit

Permalink
dart-lang#2559. Add augmenting types tests. Part 3
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrekhov committed Mar 14, 2024
1 parent 5c18c22 commit 4c7fe0a
Show file tree
Hide file tree
Showing 6 changed files with 174 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (c) 2024, 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 augmenting type declares an extends clause, but one was already
/// present. We don't allow overwriting an existing extends, but one can be
/// filled in if it wasn't present originally.
///
/// @description Checks that it is a compile-time error if an augmenting type
/// declares an extends clause, but one was already present
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=macros

import augment 'augmenting_types_A03_t01_lib.dart';

class A {}
class B extends A {}
class C extends B {}

main() {
print(C);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (c) 2024, 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 augmenting type declares an extends clause, but one was already
/// present. We don't allow overwriting an existing extends, but one can be
/// filled in if it wasn't present originally.
///
/// @description Checks that it is a compile-time error if an augmenting type
/// declares an extends clause, but one was already present
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=macros

library augment 'augmenting_types_A03_t01.dart';

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

class D {}

augment class C extends D {}
// ^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) 2024, 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 augmenting type declares an extends clause, but one was already
/// present. We don't allow overwriting an existing extends, but one can be
/// filled in if it wasn't present originally.
///
/// @description Checks that it is a compile-time error if an augmenting type
/// declares an extends clause, but one was already present. Test the same
/// `extends` class
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=macros

import augment 'augmenting_types_A03_t02_lib.dart';

class A {}
class C extends A {}
typedef AAlias = A;

main() {
print(C);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright (c) 2024, 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 augmenting type declares an extends clause, but one was already
/// present. We don't allow overwriting an existing extends, but one can be
/// filled in if it wasn't present originally.
///
/// @description Checks that it is a compile-time error if an augmenting type
/// declares an extends clause, but one was already present. Test the same
/// `extends` class
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=macros

library augment 'augmenting_types_A03_t02.dart';

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

augment class C extends AAlias {}
// ^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright (c) 2024, 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 augmenting type declares an extends clause, but one was already
/// present. We don't allow overwriting an existing extends, but one can be
/// filled in if it wasn't present originally.
///
/// @description Checks that it is a compile-time error if an augmenting type
/// declares an extends clause, but one was already present. Test
/// `extends Object` case
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=macros

import augment 'augmenting_types_A03_t03_lib.dart';

typedef ObjectAlias = Object;

class C1 extends Object {}
class C2 extends ObjectAlias {}

main() {
print(C1);
print(C2);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright (c) 2024, 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 augmenting type declares an extends clause, but one was already
/// present. We don't allow overwriting an existing extends, but one can be
/// filled in if it wasn't present originally.
///
/// @description Checks that it is a compile-time error if an augmenting type
/// declares an extends clause, but one was already present. Test
/// `extends Object` case
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=macros

library augment 'augmenting_types_A03_t03.dart';

augment class C1 extends Object {}
// ^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

augment class C1 extends ObjectAlias {}
// ^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

augment class C2 extends Object {}
// ^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

augment class C2 extends ObjectAlias {}
// ^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

0 comments on commit 4c7fe0a

Please sign in to comment.