| // 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. |
| |
| import 'package:analyzer/dart/element/element.dart'; |
| import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| |
| import '../../dart/resolution/node_text_expectations.dart'; |
| import '../element_text.dart'; |
| import '../elements_base.dart'; |
| |
| main() { |
| defineReflectiveSuite(() { |
| defineReflectiveTests(EnumElementTest_keepLinking); |
| defineReflectiveTests(EnumElementTest_fromBytes); |
| defineReflectiveTests(EnumElementTest_augmentation_keepLinking); |
| defineReflectiveTests(EnumElementTest_augmentation_fromBytes); |
| defineReflectiveTests(UpdateNodeTextExpectations); |
| }); |
| } |
| |
| abstract class EnumElementTest extends ElementsBaseTest { |
| test_codeRange_enum() async { |
| var library = await buildLibrary(''' |
| enum E { |
| aaa, bbb, ccc |
| } |
| '''); |
| configuration.withCodeRanges = true; |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| enums |
| enum E @5 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| codeOffset: 0 |
| codeLength: 26 |
| supertype: Enum |
| fields |
| static const enumConstant aaa @11 |
| reference: <testLibraryFragment>::@enum::E::@field::aaa |
| enclosingElement: <testLibraryFragment>::@enum::E |
| codeOffset: 11 |
| codeLength: 3 |
| type: E |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E |
| staticElement: <testLibraryFragment>::@enum::E::@constructor::new |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| static const enumConstant bbb @16 |
| reference: <testLibraryFragment>::@enum::E::@field::bbb |
| enclosingElement: <testLibraryFragment>::@enum::E |
| codeOffset: 16 |
| codeLength: 3 |
| type: E |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E |
| staticElement: <testLibraryFragment>::@enum::E::@constructor::new |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| static const enumConstant ccc @21 |
| reference: <testLibraryFragment>::@enum::E::@field::ccc |
| enclosingElement: <testLibraryFragment>::@enum::E |
| codeOffset: 21 |
| codeLength: 3 |
| type: E |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E |
| staticElement: <testLibraryFragment>::@enum::E::@constructor::new |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: aaa @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::aaa |
| staticType: E |
| SimpleIdentifier |
| token: bbb @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::bbb |
| staticType: E |
| SimpleIdentifier |
| token: ccc @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::ccc |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| constructors |
| synthetic const @-1 |
| reference: <testLibraryFragment>::@enum::E::@constructor::new |
| enclosingElement: <testLibraryFragment>::@enum::E |
| accessors |
| synthetic static get aaa @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::aaa |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E |
| synthetic static get bbb @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::bbb |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E |
| synthetic static get ccc @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::ccc |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E> |
| '''); |
| } |
| |
| test_enum_constant_inference() async { |
| var library = await buildLibrary(r''' |
| enum E<T> { |
| int(1), string('2'); |
| const E(T a); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| enums |
| enum E @5 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| typeParameters |
| covariant T @7 |
| defaultType: dynamic |
| supertype: Enum |
| fields |
| static const enumConstant int @14 |
| reference: <testLibraryFragment>::@enum::E::@field::int |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: E<int> |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E<int> |
| staticElement: ConstructorMember |
| base: <testLibraryFragment>::@enum::E::@constructor::new |
| substitution: {T: int} |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| arguments |
| IntegerLiteral |
| literal: 1 @18 |
| staticType: int |
| rightParenthesis: ) @0 |
| staticType: E<int> |
| static const enumConstant string @22 |
| reference: <testLibraryFragment>::@enum::E::@field::string |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: E<String> |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E<String> |
| staticElement: ConstructorMember |
| base: <testLibraryFragment>::@enum::E::@constructor::new |
| substitution: {T: String} |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| arguments |
| SimpleStringLiteral |
| literal: '2' @29 |
| rightParenthesis: ) @0 |
| staticType: E<String> |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E<dynamic>> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: int @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::int |
| staticType: E<int> |
| SimpleIdentifier |
| token: string @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::string |
| staticType: E<String> |
| rightBracket: ] @0 |
| staticType: List<E<dynamic>> |
| constructors |
| const @43 |
| reference: <testLibraryFragment>::@enum::E::@constructor::new |
| enclosingElement: <testLibraryFragment>::@enum::E |
| parameters |
| requiredPositional a @47 |
| type: T |
| accessors |
| synthetic static get int @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::int |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E<int> |
| synthetic static get string @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::string |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E<String> |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E<dynamic>> |
| '''); |
| } |
| |
| /// Test that a constant named `_name` renames the synthetic `name` field. |
| test_enum_constant_name() async { |
| var library = await buildLibrary(r''' |
| enum E { |
| _name; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| enums |
| enum E @5 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| supertype: Enum |
| fields |
| static const enumConstant _name @11 |
| reference: <testLibraryFragment>::@enum::E::@field::_name |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: E |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E |
| staticElement: <testLibraryFragment>::@enum::E::@constructor::new |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: _name @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::_name |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| constructors |
| synthetic const @-1 |
| reference: <testLibraryFragment>::@enum::E::@constructor::new |
| enclosingElement: <testLibraryFragment>::@enum::E |
| accessors |
| synthetic static get _name @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::_name |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E> |
| '''); |
| } |
| |
| test_enum_constant_typeArguments() async { |
| var library = await buildLibrary(r''' |
| enum E<T> { |
| v<double>(42); |
| const E(T a); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| enums |
| enum E @5 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| typeParameters |
| covariant T @7 |
| defaultType: dynamic |
| supertype: Enum |
| fields |
| static const enumConstant v @14 |
| reference: <testLibraryFragment>::@enum::E::@field::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: E<double> |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| typeArguments: TypeArgumentList |
| leftBracket: < @15 |
| arguments |
| NamedType |
| name: double @16 |
| element: dart:core::<fragment>::@class::double |
| type: double |
| rightBracket: > @22 |
| element: <testLibraryFragment>::@enum::E |
| type: E<double> |
| staticElement: ConstructorMember |
| base: <testLibraryFragment>::@enum::E::@constructor::new |
| substitution: {T: double} |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| arguments |
| IntegerLiteral |
| literal: 42 @24 |
| staticType: double |
| rightParenthesis: ) @0 |
| staticType: E<double> |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E<dynamic>> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::v |
| staticType: E<double> |
| rightBracket: ] @0 |
| staticType: List<E<dynamic>> |
| constructors |
| const @37 |
| reference: <testLibraryFragment>::@enum::E::@constructor::new |
| enclosingElement: <testLibraryFragment>::@enum::E |
| parameters |
| requiredPositional a @41 |
| type: T |
| accessors |
| synthetic static get v @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E<double> |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E<dynamic>> |
| '''); |
| } |
| |
| test_enum_constant_underscore() async { |
| var library = await buildLibrary(''' |
| enum E { |
| _ |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| enums |
| enum E @5 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| supertype: Enum |
| fields |
| static const enumConstant _ @11 |
| reference: <testLibraryFragment>::@enum::E::@field::_ |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: E |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E |
| staticElement: <testLibraryFragment>::@enum::E::@constructor::new |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: _ @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::_ |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| constructors |
| synthetic const @-1 |
| reference: <testLibraryFragment>::@enum::E::@constructor::new |
| enclosingElement: <testLibraryFragment>::@enum::E |
| accessors |
| synthetic static get _ @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::_ |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E> |
| '''); |
| } |
| |
| test_enum_constructor_factory_named() async { |
| var library = await buildLibrary(r''' |
| enum E { |
| v; |
| factory E.named() => v; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| enums |
| enum E @5 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| supertype: Enum |
| fields |
| static const enumConstant v @11 |
| reference: <testLibraryFragment>::@enum::E::@field::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: E |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E |
| staticElement: <testLibraryFragment>::@enum::E::@constructor::new |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::v |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| constructors |
| factory named @26 |
| reference: <testLibraryFragment>::@enum::E::@constructor::named |
| enclosingElement: <testLibraryFragment>::@enum::E |
| periodOffset: 25 |
| nameEnd: 31 |
| synthetic const @-1 |
| reference: <testLibraryFragment>::@enum::E::@constructor::new |
| enclosingElement: <testLibraryFragment>::@enum::E |
| accessors |
| synthetic static get v @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E> |
| '''); |
| } |
| |
| test_enum_constructor_factory_unnamed() async { |
| var library = await buildLibrary(r''' |
| enum E { |
| v; |
| factory E() => v; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| enums |
| enum E @5 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| supertype: Enum |
| fields |
| static const enumConstant v @11 |
| reference: <testLibraryFragment>::@enum::E::@field::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: E |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E |
| staticElement: <testLibraryFragment>::@enum::E::@constructor::new |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::v |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| constructors |
| factory @24 |
| reference: <testLibraryFragment>::@enum::E::@constructor::new |
| enclosingElement: <testLibraryFragment>::@enum::E |
| accessors |
| synthetic static get v @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E> |
| '''); |
| } |
| |
| test_enum_constructor_fieldFormal_functionTyped_withReturnType() async { |
| var library = await buildLibrary(r''' |
| enum E { |
| v; |
| final x; |
| const E(int this.x(double a)); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| enums |
| enum E @5 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| supertype: Enum |
| fields |
| static const enumConstant v @11 |
| reference: <testLibraryFragment>::@enum::E::@field::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: E |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E |
| staticElement: <testLibraryFragment>::@enum::E::@constructor::new |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::v |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| final x @22 |
| reference: <testLibraryFragment>::@enum::E::@field::x |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: dynamic |
| constructors |
| const @33 |
| reference: <testLibraryFragment>::@enum::E::@constructor::new |
| enclosingElement: <testLibraryFragment>::@enum::E |
| parameters |
| requiredPositional final this.x @44 |
| type: int Function(double) |
| parameters |
| requiredPositional a @53 |
| type: double |
| field: <testLibraryFragment>::@enum::E::@field::x |
| accessors |
| synthetic static get v @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E> |
| synthetic get x @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::x |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: dynamic |
| '''); |
| } |
| |
| test_enum_constructor_fieldFormal_multiple_matching_fields() async { |
| var library = await buildLibrary(''' |
| enum E { |
| v; |
| final int x; |
| final String x; |
| const E(this.x); |
| } |
| '''); |
| |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| enums |
| enum E @5 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| supertype: Enum |
| fields |
| static const enumConstant v @11 |
| reference: <testLibraryFragment>::@enum::E::@field::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: E |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E |
| staticElement: <testLibraryFragment>::@enum::E::@constructor::new |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::v |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| final x @26 |
| reference: <testLibraryFragment>::@enum::E::@field::x::@def::0 |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: int |
| final x @44 |
| reference: <testLibraryFragment>::@enum::E::@field::x::@def::1 |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: String |
| constructors |
| const @55 |
| reference: <testLibraryFragment>::@enum::E::@constructor::new |
| enclosingElement: <testLibraryFragment>::@enum::E |
| parameters |
| requiredPositional final this.x @62 |
| type: int |
| field: <testLibraryFragment>::@enum::E::@field::x::@def::0 |
| accessors |
| synthetic static get v @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E> |
| synthetic get x @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::x::@def::0 |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: int |
| synthetic get x @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::x::@def::1 |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: String |
| '''); |
| } |
| |
| test_enum_constructor_fieldFormal_no_matching_field() async { |
| var library = await buildLibrary(''' |
| enum E { |
| v; |
| const E(this.x); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| enums |
| enum E @5 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| supertype: Enum |
| fields |
| static const enumConstant v @11 |
| reference: <testLibraryFragment>::@enum::E::@field::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: E |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E |
| staticElement: <testLibraryFragment>::@enum::E::@constructor::new |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::v |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| constructors |
| const @22 |
| reference: <testLibraryFragment>::@enum::E::@constructor::new |
| enclosingElement: <testLibraryFragment>::@enum::E |
| parameters |
| requiredPositional final this.x @29 |
| type: dynamic |
| field: <null> |
| accessors |
| synthetic static get v @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E> |
| '''); |
| } |
| |
| test_enum_constructor_fieldFormal_optionalNamed_defaultValue() async { |
| var library = await buildLibrary(r''' |
| enum E { |
| v; |
| final int x; |
| const E({this.x = 1 + 2}); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| enums |
| enum E @5 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| supertype: Enum |
| fields |
| static const enumConstant v @11 |
| reference: <testLibraryFragment>::@enum::E::@field::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: E |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E |
| staticElement: <testLibraryFragment>::@enum::E::@constructor::new |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::v |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| final x @26 |
| reference: <testLibraryFragment>::@enum::E::@field::x |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: int |
| constructors |
| const @37 |
| reference: <testLibraryFragment>::@enum::E::@constructor::new |
| enclosingElement: <testLibraryFragment>::@enum::E |
| parameters |
| optionalNamed default final this.x @45 |
| reference: <testLibraryFragment>::@enum::E::@constructor::new::@parameter::x |
| type: int |
| constantInitializer |
| BinaryExpression |
| leftOperand: IntegerLiteral |
| literal: 1 @49 |
| staticType: int |
| operator: + @51 |
| rightOperand: IntegerLiteral |
| literal: 2 @53 |
| staticType: int |
| staticElement: dart:core::<fragment>::@class::num::@method::+ |
| staticInvokeType: num Function(num) |
| staticType: int |
| field: <testLibraryFragment>::@enum::E::@field::x |
| accessors |
| synthetic static get v @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E> |
| synthetic get x @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::x |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: int |
| '''); |
| } |
| |
| test_enum_constructor_fieldFormal_typed_typed() async { |
| var library = await buildLibrary(''' |
| enum E { |
| v; |
| final num x; |
| const E(int this.x); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| enums |
| enum E @5 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| supertype: Enum |
| fields |
| static const enumConstant v @11 |
| reference: <testLibraryFragment>::@enum::E::@field::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: E |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E |
| staticElement: <testLibraryFragment>::@enum::E::@constructor::new |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::v |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| final x @26 |
| reference: <testLibraryFragment>::@enum::E::@field::x |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: num |
| constructors |
| const @37 |
| reference: <testLibraryFragment>::@enum::E::@constructor::new |
| enclosingElement: <testLibraryFragment>::@enum::E |
| parameters |
| requiredPositional final this.x @48 |
| type: int |
| field: <testLibraryFragment>::@enum::E::@field::x |
| accessors |
| synthetic static get v @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E> |
| synthetic get x @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::x |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: num |
| '''); |
| } |
| |
| test_enum_constructor_fieldFormal_untyped_typed() async { |
| var library = await buildLibrary(r''' |
| enum E { |
| v; |
| final x; |
| E(int this.x); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| enums |
| enum E @5 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| supertype: Enum |
| fields |
| static const enumConstant v @11 |
| reference: <testLibraryFragment>::@enum::E::@field::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: E |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E |
| staticElement: <testLibraryFragment>::@enum::E::@constructor::new |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::v |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| final x @22 |
| reference: <testLibraryFragment>::@enum::E::@field::x |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: dynamic |
| constructors |
| @27 |
| reference: <testLibraryFragment>::@enum::E::@constructor::new |
| enclosingElement: <testLibraryFragment>::@enum::E |
| parameters |
| requiredPositional final this.x @38 |
| type: int |
| field: <testLibraryFragment>::@enum::E::@field::x |
| accessors |
| synthetic static get v @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E> |
| synthetic get x @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::x |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: dynamic |
| '''); |
| } |
| |
| test_enum_constructor_fieldFormal_untyped_untyped() async { |
| var library = await buildLibrary(r''' |
| enum E { |
| v; |
| final x; |
| E(this.x); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| enums |
| enum E @5 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| supertype: Enum |
| fields |
| static const enumConstant v @11 |
| reference: <testLibraryFragment>::@enum::E::@field::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: E |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E |
| staticElement: <testLibraryFragment>::@enum::E::@constructor::new |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::v |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| final x @22 |
| reference: <testLibraryFragment>::@enum::E::@field::x |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: dynamic |
| constructors |
| @27 |
| reference: <testLibraryFragment>::@enum::E::@constructor::new |
| enclosingElement: <testLibraryFragment>::@enum::E |
| parameters |
| requiredPositional final this.x @34 |
| type: dynamic |
| field: <testLibraryFragment>::@enum::E::@field::x |
| accessors |
| synthetic static get v @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E> |
| synthetic get x @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::x |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: dynamic |
| '''); |
| } |
| |
| test_enum_constructor_generative_named() async { |
| var library = await buildLibrary(r''' |
| enum E { |
| v.named(42); |
| const E.named(int a); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| enums |
| enum E @5 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| supertype: Enum |
| fields |
| static const enumConstant v @11 |
| reference: <testLibraryFragment>::@enum::E::@field::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: E |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E |
| period: . @0 |
| name: SimpleIdentifier |
| token: named @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@constructor::named |
| staticType: null |
| staticElement: <testLibraryFragment>::@enum::E::@constructor::named |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| arguments |
| IntegerLiteral |
| literal: 42 @19 |
| staticType: int |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::v |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| constructors |
| const named @34 |
| reference: <testLibraryFragment>::@enum::E::@constructor::named |
| enclosingElement: <testLibraryFragment>::@enum::E |
| periodOffset: 33 |
| nameEnd: 39 |
| parameters |
| requiredPositional a @44 |
| type: int |
| accessors |
| synthetic static get v @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E> |
| '''); |
| } |
| |
| test_enum_constructor_generative_unnamed() async { |
| var library = await buildLibrary(r''' |
| enum E { |
| v(42); |
| const E(int a); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| enums |
| enum E @5 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| supertype: Enum |
| fields |
| static const enumConstant v @11 |
| reference: <testLibraryFragment>::@enum::E::@field::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: E |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E |
| staticElement: <testLibraryFragment>::@enum::E::@constructor::new |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| arguments |
| IntegerLiteral |
| literal: 42 @13 |
| staticType: int |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::v |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| constructors |
| const @26 |
| reference: <testLibraryFragment>::@enum::E::@constructor::new |
| enclosingElement: <testLibraryFragment>::@enum::E |
| parameters |
| requiredPositional a @32 |
| type: int |
| accessors |
| synthetic static get v @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E> |
| '''); |
| } |
| |
| test_enum_constructor_initializer() async { |
| var library = await buildLibrary(r''' |
| enum E<T> { |
| v; |
| final int x; |
| const E(T? a) : assert(a is T), x = 0; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| enums |
| enum E @5 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| typeParameters |
| covariant T @7 |
| defaultType: dynamic |
| supertype: Enum |
| fields |
| static const enumConstant v @14 |
| reference: <testLibraryFragment>::@enum::E::@field::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: E<dynamic> |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E<dynamic> |
| staticElement: ConstructorMember |
| base: <testLibraryFragment>::@enum::E::@constructor::new |
| substitution: {T: dynamic} |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E<dynamic> |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E<dynamic>> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::v |
| staticType: E<dynamic> |
| rightBracket: ] @0 |
| staticType: List<E<dynamic>> |
| final x @29 |
| reference: <testLibraryFragment>::@enum::E::@field::x |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: int |
| constructors |
| const @40 |
| reference: <testLibraryFragment>::@enum::E::@constructor::new |
| enclosingElement: <testLibraryFragment>::@enum::E |
| parameters |
| requiredPositional a @45 |
| type: T? |
| constantInitializers |
| AssertInitializer |
| assertKeyword: assert @50 |
| leftParenthesis: ( @56 |
| condition: IsExpression |
| expression: SimpleIdentifier |
| token: a @57 |
| staticElement: <testLibraryFragment>::@enum::E::@constructor::new::@parameter::a |
| staticType: T? |
| isOperator: is @59 |
| type: NamedType |
| name: T @62 |
| element: T@7 |
| type: T |
| staticType: bool |
| rightParenthesis: ) @63 |
| ConstructorFieldInitializer |
| fieldName: SimpleIdentifier |
| token: x @66 |
| staticElement: <testLibraryFragment>::@enum::E::@field::x |
| staticType: null |
| equals: = @68 |
| expression: IntegerLiteral |
| literal: 0 @70 |
| staticType: int |
| accessors |
| synthetic static get v @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E<dynamic> |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E<dynamic>> |
| synthetic get x @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::x |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: int |
| '''); |
| } |
| |
| test_enum_documented() async { |
| var library = await buildLibrary(''' |
| // Extra comment so doc comment offset != 0 |
| /** |
| * Docs |
| */ |
| enum E { v }'''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| enums |
| enum E @65 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| documentationComment: /**\n * Docs\n */ |
| supertype: Enum |
| fields |
| static const enumConstant v @69 |
| reference: <testLibraryFragment>::@enum::E::@field::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: E |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E |
| staticElement: <testLibraryFragment>::@enum::E::@constructor::new |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::v |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| constructors |
| synthetic const @-1 |
| reference: <testLibraryFragment>::@enum::E::@constructor::new |
| enclosingElement: <testLibraryFragment>::@enum::E |
| accessors |
| synthetic static get v @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E> |
| '''); |
| } |
| |
| test_enum_field() async { |
| var library = await buildLibrary(r''' |
| enum E { |
| v; |
| final foo = 42; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| enums |
| enum E @5 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| supertype: Enum |
| fields |
| static const enumConstant v @11 |
| reference: <testLibraryFragment>::@enum::E::@field::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: E |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E |
| staticElement: <testLibraryFragment>::@enum::E::@constructor::new |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::v |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| final foo @22 |
| reference: <testLibraryFragment>::@enum::E::@field::foo |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: int |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| IntegerLiteral |
| literal: 42 @28 |
| staticType: int |
| constructors |
| synthetic const @-1 |
| reference: <testLibraryFragment>::@enum::E::@constructor::new |
| enclosingElement: <testLibraryFragment>::@enum::E |
| accessors |
| synthetic static get v @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E> |
| synthetic get foo @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::foo |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: int |
| '''); |
| } |
| |
| test_enum_field_isPromotable() async { |
| var library = await buildLibrary(r''' |
| enum E { |
| v(null); |
| final int? _foo; |
| E(this._foo); |
| } |
| '''); |
| configuration.forPromotableFields( |
| enumNames: {'E'}, |
| fieldNames: {'_foo'}, |
| ); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| enums |
| enum E @5 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| supertype: Enum |
| fields |
| final promotable _foo @33 |
| reference: <testLibraryFragment>::@enum::E::@field::_foo |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: int? |
| '''); |
| } |
| |
| test_enum_getter() async { |
| var library = await buildLibrary(r''' |
| enum E{ |
| v; |
| int get foo => 0; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| enums |
| enum E @5 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| supertype: Enum |
| fields |
| static const enumConstant v @10 |
| reference: <testLibraryFragment>::@enum::E::@field::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: E |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E |
| staticElement: <testLibraryFragment>::@enum::E::@constructor::new |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::v |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| synthetic foo @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::foo |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: int |
| constructors |
| synthetic const @-1 |
| reference: <testLibraryFragment>::@enum::E::@constructor::new |
| enclosingElement: <testLibraryFragment>::@enum::E |
| accessors |
| synthetic static get v @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E> |
| get foo @23 |
| reference: <testLibraryFragment>::@enum::E::@getter::foo |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: int |
| '''); |
| } |
| |
| test_enum_interfaces() async { |
| var library = await buildLibrary(r''' |
| class I {} |
| enum E implements I { |
| v; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class I @6 |
| reference: <testLibraryFragment>::@class::I |
| enclosingElement: <testLibraryFragment> |
| constructors |
| synthetic @-1 |
| reference: <testLibraryFragment>::@class::I::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::I |
| enums |
| enum E @16 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| supertype: Enum |
| interfaces |
| I |
| fields |
| static const enumConstant v @35 |
| reference: <testLibraryFragment>::@enum::E::@field::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: E |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E |
| staticElement: <testLibraryFragment>::@enum::E::@constructor::new |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::v |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| constructors |
| synthetic const @-1 |
| reference: <testLibraryFragment>::@enum::E::@constructor::new |
| enclosingElement: <testLibraryFragment>::@enum::E |
| accessors |
| synthetic static get v @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E> |
| '''); |
| } |
| |
| test_enum_interfaces_extensionType() async { |
| var library = await buildLibrary(r''' |
| class A {} |
| extension type B(int it) {} |
| class C {} |
| enum E implements A, B, C { v } |
| '''); |
| configuration |
| ..withConstructors = false |
| ..withConstantInitializers = false; |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class A @6 |
| reference: <testLibraryFragment>::@class::A |
| enclosingElement: <testLibraryFragment> |
| class C @45 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| enums |
| enum E @55 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| supertype: Enum |
| interfaces |
| A |
| C |
| fields |
| static const enumConstant v @78 |
| reference: <testLibraryFragment>::@enum::E::@field::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: E |
| shouldUseTypeForInitializerInference: false |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E> |
| accessors |
| synthetic static get v @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E> |
| extensionTypes |
| B @26 |
| reference: <testLibraryFragment>::@extensionType::B |
| enclosingElement: <testLibraryFragment> |
| representation: <testLibraryFragment>::@extensionType::B::@field::it |
| primaryConstructor: <testLibraryFragment>::@extensionType::B::@constructor::new |
| typeErasure: int |
| fields |
| final it @32 |
| reference: <testLibraryFragment>::@extensionType::B::@field::it |
| enclosingElement: <testLibraryFragment>::@extensionType::B |
| type: int |
| accessors |
| synthetic get it @-1 |
| reference: <testLibraryFragment>::@extensionType::B::@getter::it |
| enclosingElement: <testLibraryFragment>::@extensionType::B |
| returnType: int |
| '''); |
| } |
| |
| test_enum_interfaces_generic() async { |
| var library = await buildLibrary(r''' |
| class I<T> {} |
| enum E<U> implements I<U> { |
| v; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class I @6 |
| reference: <testLibraryFragment>::@class::I |
| enclosingElement: <testLibraryFragment> |
| typeParameters |
| covariant T @8 |
| defaultType: dynamic |
| constructors |
| synthetic @-1 |
| reference: <testLibraryFragment>::@class::I::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::I |
| enums |
| enum E @19 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| typeParameters |
| covariant U @21 |
| defaultType: dynamic |
| supertype: Enum |
| interfaces |
| I<U> |
| fields |
| static const enumConstant v @44 |
| reference: <testLibraryFragment>::@enum::E::@field::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: E<dynamic> |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E<dynamic> |
| staticElement: ConstructorMember |
| base: <testLibraryFragment>::@enum::E::@constructor::new |
| substitution: {U: dynamic} |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E<dynamic> |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E<dynamic>> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::v |
| staticType: E<dynamic> |
| rightBracket: ] @0 |
| staticType: List<E<dynamic>> |
| constructors |
| synthetic const @-1 |
| reference: <testLibraryFragment>::@enum::E::@constructor::new |
| enclosingElement: <testLibraryFragment>::@enum::E |
| accessors |
| synthetic static get v @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E<dynamic> |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E<dynamic>> |
| '''); |
| } |
| |
| test_enum_interfaces_unresolved() async { |
| var library = await buildLibrary(''' |
| class X {} |
| class Z {} |
| enum E implements X, Y, Z { |
| v |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class X @6 |
| reference: <testLibraryFragment>::@class::X |
| enclosingElement: <testLibraryFragment> |
| constructors |
| synthetic @-1 |
| reference: <testLibraryFragment>::@class::X::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::X |
| class Z @17 |
| reference: <testLibraryFragment>::@class::Z |
| enclosingElement: <testLibraryFragment> |
| constructors |
| synthetic @-1 |
| reference: <testLibraryFragment>::@class::Z::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::Z |
| enums |
| enum E @27 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| supertype: Enum |
| interfaces |
| X |
| Z |
| fields |
| static const enumConstant v @52 |
| reference: <testLibraryFragment>::@enum::E::@field::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: E |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E |
| staticElement: <testLibraryFragment>::@enum::E::@constructor::new |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::v |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| constructors |
| synthetic const @-1 |
| reference: <testLibraryFragment>::@enum::E::@constructor::new |
| enclosingElement: <testLibraryFragment>::@enum::E |
| accessors |
| synthetic static get v @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E> |
| '''); |
| } |
| |
| test_enum_method() async { |
| var library = await buildLibrary(r''' |
| enum E<T> { |
| v; |
| int foo<U>(T t, U u) => 0; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| enums |
| enum E @5 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| typeParameters |
| covariant T @7 |
| defaultType: dynamic |
| supertype: Enum |
| fields |
| static const enumConstant v @14 |
| reference: <testLibraryFragment>::@enum::E::@field::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: E<dynamic> |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E<dynamic> |
| staticElement: ConstructorMember |
| base: <testLibraryFragment>::@enum::E::@constructor::new |
| substitution: {T: dynamic} |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E<dynamic> |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E<dynamic>> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::v |
| staticType: E<dynamic> |
| rightBracket: ] @0 |
| staticType: List<E<dynamic>> |
| constructors |
| synthetic const @-1 |
| reference: <testLibraryFragment>::@enum::E::@constructor::new |
| enclosingElement: <testLibraryFragment>::@enum::E |
| accessors |
| synthetic static get v @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E<dynamic> |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E<dynamic>> |
| methods |
| foo @23 |
| reference: <testLibraryFragment>::@enum::E::@method::foo |
| enclosingElement: <testLibraryFragment>::@enum::E |
| typeParameters |
| covariant U @27 |
| defaultType: dynamic |
| parameters |
| requiredPositional t @32 |
| type: T |
| requiredPositional u @37 |
| type: U |
| returnType: int |
| '''); |
| } |
| |
| test_enum_method_toString() async { |
| var library = await buildLibrary(r''' |
| enum E { |
| v; |
| String toString() => 'E'; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| enums |
| enum E @5 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| supertype: Enum |
| fields |
| static const enumConstant v @11 |
| reference: <testLibraryFragment>::@enum::E::@field::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: E |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E |
| staticElement: <testLibraryFragment>::@enum::E::@constructor::new |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::v |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| constructors |
| synthetic const @-1 |
| reference: <testLibraryFragment>::@enum::E::@constructor::new |
| enclosingElement: <testLibraryFragment>::@enum::E |
| accessors |
| synthetic static get v @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E> |
| methods |
| toString @23 |
| reference: <testLibraryFragment>::@enum::E::@method::toString |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: String |
| '''); |
| } |
| |
| test_enum_mixins() async { |
| var library = await buildLibrary(r''' |
| mixin M {} |
| enum E with M { |
| v; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| enums |
| enum E @16 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| supertype: Enum |
| mixins |
| M |
| fields |
| static const enumConstant v @29 |
| reference: <testLibraryFragment>::@enum::E::@field::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: E |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E |
| staticElement: <testLibraryFragment>::@enum::E::@constructor::new |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::v |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| constructors |
| synthetic const @-1 |
| reference: <testLibraryFragment>::@enum::E::@constructor::new |
| enclosingElement: <testLibraryFragment>::@enum::E |
| accessors |
| synthetic static get v @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E> |
| mixins |
| mixin M @6 |
| reference: <testLibraryFragment>::@mixin::M |
| enclosingElement: <testLibraryFragment> |
| superclassConstraints |
| Object |
| '''); |
| } |
| |
| test_enum_mixins_extensionType() async { |
| var library = await buildLibrary(r''' |
| class A {} |
| extension type B(int it) {} |
| class C {} |
| enum E with A, B, C { v } |
| '''); |
| configuration |
| ..withConstructors = false |
| ..withConstantInitializers = false; |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class A @6 |
| reference: <testLibraryFragment>::@class::A |
| enclosingElement: <testLibraryFragment> |
| class C @45 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| enums |
| enum E @55 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| supertype: Enum |
| mixins |
| A |
| C |
| fields |
| static const enumConstant v @72 |
| reference: <testLibraryFragment>::@enum::E::@field::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: E |
| shouldUseTypeForInitializerInference: false |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E> |
| accessors |
| synthetic static get v @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E> |
| extensionTypes |
| B @26 |
| reference: <testLibraryFragment>::@extensionType::B |
| enclosingElement: <testLibraryFragment> |
| representation: <testLibraryFragment>::@extensionType::B::@field::it |
| primaryConstructor: <testLibraryFragment>::@extensionType::B::@constructor::new |
| typeErasure: int |
| fields |
| final it @32 |
| reference: <testLibraryFragment>::@extensionType::B::@field::it |
| enclosingElement: <testLibraryFragment>::@extensionType::B |
| type: int |
| accessors |
| synthetic get it @-1 |
| reference: <testLibraryFragment>::@extensionType::B::@getter::it |
| enclosingElement: <testLibraryFragment>::@extensionType::B |
| returnType: int |
| '''); |
| } |
| |
| test_enum_mixins_inference() async { |
| var library = await buildLibrary(r''' |
| mixin M1<T> {} |
| mixin M2<T> on M1<T> {} |
| enum E with M1<int>, M2 { |
| v; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| enums |
| enum E @44 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| supertype: Enum |
| mixins |
| M1<int> |
| M2<int> |
| fields |
| static const enumConstant v @67 |
| reference: <testLibraryFragment>::@enum::E::@field::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: E |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E |
| staticElement: <testLibraryFragment>::@enum::E::@constructor::new |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::v |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| constructors |
| synthetic const @-1 |
| reference: <testLibraryFragment>::@enum::E::@constructor::new |
| enclosingElement: <testLibraryFragment>::@enum::E |
| accessors |
| synthetic static get v @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E> |
| mixins |
| mixin M1 @6 |
| reference: <testLibraryFragment>::@mixin::M1 |
| enclosingElement: <testLibraryFragment> |
| typeParameters |
| covariant T @9 |
| defaultType: dynamic |
| superclassConstraints |
| Object |
| mixin M2 @21 |
| reference: <testLibraryFragment>::@mixin::M2 |
| enclosingElement: <testLibraryFragment> |
| typeParameters |
| covariant T @24 |
| defaultType: dynamic |
| superclassConstraints |
| M1<T> |
| '''); |
| } |
| |
| test_enum_setter() async { |
| var library = await buildLibrary(r''' |
| enum E{ |
| v; |
| set foo(int _) {} |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| enums |
| enum E @5 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| supertype: Enum |
| fields |
| static const enumConstant v @10 |
| reference: <testLibraryFragment>::@enum::E::@field::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: E |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E |
| staticElement: <testLibraryFragment>::@enum::E::@constructor::new |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::v |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| synthetic foo @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::foo |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: int |
| constructors |
| synthetic const @-1 |
| reference: <testLibraryFragment>::@enum::E::@constructor::new |
| enclosingElement: <testLibraryFragment>::@enum::E |
| accessors |
| synthetic static get v @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E> |
| set foo= @19 |
| reference: <testLibraryFragment>::@enum::E::@setter::foo |
| enclosingElement: <testLibraryFragment>::@enum::E |
| parameters |
| requiredPositional _ @27 |
| type: int |
| returnType: void |
| '''); |
| } |
| |
| test_enum_typeParameters() async { |
| var library = await buildLibrary(''' |
| enum E<T> { |
| v |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| enums |
| enum E @5 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| typeParameters |
| covariant T @7 |
| defaultType: dynamic |
| supertype: Enum |
| fields |
| static const enumConstant v @14 |
| reference: <testLibraryFragment>::@enum::E::@field::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: E<dynamic> |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E<dynamic> |
| staticElement: ConstructorMember |
| base: <testLibraryFragment>::@enum::E::@constructor::new |
| substitution: {T: dynamic} |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E<dynamic> |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E<dynamic>> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::v |
| staticType: E<dynamic> |
| rightBracket: ] @0 |
| staticType: List<E<dynamic>> |
| constructors |
| synthetic const @-1 |
| reference: <testLibraryFragment>::@enum::E::@constructor::new |
| enclosingElement: <testLibraryFragment>::@enum::E |
| accessors |
| synthetic static get v @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E<dynamic> |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E<dynamic>> |
| '''); |
| } |
| |
| test_enum_typeParameters_bound() async { |
| var library = await buildLibrary(''' |
| enum E<T extends num, U extends T> { |
| v |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| enums |
| notSimplyBounded enum E @5 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| typeParameters |
| covariant T @7 |
| bound: num |
| defaultType: num |
| covariant U @22 |
| bound: T |
| defaultType: num |
| supertype: Enum |
| fields |
| static const enumConstant v @39 |
| reference: <testLibraryFragment>::@enum::E::@field::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: E<num, num> |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E<num, num> |
| staticElement: ConstructorMember |
| base: <testLibraryFragment>::@enum::E::@constructor::new |
| substitution: {T: num, U: num} |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E<num, num> |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E<num, num>> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::v |
| staticType: E<num, num> |
| rightBracket: ] @0 |
| staticType: List<E<num, num>> |
| constructors |
| synthetic const @-1 |
| reference: <testLibraryFragment>::@enum::E::@constructor::new |
| enclosingElement: <testLibraryFragment>::@enum::E |
| accessors |
| synthetic static get v @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E<num, num> |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E<num, num>> |
| '''); |
| } |
| |
| test_enum_typeParameters_cycle_1of1() async { |
| var library = await buildLibrary(''' |
| enum E<T extends T> {} |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| enums |
| notSimplyBounded enum E @5 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| typeParameters |
| covariant T @7 |
| bound: dynamic |
| defaultType: dynamic |
| supertype: Enum |
| fields |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E<dynamic>> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| rightBracket: ] @0 |
| staticType: List<E<dynamic>> |
| constructors |
| synthetic const @-1 |
| reference: <testLibraryFragment>::@enum::E::@constructor::new |
| enclosingElement: <testLibraryFragment>::@enum::E |
| accessors |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E<dynamic>> |
| '''); |
| } |
| |
| test_enum_typeParameters_cycle_2of3() async { |
| var library = await buildLibrary(r''' |
| enum E<T extends V, U extends num, V extends T> {} |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| enums |
| notSimplyBounded enum E @5 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| typeParameters |
| covariant T @7 |
| bound: dynamic |
| defaultType: dynamic |
| covariant U @20 |
| bound: num |
| defaultType: num |
| covariant V @35 |
| bound: dynamic |
| defaultType: dynamic |
| supertype: Enum |
| fields |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E<dynamic, num, dynamic>> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| rightBracket: ] @0 |
| staticType: List<E<dynamic, num, dynamic>> |
| constructors |
| synthetic const @-1 |
| reference: <testLibraryFragment>::@enum::E::@constructor::new |
| enclosingElement: <testLibraryFragment>::@enum::E |
| accessors |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E<dynamic, num, dynamic>> |
| '''); |
| } |
| |
| test_enum_typeParameters_defaultType_cycle_genericFunctionType() async { |
| var library = await buildLibrary(r''' |
| enum E<T extends void Function(E)> {} |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| enums |
| notSimplyBounded enum E @5 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| typeParameters |
| covariant T @7 |
| bound: void Function(E<dynamic>) |
| defaultType: dynamic |
| supertype: Enum |
| fields |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E<dynamic>> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| rightBracket: ] @0 |
| staticType: List<E<dynamic>> |
| constructors |
| synthetic const @-1 |
| reference: <testLibraryFragment>::@enum::E::@constructor::new |
| enclosingElement: <testLibraryFragment>::@enum::E |
| accessors |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E<dynamic>> |
| '''); |
| } |
| |
| test_enum_typeParameters_variance_contravariant() async { |
| var library = await buildLibrary(''' |
| enum E<in T> {} |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| enums |
| enum E @5 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| typeParameters |
| contravariant T @10 |
| defaultType: dynamic |
| supertype: Enum |
| fields |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E<dynamic>> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| rightBracket: ] @0 |
| staticType: List<E<dynamic>> |
| constructors |
| synthetic const @-1 |
| reference: <testLibraryFragment>::@enum::E::@constructor::new |
| enclosingElement: <testLibraryFragment>::@enum::E |
| accessors |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E<dynamic>> |
| '''); |
| } |
| |
| test_enum_typeParameters_variance_covariant() async { |
| var library = await buildLibrary(''' |
| enum E<out T> {} |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| enums |
| enum E @5 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| typeParameters |
| covariant T @11 |
| defaultType: dynamic |
| supertype: Enum |
| fields |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E<dynamic>> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| rightBracket: ] @0 |
| staticType: List<E<dynamic>> |
| constructors |
| synthetic const @-1 |
| reference: <testLibraryFragment>::@enum::E::@constructor::new |
| enclosingElement: <testLibraryFragment>::@enum::E |
| accessors |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E<dynamic>> |
| '''); |
| } |
| |
| test_enum_typeParameters_variance_invariant() async { |
| var library = await buildLibrary(''' |
| enum E<inout T> {} |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| enums |
| enum E @5 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| typeParameters |
| invariant T @13 |
| defaultType: dynamic |
| supertype: Enum |
| fields |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E<dynamic>> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| rightBracket: ] @0 |
| staticType: List<E<dynamic>> |
| constructors |
| synthetic const @-1 |
| reference: <testLibraryFragment>::@enum::E::@constructor::new |
| enclosingElement: <testLibraryFragment>::@enum::E |
| accessors |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E<dynamic>> |
| '''); |
| } |
| |
| test_enum_typeParameters_variance_multiple() async { |
| var library = await buildLibrary(''' |
| enum E<inout T, in U, out V> {} |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| enums |
| enum E @5 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| typeParameters |
| invariant T @13 |
| defaultType: dynamic |
| contravariant U @19 |
| defaultType: dynamic |
| covariant V @26 |
| defaultType: dynamic |
| supertype: Enum |
| fields |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E<dynamic, dynamic, dynamic>> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| rightBracket: ] @0 |
| staticType: List<E<dynamic, dynamic, dynamic>> |
| constructors |
| synthetic const @-1 |
| reference: <testLibraryFragment>::@enum::E::@constructor::new |
| enclosingElement: <testLibraryFragment>::@enum::E |
| accessors |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E<dynamic, dynamic, dynamic>> |
| '''); |
| } |
| |
| test_enum_value_documented() async { |
| var library = await buildLibrary(''' |
| enum E { |
| /** |
| * aaa |
| */ |
| a, |
| /// bbb |
| b |
| }'''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| enums |
| enum E @5 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| supertype: Enum |
| fields |
| static const enumConstant a @32 |
| reference: <testLibraryFragment>::@enum::E::@field::a |
| enclosingElement: <testLibraryFragment>::@enum::E |
| documentationComment: /**\n * aaa\n */ |
| type: E |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E |
| staticElement: <testLibraryFragment>::@enum::E::@constructor::new |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| static const enumConstant b @47 |
| reference: <testLibraryFragment>::@enum::E::@field::b |
| enclosingElement: <testLibraryFragment>::@enum::E |
| documentationComment: /// bbb |
| type: E |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E |
| staticElement: <testLibraryFragment>::@enum::E::@constructor::new |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: a @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::a |
| staticType: E |
| SimpleIdentifier |
| token: b @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::b |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| constructors |
| synthetic const @-1 |
| reference: <testLibraryFragment>::@enum::E::@constructor::new |
| enclosingElement: <testLibraryFragment>::@enum::E |
| accessors |
| synthetic static get a @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::a |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E |
| synthetic static get b @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::b |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E> |
| '''); |
| } |
| |
| test_enum_value_documented_withMetadata() async { |
| var library = await buildLibrary(''' |
| enum E { |
| /** |
| * aaa |
| */ |
| @annotation |
| a, |
| /// bbb |
| @annotation |
| b, |
| } |
| |
| const int annotation = 0; |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| enums |
| enum E @5 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| supertype: Enum |
| fields |
| static const enumConstant a @46 |
| reference: <testLibraryFragment>::@enum::E::@field::a |
| enclosingElement: <testLibraryFragment>::@enum::E |
| documentationComment: /**\n * aaa\n */ |
| metadata |
| Annotation |
| atSign: @ @32 |
| name: SimpleIdentifier |
| token: annotation @33 |
| staticElement: <testLibraryFragment>::@getter::annotation |
| staticType: null |
| element: <testLibraryFragment>::@getter::annotation |
| type: E |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E |
| staticElement: <testLibraryFragment>::@enum::E::@constructor::new |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| static const enumConstant b @75 |
| reference: <testLibraryFragment>::@enum::E::@field::b |
| enclosingElement: <testLibraryFragment>::@enum::E |
| documentationComment: /// bbb |
| metadata |
| Annotation |
| atSign: @ @61 |
| name: SimpleIdentifier |
| token: annotation @62 |
| staticElement: <testLibraryFragment>::@getter::annotation |
| staticType: null |
| element: <testLibraryFragment>::@getter::annotation |
| type: E |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E |
| staticElement: <testLibraryFragment>::@enum::E::@constructor::new |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: a @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::a |
| staticType: E |
| SimpleIdentifier |
| token: b @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::b |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| constructors |
| synthetic const @-1 |
| reference: <testLibraryFragment>::@enum::E::@constructor::new |
| enclosingElement: <testLibraryFragment>::@enum::E |
| accessors |
| synthetic static get a @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::a |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E |
| synthetic static get b @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::b |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E> |
| topLevelVariables |
| static const annotation @91 |
| reference: <testLibraryFragment>::@topLevelVariable::annotation |
| enclosingElement: <testLibraryFragment> |
| type: int |
| shouldUseTypeForInitializerInference: true |
| constantInitializer |
| IntegerLiteral |
| literal: 0 @104 |
| staticType: int |
| accessors |
| synthetic static get annotation @-1 |
| reference: <testLibraryFragment>::@getter::annotation |
| enclosingElement: <testLibraryFragment> |
| returnType: int |
| '''); |
| } |
| |
| test_enum_values() async { |
| var library = await buildLibrary('enum E { v1, v2 }'); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| enums |
| enum E @5 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| supertype: Enum |
| fields |
| static const enumConstant v1 @9 |
| reference: <testLibraryFragment>::@enum::E::@field::v1 |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: E |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E |
| staticElement: <testLibraryFragment>::@enum::E::@constructor::new |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| static const enumConstant v2 @13 |
| reference: <testLibraryFragment>::@enum::E::@field::v2 |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: E |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E |
| staticElement: <testLibraryFragment>::@enum::E::@constructor::new |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v1 @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::v1 |
| staticType: E |
| SimpleIdentifier |
| token: v2 @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::v2 |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| constructors |
| synthetic const @-1 |
| reference: <testLibraryFragment>::@enum::E::@constructor::new |
| enclosingElement: <testLibraryFragment>::@enum::E |
| accessors |
| synthetic static get v1 @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::v1 |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E |
| synthetic static get v2 @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::v2 |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E> |
| '''); |
| } |
| |
| test_enums() async { |
| var library = await buildLibrary('enum E1 { v1 } enum E2 { v2 }'); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| enums |
| enum E1 @5 |
| reference: <testLibraryFragment>::@enum::E1 |
| enclosingElement: <testLibraryFragment> |
| supertype: Enum |
| fields |
| static const enumConstant v1 @10 |
| reference: <testLibraryFragment>::@enum::E1::@field::v1 |
| enclosingElement: <testLibraryFragment>::@enum::E1 |
| type: E1 |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E1 @-1 |
| element: <testLibraryFragment>::@enum::E1 |
| type: E1 |
| staticElement: <testLibraryFragment>::@enum::E1::@constructor::new |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E1 |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E1::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E1 |
| type: List<E1> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v1 @-1 |
| staticElement: <testLibraryFragment>::@enum::E1::@getter::v1 |
| staticType: E1 |
| rightBracket: ] @0 |
| staticType: List<E1> |
| constructors |
| synthetic const @-1 |
| reference: <testLibraryFragment>::@enum::E1::@constructor::new |
| enclosingElement: <testLibraryFragment>::@enum::E1 |
| accessors |
| synthetic static get v1 @-1 |
| reference: <testLibraryFragment>::@enum::E1::@getter::v1 |
| enclosingElement: <testLibraryFragment>::@enum::E1 |
| returnType: E1 |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E1::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E1 |
| returnType: List<E1> |
| enum E2 @20 |
| reference: <testLibraryFragment>::@enum::E2 |
| enclosingElement: <testLibraryFragment> |
| supertype: Enum |
| fields |
| static const enumConstant v2 @25 |
| reference: <testLibraryFragment>::@enum::E2::@field::v2 |
| enclosingElement: <testLibraryFragment>::@enum::E2 |
| type: E2 |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E2 @-1 |
| element: <testLibraryFragment>::@enum::E2 |
| type: E2 |
| staticElement: <testLibraryFragment>::@enum::E2::@constructor::new |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E2 |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E2::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E2 |
| type: List<E2> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v2 @-1 |
| staticElement: <testLibraryFragment>::@enum::E2::@getter::v2 |
| staticType: E2 |
| rightBracket: ] @0 |
| staticType: List<E2> |
| constructors |
| synthetic const @-1 |
| reference: <testLibraryFragment>::@enum::E2::@constructor::new |
| enclosingElement: <testLibraryFragment>::@enum::E2 |
| accessors |
| synthetic static get v2 @-1 |
| reference: <testLibraryFragment>::@enum::E2::@getter::v2 |
| enclosingElement: <testLibraryFragment>::@enum::E2 |
| returnType: E2 |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E2::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E2 |
| returnType: List<E2> |
| '''); |
| } |
| |
| test_error_extendsEnum() async { |
| var library = await buildLibrary(''' |
| enum E {a, b, c} |
| |
| class M {} |
| |
| class A extends E { |
| foo() {} |
| } |
| |
| class B implements E, M { |
| foo() {} |
| } |
| |
| class C extends Object with E, M { |
| foo() {} |
| } |
| |
| class D = Object with M, E; |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class M @24 |
| reference: <testLibraryFragment>::@class::M |
| enclosingElement: <testLibraryFragment> |
| constructors |
| synthetic @-1 |
| reference: <testLibraryFragment>::@class::M::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::M |
| class A @36 |
| reference: <testLibraryFragment>::@class::A |
| enclosingElement: <testLibraryFragment> |
| constructors |
| synthetic @-1 |
| reference: <testLibraryFragment>::@class::A::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::A |
| methods |
| foo @52 |
| reference: <testLibraryFragment>::@class::A::@method::foo |
| enclosingElement: <testLibraryFragment>::@class::A |
| returnType: dynamic |
| class B @70 |
| reference: <testLibraryFragment>::@class::B |
| enclosingElement: <testLibraryFragment> |
| interfaces |
| M |
| constructors |
| synthetic @-1 |
| reference: <testLibraryFragment>::@class::B::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::B |
| methods |
| foo @92 |
| reference: <testLibraryFragment>::@class::B::@method::foo |
| enclosingElement: <testLibraryFragment>::@class::B |
| returnType: dynamic |
| class C @110 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| supertype: Object |
| mixins |
| M |
| constructors |
| synthetic @-1 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| methods |
| foo @141 |
| reference: <testLibraryFragment>::@class::C::@method::foo |
| enclosingElement: <testLibraryFragment>::@class::C |
| returnType: dynamic |
| class alias D @159 |
| reference: <testLibraryFragment>::@class::D |
| enclosingElement: <testLibraryFragment> |
| supertype: Object |
| mixins |
| M |
| constructors |
| synthetic const @-1 |
| reference: <testLibraryFragment>::@class::D::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::D |
| constantInitializers |
| SuperConstructorInvocation |
| superKeyword: super @0 |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticElement: dart:core::<fragment>::@class::Object::@constructor::new |
| enums |
| enum E @5 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| supertype: Enum |
| fields |
| static const enumConstant a @8 |
| reference: <testLibraryFragment>::@enum::E::@field::a |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: E |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E |
| staticElement: <testLibraryFragment>::@enum::E::@constructor::new |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| static const enumConstant b @11 |
| reference: <testLibraryFragment>::@enum::E::@field::b |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: E |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E |
| staticElement: <testLibraryFragment>::@enum::E::@constructor::new |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| static const enumConstant c @14 |
| reference: <testLibraryFragment>::@enum::E::@field::c |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: E |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E |
| staticElement: <testLibraryFragment>::@enum::E::@constructor::new |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: a @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::a |
| staticType: E |
| SimpleIdentifier |
| token: b @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::b |
| staticType: E |
| SimpleIdentifier |
| token: c @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::c |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| constructors |
| synthetic const @-1 |
| reference: <testLibraryFragment>::@enum::E::@constructor::new |
| enclosingElement: <testLibraryFragment>::@enum::E |
| accessors |
| synthetic static get a @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::a |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E |
| synthetic static get b @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::b |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E |
| synthetic static get c @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::c |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E> |
| '''); |
| } |
| |
| test_metadata_enum_constant() async { |
| var library = await buildLibrary('const a = 42; enum E { @a v }'); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| enums |
| enum E @19 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| supertype: Enum |
| fields |
| static const enumConstant v @26 |
| reference: <testLibraryFragment>::@enum::E::@field::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| metadata |
| Annotation |
| atSign: @ @23 |
| name: SimpleIdentifier |
| token: a @24 |
| staticElement: <testLibraryFragment>::@getter::a |
| staticType: null |
| element: <testLibraryFragment>::@getter::a |
| type: E |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E |
| staticElement: <testLibraryFragment>::@enum::E::@constructor::new |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::v |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| constructors |
| synthetic const @-1 |
| reference: <testLibraryFragment>::@enum::E::@constructor::new |
| enclosingElement: <testLibraryFragment>::@enum::E |
| accessors |
| synthetic static get v @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E> |
| topLevelVariables |
| static const a @6 |
| reference: <testLibraryFragment>::@topLevelVariable::a |
| enclosingElement: <testLibraryFragment> |
| type: int |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| IntegerLiteral |
| literal: 42 @10 |
| staticType: int |
| accessors |
| synthetic static get a @-1 |
| reference: <testLibraryFragment>::@getter::a |
| enclosingElement: <testLibraryFragment> |
| returnType: int |
| '''); |
| } |
| |
| test_metadata_enum_constant_instanceCreation() async { |
| var library = await buildLibrary(''' |
| class A { |
| final dynamic value; |
| const A(this.value); |
| } |
| |
| enum E { |
| @A(100) a, |
| b, |
| @A(300) c, |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class A @6 |
| reference: <testLibraryFragment>::@class::A |
| enclosingElement: <testLibraryFragment> |
| fields |
| final value @26 |
| reference: <testLibraryFragment>::@class::A::@field::value |
| enclosingElement: <testLibraryFragment>::@class::A |
| type: dynamic |
| constructors |
| const @41 |
| reference: <testLibraryFragment>::@class::A::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::A |
| parameters |
| requiredPositional final this.value @48 |
| type: dynamic |
| field: <testLibraryFragment>::@class::A::@field::value |
| accessors |
| synthetic get value @-1 |
| reference: <testLibraryFragment>::@class::A::@getter::value |
| enclosingElement: <testLibraryFragment>::@class::A |
| returnType: dynamic |
| enums |
| enum E @64 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| supertype: Enum |
| fields |
| static const enumConstant a @78 |
| reference: <testLibraryFragment>::@enum::E::@field::a |
| enclosingElement: <testLibraryFragment>::@enum::E |
| metadata |
| Annotation |
| atSign: @ @70 |
| name: SimpleIdentifier |
| token: A @71 |
| staticElement: <testLibraryFragment>::@class::A |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @72 |
| arguments |
| IntegerLiteral |
| literal: 100 @73 |
| staticType: int |
| rightParenthesis: ) @76 |
| element: <testLibraryFragment>::@class::A::@constructor::new |
| type: E |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E |
| staticElement: <testLibraryFragment>::@enum::E::@constructor::new |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| static const enumConstant b @83 |
| reference: <testLibraryFragment>::@enum::E::@field::b |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: E |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E |
| staticElement: <testLibraryFragment>::@enum::E::@constructor::new |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| static const enumConstant c @96 |
| reference: <testLibraryFragment>::@enum::E::@field::c |
| enclosingElement: <testLibraryFragment>::@enum::E |
| metadata |
| Annotation |
| atSign: @ @88 |
| name: SimpleIdentifier |
| token: A @89 |
| staticElement: <testLibraryFragment>::@class::A |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @90 |
| arguments |
| IntegerLiteral |
| literal: 300 @91 |
| staticType: int |
| rightParenthesis: ) @94 |
| element: <testLibraryFragment>::@class::A::@constructor::new |
| type: E |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E |
| staticElement: <testLibraryFragment>::@enum::E::@constructor::new |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: a @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::a |
| staticType: E |
| SimpleIdentifier |
| token: b @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::b |
| staticType: E |
| SimpleIdentifier |
| token: c @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::c |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| constructors |
| synthetic const @-1 |
| reference: <testLibraryFragment>::@enum::E::@constructor::new |
| enclosingElement: <testLibraryFragment>::@enum::E |
| accessors |
| synthetic static get a @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::a |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E |
| synthetic static get b @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::b |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E |
| synthetic static get c @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::c |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E> |
| '''); |
| } |
| |
| test_metadata_enum_constant_self() async { |
| var library = await buildLibrary(r''' |
| enum E { |
| @v |
| v |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| enums |
| enum E @5 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| supertype: Enum |
| fields |
| static const enumConstant v @16 |
| reference: <testLibraryFragment>::@enum::E::@field::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| metadata |
| Annotation |
| atSign: @ @11 |
| name: SimpleIdentifier |
| token: v @12 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::v |
| staticType: null |
| element: <testLibraryFragment>::@enum::E::@getter::v |
| type: E |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E |
| staticElement: <testLibraryFragment>::@enum::E::@constructor::new |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::v |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| constructors |
| synthetic const @-1 |
| reference: <testLibraryFragment>::@enum::E::@constructor::new |
| enclosingElement: <testLibraryFragment>::@enum::E |
| accessors |
| synthetic static get v @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E> |
| '''); |
| } |
| |
| test_metadata_enum_constructor() async { |
| var library = await buildLibrary(r''' |
| const a = 42; |
| enum E { |
| v; |
| @a |
| const E(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| enums |
| enum E @19 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| supertype: Enum |
| fields |
| static const enumConstant v @25 |
| reference: <testLibraryFragment>::@enum::E::@field::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: E |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
| type: E |
| staticElement: <testLibraryFragment>::@enum::E::@constructor::new |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| reference: <testLibraryFragment>::@enum::E::@field::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: <testLibraryFragment>::@enum::E::@getter::v |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| constructors |
| const @41 |
| reference: <testLibraryFragment>::@enum::E::@constructor::new |
| enclosingElement: <testLibraryFragment>::@enum::E |
| metadata |
| Annotation |
| atSign: @ @30 |
| name: SimpleIdentifier |
| token: a @31 |
| staticElement: <testLibraryFragment>::@getter::a |
| staticType: null |
| element: <testLibraryFragment>::@getter::a |
| accessors |
| synthetic static get v @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: E |
| synthetic static get values @-1 |
| reference: <testLibraryFragment>::@enum::E::@getter::values |
| enclosingElement: <testLibraryFragment>::@enum::E |
| returnType: List<E> |
| topLevelVariables |
| static const a @6 |
| reference: <testLibraryFragment>::@topLevelVariable::a |
| enclosingElement: <testLibraryFragment> |
| type: int |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| IntegerLiteral |
| literal: 42 @10 |
| staticType: int |
| accessors |
| synthetic static get a @-1 |
| reference: <testLibraryFragment>::@getter::a |
| enclosingElement: <testLibraryFragment> |
| returnType: int |
| '''); |
| } |
| |
| test_metadata_enum_method() async { |
| var library = await buildLibrary(r''' |
| const a = 42; |
| enum E { |
| v; |
| @a |
| void foo() {} |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| enums |
| enum E @19 |
| reference: <testLibraryFragment>::@enum::E |
| enclosingElement: <testLibraryFragment> |
| supertype: Enum |
| fields |
| static const enumConstant v @25 |
| reference: <testLibraryFragment>::@enum::E::@field::v |
| enclosingElement: <testLibraryFragment>::@enum::E |
| type: E |
| shouldUseTypeForInitializerInference: false |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: E @-1 |
| element: <testLibraryFragment>::@enum::E |
|