diff --git a/LanguageFeatures/Extension-methods/syntax_name_t01.dart b/LanguageFeatures/Extension-methods/syntax_name_t01.dart index c58ac78f7f..ddaf865501 100644 --- a/LanguageFeatures/Extension-methods/syntax_name_t01.dart +++ b/LanguageFeatures/Extension-methods/syntax_name_t01.dart @@ -2,28 +2,21 @@ // 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 an extension declaration is a top-level declaration with a grammar -/// similar to: +/// @assertion an extension declaration is a top-level declaration with a +/// grammar similar to: /// ::= /// `extension' ? ? `on' `?'? `{' /// memberDeclaration* /// `}' /// Such a declaration introduces its name (the identifier) into the surrounding /// scope. The name does not denote a type, but it can be used to denote the -/// extension itself in various places. The name can be hidden or shown in import -/// or export declarations. +/// extension itself in various places. The name can be hidden or shown in +/// import export declarations. /// /// @description Check that the name does not denote a type /// @author sgrekhov@unipro.ru - - -extension MyFancyList on List { - int get doubleLength => this.length * 2; - List operator-() => this.reversed.toList(); - List> split(int at) => >[this.sublist(0, at), this.sublist(at)]; - static String get className => "List"; -} +extension MyFancyList on List {} main() { MyFancyList list = ["Lily", "was", "here"]; diff --git a/LanguageFeatures/Extension-methods/syntax_name_t02.dart b/LanguageFeatures/Extension-methods/syntax_name_t02.dart index 836295f56c..4c9e2b53fc 100644 --- a/LanguageFeatures/Extension-methods/syntax_name_t02.dart +++ b/LanguageFeatures/Extension-methods/syntax_name_t02.dart @@ -2,22 +2,20 @@ // 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 an extension declaration is a top-level declaration with a grammar -/// similar to: +/// @assertion an extension declaration is a top-level declaration with a +/// grammar similar to: /// ::= /// `extension' ? ? `on' `?'? `{' /// memberDeclaration* /// `}' /// Such a declaration introduces its name (the identifier) into the surrounding /// scope. The name does not denote a type, but it can be used to denote the -/// extension itself in various places. The name can be hidden or shown in import -/// or export declarations. +/// extension itself in various places. The name can be hidden or shown in +/// import export declarations. /// /// @description Check that the name does not denote a type /// @author sgrekhov@unipro.ru - - import "my_fancy_list_lib.dart"; main() { diff --git a/LanguageFeatures/Extension-methods/syntax_name_t03.dart b/LanguageFeatures/Extension-methods/syntax_name_t03.dart index 8593c8efb1..339c28edef 100644 --- a/LanguageFeatures/Extension-methods/syntax_name_t03.dart +++ b/LanguageFeatures/Extension-methods/syntax_name_t03.dart @@ -2,23 +2,21 @@ // 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 an extension declaration is a top-level declaration with a grammar -/// similar to: +/// @assertion an extension declaration is a top-level declaration with a +/// grammar similar to: /// ::= /// `extension' ? ? `on' `?'? `{' /// memberDeclaration* /// `}' /// Such a declaration introduces its name (the identifier) into the surrounding /// scope. The name does not denote a type, but it can be used to denote the -/// extension itself in various places. The name can be hidden or shown in import -/// or export declarations. +/// extension itself in various places. The name can be hidden or shown in +/// import export declarations. /// /// @description Check that the name can be hidden or shown in import or export /// declarations. /// @author sgrekhov@unipro.ru - - import "my_fancy_list_lib.dart" hide MyFancyList; main() { diff --git a/LanguageFeatures/Extension-methods/syntax_name_t04.dart b/LanguageFeatures/Extension-methods/syntax_name_t04.dart index 8bf1dd961f..7cf78e6077 100644 --- a/LanguageFeatures/Extension-methods/syntax_name_t04.dart +++ b/LanguageFeatures/Extension-methods/syntax_name_t04.dart @@ -2,23 +2,21 @@ // 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 an extension declaration is a top-level declaration with a grammar -/// similar to: +/// @assertion an extension declaration is a top-level declaration with a +/// grammar similar to: /// ::= /// `extension' ? ? `on' `?'? `{' /// memberDeclaration* /// `}' /// Such a declaration introduces its name (the identifier) into the surrounding /// scope. The name does not denote a type, but it can be used to denote the -/// extension itself in various places. The name can be hidden or shown in import -/// or export declarations. +/// extension itself in various places. The name can be hidden or shown in +/// import export declarations. /// /// @description Check that the name can be hidden or shown in import or export /// declarations. /// @author sgrekhov@unipro.ru - - import "../../Utils/expect.dart"; import "my_fancy_list_lib.dart" show MyFancyList; diff --git a/LanguageFeatures/Extension-methods/syntax_name_t05.dart b/LanguageFeatures/Extension-methods/syntax_name_t05.dart new file mode 100644 index 0000000000..102651c976 --- /dev/null +++ b/LanguageFeatures/Extension-methods/syntax_name_t05.dart @@ -0,0 +1,30 @@ +// 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 an extension declaration is a top-level declaration with a +/// grammar similar to: +/// ::= +/// `extension' ? ? `on' `?'? `{' +/// memberDeclaration* +/// `}' +/// Such a declaration introduces its name (the identifier) into the surrounding +/// scope. The name does not denote a type, but it can be used to denote the +/// extension itself in various places. The name can be hidden or shown in +/// import export declarations. +/// +/// @description Check that it is a compile-time error to create a type alias +/// for an extension +/// @author sgrekhov22@gmail.com + +class A {} +extension Ext on A {} + +typedef ExtAlias = Ext; +// ^^^ +// [analyzer] unspecified +// [cfe] unspecified + +main() { + print(A); +}