-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
LanguageFeatures/Extension-types/static_analysis_extension_types_A34_t01.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
25 changes: 25 additions & 0 deletions
25
LanguageFeatures/Extension-types/static_analysis_extension_types_A34_t02.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>?>>(); | ||
} |