Skip to content

Commit

Permalink
dart-lang#2559. Add augmenting types tests. Part 5
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrekhov committed Mar 28, 2024
1 parent 947af2a commit 2384e8b
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// 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:
/// ...
/// - An augmenting extension declares an on clause. We don't allow filling this
/// in for extensions, it must be on the original declaration. This
/// restriction could be lifted later if we have a compelling use case, as
/// there is no fundamental reason it cannot be allowed, although it would be
/// a parse error today to have an extension with no on clause.
///
/// @description Checks that it is a compile-time error if an augmenting
/// extension declares an `on` clause
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=macros

import augment 'augmenting_types_A04_t01_lib.dart';

class C {}

extension Ext on C {
String foo() => "Extension Ext on C";
}

extension on C {
String bar() => "Extension on C";
}

main() {
print(C);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// 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:
/// ...
/// - An augmenting extension declares an on clause. We don't allow filling this
/// in for extensions, it must be on the original declaration. This
/// restriction could be lifted later if we have a compelling use case, as
/// there is no fundamental reason it cannot be allowed, although it would be
/// a parse error today to have an extension with no on clause.
///
/// @description Checks that it is a compile-time error if an augmenting
/// extension declares an `on` clause
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=macros

augment library 'augmenting_types_A04_t01.dart';

augment extension on C {
// ^^
// [analyzer] unspecified
// [cfe] unspecified
}

augment extension Ext on C {
// ^^
// [analyzer] unspecified
// [cfe] unspecified
}

0 comments on commit 2384e8b

Please sign in to comment.