Skip to content

Commit

Permalink
#1400. Add extension types tests for bottom types (#2944)
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrekhov authored Oct 23, 2024
1 parent bdab922 commit 61eb71a
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// 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 A compile-time error occurs if the representation type of an
/// extension type declaration is a bottom type.
///
/// @description Check that it is a compile-time error if the representation
/// type of an extension type declaration is a bottom type.
/// @author [email protected]
typedef NeverAlias = Never;

extension type ET1(Never _) {}
// ^^^^^
// [analyzer] unspecified
// [cfe] unspecified

extension type ET2(NeverAlias _) {}
// ^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

main() {
print(ET1);
print(ET2);
}
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 Note that it is still possible for the instantiated
/// representation type of a given extension type to be a bottom type. For
/// example, assuming extension type `E<X>(X x) {}, E<Never>` would be an
/// extension type whose instantiated representation type is `Never`.
///
/// @description Check that it is not an error to have an instantiated
/// representation type to be a bottom type.
/// @author [email protected]
import '../../Utils/static_type_helper.dart';

typedef NeverAlias = Never;

extension type ET<X>(X _) {}

main() {
ET<Never>? et1;
et1.expectStaticType<Exactly<ET<Never>?>>();
ET<NeverAlias>? et2;
et2.expectStaticType<Exactly<ET<Never>?>>();
}

0 comments on commit 61eb71a

Please sign in to comment.