| // Copyright (c) 2023, 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 rule for <extensionTypeDeclaration> is added to the grammar, |
| /// along with some rules for elements used in extension type declarations: |
| /// |
| /// <extensionTypeDeclaration> ::= |
| /// 'extension' 'type' 'const'? <typeIdentifier> <typeParameters>? |
| /// <representationDeclaration> <interfaces>? |
| /// '{' |
| /// (<metadata> <extensionTypeMemberDeclaration>)* |
| /// '}' |
| /// |
| /// <representationDeclaration> ::= |
| /// ('.' <identifierOrNew>)? '(' <metadata> <type> <identifier> ')' |
| /// |
| /// <identifierOrNew> ::= <identifier> | 'new' |
| /// |
| /// <extensionTypeMemberDeclaration> ::= <classMemberDefinition> |
| /// |
| /// @description Checks that a `representationDeclaration` may have form |
| /// `identifier`.new |
| /// @author sgrekhov22@gmail.com |
| |
| import "../../Utils/expect.dart"; |
| |
| extension type ET.new(int id) {} |
| |
| main() { |
| ET et1 = ET(1); |
| Expect.equals(1, et1.id); |
| |
| ET et2 = ET.new(2); |
| Expect.equals(2, et2.id); |
| } |