diff --git a/LanguageFeatures/Extension-types/static_analysis_extension_types_A34_t01.dart b/LanguageFeatures/Extension-types/static_analysis_extension_types_A34_t01.dart new file mode 100644 index 0000000000..b2600a983e --- /dev/null +++ b/LanguageFeatures/Extension-types/static_analysis_extension_types_A34_t01.dart @@ -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 sgrekhov22@gmail.com + +typedef NeverAlias = Never; + +extension type ET1(Never _) {} +// ^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + +extension type ET2(NeverAlias _) {} +// ^^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + +main() { + print(ET1); + print(ET2); +} diff --git a/LanguageFeatures/Extension-types/static_analysis_extension_types_A34_t02.dart b/LanguageFeatures/Extension-types/static_analysis_extension_types_A34_t02.dart new file mode 100644 index 0000000000..60f53d6f29 --- /dev/null +++ b/LanguageFeatures/Extension-types/static_analysis_extension_types_A34_t02.dart @@ -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) {}, E` 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 sgrekhov22@gmail.com + +import '../../Utils/static_type_helper.dart'; + +typedef NeverAlias = Never; + +extension type ET(X _) {} + +main() { + ET? et1; + et1.expectStaticType?>>(); + ET? et2; + et2.expectStaticType?>>(); +}