| // Copyright (c) 2015, 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/analysis/declared_variables.dart'; |
| import 'package:analyzer/dart/analysis/features.dart'; |
| import 'package:analyzer/dart/ast/ast.dart'; |
| import 'package:analyzer/dart/element/element.dart'; |
| import 'package:analyzer/dart/element/type.dart'; |
| import 'package:analyzer/file_system/file_system.dart'; |
| import 'package:analyzer/src/dart/analysis/experiments.dart'; |
| import 'package:analyzer/src/dart/element/element.dart'; |
| import 'package:analyzer/src/dart/sdk/sdk.dart'; |
| import 'package:analyzer/src/generated/source.dart'; |
| import 'package:analyzer/src/source/package_map_resolver.dart'; |
| import 'package:analyzer/src/test_utilities/mock_sdk.dart'; |
| import 'package:analyzer/src/test_utilities/resource_provider_mixin.dart'; |
| import 'package:pub_semver/pub_semver.dart'; |
| import 'package:test/test.dart'; |
| import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| |
| import 'element_text.dart'; |
| |
| /// Abstract base class for resynthesizing and comparing elements. |
| /// |
| /// The return type separator: → |
| abstract class AbstractResynthesizeTest with ResourceProviderMixin { |
| /// The set of features enabled in this test. |
| late FeatureSet featureSet; |
| |
| DeclaredVariables declaredVariables = DeclaredVariables(); |
| late final SourceFactory sourceFactory; |
| late final FolderBasedDartSdk sdk; |
| |
| late String testFile; |
| late Source testSource; |
| Set<Source> otherLibrarySources = <Source>{}; |
| |
| AbstractResynthesizeTest() { |
| var sdkRoot = newFolder('/sdk'); |
| createMockSdk( |
| resourceProvider: resourceProvider, |
| root: sdkRoot, |
| ); |
| sdk = FolderBasedDartSdk(resourceProvider, sdkRoot); |
| |
| sourceFactory = SourceFactory( |
| [ |
| DartUriResolver(sdk), |
| PackageMapUriResolver(resourceProvider, { |
| 'test': [ |
| getFolder('/home/test/lib'), |
| ], |
| }), |
| ResourceUriResolver(resourceProvider), |
| ], |
| ); |
| |
| testFile = convertPath('/test.dart'); |
| } |
| |
| void addLibrary(String uri) { |
| var source = sourceFactory.forUri(uri)!; |
| otherLibrarySources.add(source); |
| } |
| |
| Source addLibrarySource(String filePath, String contents) { |
| var source = addSource(filePath, contents); |
| otherLibrarySources.add(source); |
| return source; |
| } |
| |
| Source addSource(String path, String contents) { |
| var file = newFile(path, content: contents); |
| var uri = sourceFactory.pathToUri(file.path)!; |
| return sourceFactory.forUri2(uri)!; |
| } |
| |
| Source addTestSource(String code, [Uri? uri]) { |
| testSource = addSource(testFile, code); |
| return testSource; |
| } |
| |
| Future<LibraryElementImpl> checkLibrary(String text, |
| {bool allowErrors = false}); |
| } |
| |
| class FeatureSets { |
| static final FeatureSet language_2_9 = FeatureSet.fromEnableFlags2( |
| sdkLanguageVersion: Version.parse('2.9.0'), |
| flags: [], |
| ); |
| |
| static final FeatureSet language_2_12 = FeatureSet.fromEnableFlags2( |
| sdkLanguageVersion: Version.parse('2.12.0'), |
| flags: [], |
| ); |
| |
| static final FeatureSet latestWithExperiments = FeatureSet.fromEnableFlags2( |
| sdkLanguageVersion: Version.parse('2.16.0'), |
| flags: [ |
| EnableString.constructor_tearoffs, |
| EnableString.enhanced_enums, |
| EnableString.super_parameters, |
| ], |
| ); |
| } |
| |
| /// Mixin containing test cases exercising summary resynthesis. Intended to be |
| /// applied to a class implementing [AbstractResynthesizeTest]. |
| mixin ResynthesizeTestCases on AbstractResynthesizeTest { |
| test_class_abstract() async { |
| var library = await checkLibrary('abstract class C {}'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| abstract class C @15 |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_constructor_const() async { |
| var library = await checkLibrary('class C { const C(); }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| const @16 |
| '''); |
| } |
| |
| test_class_constructor_const_external() async { |
| var library = await checkLibrary('class C { external const C(); }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| external const @25 |
| '''); |
| } |
| |
| test_class_constructor_documented() async { |
| var library = await checkLibrary(''' |
| class C { |
| /** |
| * Docs |
| */ |
| C(); |
| }'''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| @34 |
| documentationComment: /**\n * Docs\n */ |
| '''); |
| } |
| |
| test_class_constructor_explicit_named() async { |
| var library = await checkLibrary('class C { C.foo(); }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| foo @12 |
| periodOffset: 11 |
| nameEnd: 15 |
| '''); |
| } |
| |
| test_class_constructor_explicit_type_params() async { |
| var library = await checkLibrary('class C<T, U> { C(); }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| typeParameters |
| covariant T @8 |
| defaultType: dynamic |
| covariant U @11 |
| defaultType: dynamic |
| constructors |
| @16 |
| '''); |
| } |
| |
| test_class_constructor_explicit_unnamed() async { |
| var library = await checkLibrary('class C { C(); }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| @10 |
| '''); |
| } |
| |
| test_class_constructor_external() async { |
| var library = await checkLibrary('class C { external C(); }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| external @19 |
| '''); |
| } |
| |
| test_class_constructor_factory() async { |
| var library = await checkLibrary('class C { factory C() => throw 0; }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| factory @18 |
| '''); |
| } |
| |
| test_class_constructor_field_formal_dynamic_dynamic() async { |
| var library = |
| await checkLibrary('class C { dynamic x; C(dynamic this.x); }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| x @18 |
| type: dynamic |
| constructors |
| @21 |
| parameters |
| requiredPositional final this.x @36 |
| type: dynamic |
| field: self::@class::C::@field::x |
| accessors |
| synthetic get x @-1 |
| returnType: dynamic |
| synthetic set x @-1 |
| parameters |
| requiredPositional _x @-1 |
| type: dynamic |
| returnType: void |
| '''); |
| } |
| |
| test_class_constructor_field_formal_dynamic_typed() async { |
| var library = await checkLibrary('class C { dynamic x; C(int this.x); }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| x @18 |
| type: dynamic |
| constructors |
| @21 |
| parameters |
| requiredPositional final this.x @32 |
| type: int |
| field: self::@class::C::@field::x |
| accessors |
| synthetic get x @-1 |
| returnType: dynamic |
| synthetic set x @-1 |
| parameters |
| requiredPositional _x @-1 |
| type: dynamic |
| returnType: void |
| '''); |
| } |
| |
| test_class_constructor_field_formal_dynamic_untyped() async { |
| var library = await checkLibrary('class C { dynamic x; C(this.x); }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| x @18 |
| type: dynamic |
| constructors |
| @21 |
| parameters |
| requiredPositional final this.x @28 |
| type: dynamic |
| field: self::@class::C::@field::x |
| accessors |
| synthetic get x @-1 |
| returnType: dynamic |
| synthetic set x @-1 |
| parameters |
| requiredPositional _x @-1 |
| type: dynamic |
| returnType: void |
| '''); |
| } |
| |
| test_class_constructor_field_formal_functionTyped_noReturnType() async { |
| var library = await checkLibrary(r''' |
| class C { |
| var x; |
| C(this.x(double b)); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| x @16 |
| type: dynamic |
| constructors |
| @21 |
| parameters |
| requiredPositional final this.x @28 |
| type: dynamic Function(double) |
| parameters |
| requiredPositional b @37 |
| type: double |
| field: self::@class::C::@field::x |
| accessors |
| synthetic get x @-1 |
| returnType: dynamic |
| synthetic set x @-1 |
| parameters |
| requiredPositional _x @-1 |
| type: dynamic |
| returnType: void |
| '''); |
| } |
| |
| test_class_constructor_field_formal_functionTyped_withReturnType() async { |
| var library = await checkLibrary(r''' |
| class C { |
| var x; |
| C(int this.x(double b)); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| x @16 |
| type: dynamic |
| constructors |
| @21 |
| parameters |
| requiredPositional final this.x @32 |
| type: int Function(double) |
| parameters |
| requiredPositional b @41 |
| type: double |
| field: self::@class::C::@field::x |
| accessors |
| synthetic get x @-1 |
| returnType: dynamic |
| synthetic set x @-1 |
| parameters |
| requiredPositional _x @-1 |
| type: dynamic |
| returnType: void |
| '''); |
| } |
| |
| test_class_constructor_field_formal_functionTyped_withReturnType_generic() async { |
| var library = await checkLibrary(r''' |
| class C { |
| Function() f; |
| C(List<U> this.f<T, U>(T t)); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| f @23 |
| type: dynamic Function() |
| constructors |
| @28 |
| parameters |
| requiredPositional final this.f @43 |
| type: List<U> Function<T, U>(T) |
| typeParameters |
| covariant T @45 |
| covariant U @48 |
| parameters |
| requiredPositional t @53 |
| type: T |
| field: self::@class::C::@field::f |
| accessors |
| synthetic get f @-1 |
| returnType: dynamic Function() |
| synthetic set f @-1 |
| parameters |
| requiredPositional _f @-1 |
| type: dynamic Function() |
| returnType: void |
| '''); |
| } |
| |
| test_class_constructor_field_formal_multiple_matching_fields() async { |
| // This is a compile-time error but it should still analyze consistently. |
| var library = await checkLibrary('class C { C(this.x); int x; String x; }', |
| allowErrors: true); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| x @25 |
| type: int |
| x @35 |
| type: String |
| constructors |
| @10 |
| parameters |
| requiredPositional final this.x @17 |
| type: int |
| field: self::@class::C::@field::x |
| accessors |
| synthetic get x @-1 |
| returnType: int |
| synthetic set x @-1 |
| parameters |
| requiredPositional _x @-1 |
| type: int |
| returnType: void |
| synthetic get x @-1 |
| returnType: String |
| synthetic set x @-1 |
| parameters |
| requiredPositional _x @-1 |
| type: String |
| returnType: void |
| '''); |
| } |
| |
| test_class_constructor_field_formal_no_matching_field() async { |
| // This is a compile-time error but it should still analyze consistently. |
| var library = |
| await checkLibrary('class C { C(this.x); }', allowErrors: true); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| @10 |
| parameters |
| requiredPositional final this.x @17 |
| type: dynamic |
| field: <null> |
| '''); |
| } |
| |
| test_class_constructor_field_formal_typed_dynamic() async { |
| var library = await checkLibrary('class C { num x; C(dynamic this.x); }', |
| allowErrors: true); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| x @14 |
| type: num |
| constructors |
| @17 |
| parameters |
| requiredPositional final this.x @32 |
| type: dynamic |
| field: self::@class::C::@field::x |
| accessors |
| synthetic get x @-1 |
| returnType: num |
| synthetic set x @-1 |
| parameters |
| requiredPositional _x @-1 |
| type: num |
| returnType: void |
| '''); |
| } |
| |
| test_class_constructor_field_formal_typed_typed() async { |
| var library = await checkLibrary('class C { num x; C(int this.x); }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| x @14 |
| type: num |
| constructors |
| @17 |
| parameters |
| requiredPositional final this.x @28 |
| type: int |
| field: self::@class::C::@field::x |
| accessors |
| synthetic get x @-1 |
| returnType: num |
| synthetic set x @-1 |
| parameters |
| requiredPositional _x @-1 |
| type: num |
| returnType: void |
| '''); |
| } |
| |
| test_class_constructor_field_formal_typed_untyped() async { |
| var library = await checkLibrary('class C { num x; C(this.x); }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| x @14 |
| type: num |
| constructors |
| @17 |
| parameters |
| requiredPositional final this.x @24 |
| type: num |
| field: self::@class::C::@field::x |
| accessors |
| synthetic get x @-1 |
| returnType: num |
| synthetic set x @-1 |
| parameters |
| requiredPositional _x @-1 |
| type: num |
| returnType: void |
| '''); |
| } |
| |
| test_class_constructor_field_formal_untyped_dynamic() async { |
| var library = await checkLibrary('class C { var x; C(dynamic this.x); }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| x @14 |
| type: dynamic |
| constructors |
| @17 |
| parameters |
| requiredPositional final this.x @32 |
| type: dynamic |
| field: self::@class::C::@field::x |
| accessors |
| synthetic get x @-1 |
| returnType: dynamic |
| synthetic set x @-1 |
| parameters |
| requiredPositional _x @-1 |
| type: dynamic |
| returnType: void |
| '''); |
| } |
| |
| test_class_constructor_field_formal_untyped_typed() async { |
| var library = await checkLibrary('class C { var x; C(int this.x); }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| x @14 |
| type: dynamic |
| constructors |
| @17 |
| parameters |
| requiredPositional final this.x @28 |
| type: int |
| field: self::@class::C::@field::x |
| accessors |
| synthetic get x @-1 |
| returnType: dynamic |
| synthetic set x @-1 |
| parameters |
| requiredPositional _x @-1 |
| type: dynamic |
| returnType: void |
| '''); |
| } |
| |
| test_class_constructor_field_formal_untyped_untyped() async { |
| var library = await checkLibrary('class C { var x; C(this.x); }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| x @14 |
| type: dynamic |
| constructors |
| @17 |
| parameters |
| requiredPositional final this.x @24 |
| type: dynamic |
| field: self::@class::C::@field::x |
| accessors |
| synthetic get x @-1 |
| returnType: dynamic |
| synthetic set x @-1 |
| parameters |
| requiredPositional _x @-1 |
| type: dynamic |
| returnType: void |
| '''); |
| } |
| |
| test_class_constructor_fieldFormal_named_noDefault() async { |
| var library = await checkLibrary('class C { int x; C({this.x}); }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| x @14 |
| type: int |
| constructors |
| @17 |
| parameters |
| optionalNamed final this.x @25 |
| type: int |
| field: self::@class::C::@field::x |
| accessors |
| synthetic get x @-1 |
| returnType: int |
| synthetic set x @-1 |
| parameters |
| requiredPositional _x @-1 |
| type: int |
| returnType: void |
| '''); |
| } |
| |
| test_class_constructor_fieldFormal_named_withDefault() async { |
| var library = await checkLibrary('class C { int x; C({this.x: 42}); }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| x @14 |
| type: int |
| constructors |
| @17 |
| parameters |
| optionalNamed final this.x @25 |
| type: int |
| constantInitializer |
| IntegerLiteral |
| literal: 42 @28 |
| staticType: int |
| field: self::@class::C::@field::x |
| accessors |
| synthetic get x @-1 |
| returnType: int |
| synthetic set x @-1 |
| parameters |
| requiredPositional _x @-1 |
| type: int |
| returnType: void |
| '''); |
| } |
| |
| test_class_constructor_fieldFormal_optional_noDefault() async { |
| var library = await checkLibrary('class C { int x; C([this.x]); }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| x @14 |
| type: int |
| constructors |
| @17 |
| parameters |
| optionalPositional final this.x @25 |
| type: int |
| field: self::@class::C::@field::x |
| accessors |
| synthetic get x @-1 |
| returnType: int |
| synthetic set x @-1 |
| parameters |
| requiredPositional _x @-1 |
| type: int |
| returnType: void |
| '''); |
| } |
| |
| test_class_constructor_fieldFormal_optional_withDefault() async { |
| var library = await checkLibrary('class C { int x; C([this.x = 42]); }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| x @14 |
| type: int |
| constructors |
| @17 |
| parameters |
| optionalPositional final this.x @25 |
| type: int |
| constantInitializer |
| IntegerLiteral |
| literal: 42 @29 |
| staticType: int |
| field: self::@class::C::@field::x |
| accessors |
| synthetic get x @-1 |
| returnType: int |
| synthetic set x @-1 |
| parameters |
| requiredPositional _x @-1 |
| type: int |
| returnType: void |
| '''); |
| } |
| |
| test_class_constructor_implicit_type_params() async { |
| var library = await checkLibrary('class C<T, U> {}'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| typeParameters |
| covariant T @8 |
| defaultType: dynamic |
| covariant U @11 |
| defaultType: dynamic |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_constructor_initializers_assertInvocation() async { |
| var library = await checkLibrary(''' |
| class C { |
| const C(int x) : assert(x >= 42); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| const @18 |
| parameters |
| requiredPositional x @24 |
| type: int |
| constantInitializers |
| AssertInitializer |
| assertKeyword: assert @29 |
| leftParenthesis: ( @35 |
| condition: BinaryExpression |
| leftOperand: SimpleIdentifier |
| token: x @36 |
| staticElement: x@24 |
| staticType: int |
| operator: >= @38 |
| rightOperand: IntegerLiteral |
| literal: 42 @41 |
| staticType: int |
| staticElement: dart:core::@class::num::@method::>= |
| staticInvokeType: bool Function(num) |
| staticType: bool |
| rightParenthesis: ) @43 |
| '''); |
| } |
| |
| test_class_constructor_initializers_assertInvocation_message() async { |
| var library = await checkLibrary(''' |
| class C { |
| const C(int x) : assert(x >= 42, 'foo'); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| const @18 |
| parameters |
| requiredPositional x @24 |
| type: int |
| constantInitializers |
| AssertInitializer |
| assertKeyword: assert @29 |
| leftParenthesis: ( @35 |
| condition: BinaryExpression |
| leftOperand: SimpleIdentifier |
| token: x @36 |
| staticElement: x@24 |
| staticType: int |
| operator: >= @38 |
| rightOperand: IntegerLiteral |
| literal: 42 @41 |
| staticType: int |
| staticElement: dart:core::@class::num::@method::>= |
| staticInvokeType: bool Function(num) |
| staticType: bool |
| comma: , @43 |
| message: SimpleStringLiteral |
| literal: 'foo' @45 |
| rightParenthesis: ) @50 |
| '''); |
| } |
| |
| test_class_constructor_initializers_field() async { |
| var library = await checkLibrary(''' |
| class C { |
| final x; |
| const C() : x = 42; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| final x @18 |
| type: dynamic |
| constructors |
| const @29 |
| constantInitializers |
| ConstructorFieldInitializer |
| fieldName: SimpleIdentifier |
| token: x @35 |
| staticElement: self::@class::C::@field::x |
| staticType: null |
| equals: = @37 |
| expression: IntegerLiteral |
| literal: 42 @39 |
| staticType: int |
| accessors |
| synthetic get x @-1 |
| returnType: dynamic |
| '''); |
| } |
| |
| test_class_constructor_initializers_field_notConst() async { |
| var library = await checkLibrary(''' |
| class C { |
| final x; |
| const C() : x = foo(); |
| } |
| int foo() => 42; |
| ''', allowErrors: true); |
| // It is OK to keep non-constant initializers. |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| final x @18 |
| type: dynamic |
| constructors |
| const @29 |
| constantInitializers |
| ConstructorFieldInitializer |
| fieldName: SimpleIdentifier |
| token: x @35 |
| staticElement: self::@class::C::@field::x |
| staticType: null |
| equals: = @37 |
| expression: MethodInvocation |
| methodName: SimpleIdentifier |
| token: foo @39 |
| staticElement: self::@function::foo |
| staticType: int Function() |
| argumentList: ArgumentList |
| leftParenthesis: ( @42 |
| rightParenthesis: ) @43 |
| staticInvokeType: int Function() |
| staticType: int |
| accessors |
| synthetic get x @-1 |
| returnType: dynamic |
| functions |
| foo @52 |
| returnType: int |
| '''); |
| } |
| |
| test_class_constructor_initializers_field_optionalPositionalParameter() async { |
| var library = await checkLibrary(''' |
| class A { |
| final int _f; |
| const A([int f = 0]) : _f = f; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class A @6 |
| fields |
| final _f @22 |
| type: int |
| constructors |
| const @34 |
| parameters |
| optionalPositional f @41 |
| type: int |
| constantInitializer |
| IntegerLiteral |
| literal: 0 @45 |
| staticType: int |
| constantInitializers |
| ConstructorFieldInitializer |
| fieldName: SimpleIdentifier |
| token: _f @51 |
| staticElement: self::@class::A::@field::_f |
| staticType: null |
| equals: = @54 |
| expression: SimpleIdentifier |
| token: f @56 |
| staticElement: self::@class::A::@constructor::•::@parameter::f |
| staticType: int |
| accessors |
| synthetic get _f @-1 |
| returnType: int |
| '''); |
| } |
| |
| test_class_constructor_initializers_field_withParameter() async { |
| var library = await checkLibrary(''' |
| class C { |
| final x; |
| const C(int p) : x = 1 + p; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| final x @18 |
| type: dynamic |
| constructors |
| const @29 |
| parameters |
| requiredPositional p @35 |
| type: int |
| constantInitializers |
| ConstructorFieldInitializer |
| fieldName: SimpleIdentifier |
| token: x @40 |
| staticElement: self::@class::C::@field::x |
| staticType: null |
| equals: = @42 |
| expression: BinaryExpression |
| leftOperand: IntegerLiteral |
| literal: 1 @44 |
| staticType: int |
| operator: + @46 |
| rightOperand: SimpleIdentifier |
| token: p @48 |
| staticElement: p@35 |
| staticType: int |
| staticElement: dart:core::@class::num::@method::+ |
| staticInvokeType: num Function(num) |
| staticType: int |
| accessors |
| synthetic get x @-1 |
| returnType: dynamic |
| '''); |
| } |
| |
| test_class_constructor_initializers_genericFunctionType() async { |
| var library = await checkLibrary(''' |
| class A<T> { |
| const A(); |
| } |
| class B { |
| const B(dynamic x); |
| const B.f() |
| : this(A<Function()>()); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class A @6 |
| typeParameters |
| covariant T @8 |
| defaultType: dynamic |
| constructors |
| const @21 |
| class B @34 |
| constructors |
| const @46 |
| parameters |
| requiredPositional x @56 |
| type: dynamic |
| const f @70 |
| periodOffset: 69 |
| nameEnd: 71 |
| constantInitializers |
| RedirectingConstructorInvocation |
| thisKeyword: this @79 |
| argumentList: ArgumentList |
| leftParenthesis: ( @83 |
| arguments |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: A @84 |
| staticElement: self::@class::A |
| staticType: null |
| typeArguments: TypeArgumentList |
| leftBracket: < @85 |
| arguments |
| GenericFunctionType |
| functionKeyword: Function @86 |
| parameters: FormalParameterList |
| leftParenthesis: ( @94 |
| rightParenthesis: ) @95 |
| declaredElement: GenericFunctionTypeElement |
| parameters |
| returnType: dynamic |
| type: dynamic Function() |
| type: dynamic Function() |
| rightBracket: > @96 |
| type: A<dynamic Function()> |
| staticElement: ConstructorMember |
| base: self::@class::A::@constructor::• |
| substitution: {T: dynamic Function()} |
| argumentList: ArgumentList |
| leftParenthesis: ( @97 |
| rightParenthesis: ) @98 |
| staticType: A<dynamic Function()> |
| rightParenthesis: ) @99 |
| staticElement: self::@class::B::@constructor::• |
| redirectedConstructor: self::@class::B::@constructor::• |
| '''); |
| } |
| |
| test_class_constructor_initializers_superInvocation_argumentContextType() async { |
| var library = await checkLibrary(''' |
| class A { |
| const A(List<String> values); |
| } |
| class B extends A { |
| const B() : super(const []); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class A @6 |
| constructors |
| const @18 |
| parameters |
| requiredPositional values @33 |
| type: List<String> |
| class B @50 |
| supertype: A |
| constructors |
| const @72 |
| constantInitializers |
| SuperConstructorInvocation |
| superKeyword: super @78 |
| argumentList: ArgumentList |
| leftParenthesis: ( @83 |
| arguments |
| ListLiteral |
| constKeyword: const @84 |
| leftBracket: [ @90 |
| rightBracket: ] @91 |
| staticType: List<String> |
| rightParenthesis: ) @92 |
| staticElement: self::@class::A::@constructor::• |
| superConstructor: self::@class::A::@constructor::• |
| '''); |
| } |
| |
| test_class_constructor_initializers_superInvocation_named() async { |
| var library = await checkLibrary(''' |
| class A { |
| const A.aaa(int p); |
| } |
| class C extends A { |
| const C() : super.aaa(42); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class A @6 |
| constructors |
| const aaa @20 |
| periodOffset: 19 |
| nameEnd: 23 |
| parameters |
| requiredPositional p @28 |
| type: int |
| class C @40 |
| supertype: A |
| constructors |
| const @62 |
| constantInitializers |
| SuperConstructorInvocation |
| superKeyword: super @68 |
| period: . @73 |
| constructorName: SimpleIdentifier |
| token: aaa @74 |
| staticElement: self::@class::A::@constructor::aaa |
| staticType: null |
| argumentList: ArgumentList |
| leftParenthesis: ( @77 |
| arguments |
| IntegerLiteral |
| literal: 42 @78 |
| staticType: int |
| rightParenthesis: ) @80 |
| staticElement: self::@class::A::@constructor::aaa |
| superConstructor: self::@class::A::@constructor::aaa |
| '''); |
| } |
| |
| test_class_constructor_initializers_superInvocation_named_underscore() async { |
| var library = await checkLibrary(''' |
| class A { |
| const A._(); |
| } |
| class B extends A { |
| const B() : super._(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class A @6 |
| constructors |
| const _ @20 |
| periodOffset: 19 |
| nameEnd: 21 |
| class B @33 |
| supertype: A |
| constructors |
| const @55 |
| constantInitializers |
| SuperConstructorInvocation |
| superKeyword: super @61 |
| period: . @66 |
| constructorName: SimpleIdentifier |
| token: _ @67 |
| staticElement: self::@class::A::@constructor::_ |
| staticType: null |
| argumentList: ArgumentList |
| leftParenthesis: ( @68 |
| rightParenthesis: ) @69 |
| staticElement: self::@class::A::@constructor::_ |
| superConstructor: self::@class::A::@constructor::_ |
| '''); |
| } |
| |
| test_class_constructor_initializers_superInvocation_namedExpression() async { |
| var library = await checkLibrary(''' |
| class A { |
| const A.aaa(a, {int b}); |
| } |
| class C extends A { |
| const C() : super.aaa(1, b: 2); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class A @6 |
| constructors |
| const aaa @20 |
| periodOffset: 19 |
| nameEnd: 23 |
| parameters |
| requiredPositional a @24 |
| type: dynamic |
| optionalNamed b @32 |
| type: int |
| class C @45 |
| supertype: A |
| constructors |
| const @67 |
| constantInitializers |
| SuperConstructorInvocation |
| superKeyword: super @73 |
| period: . @78 |
| constructorName: SimpleIdentifier |
| token: aaa @79 |
| staticElement: self::@class::A::@constructor::aaa |
| staticType: null |
| argumentList: ArgumentList |
| leftParenthesis: ( @82 |
| arguments |
| IntegerLiteral |
| literal: 1 @83 |
| staticType: int |
| NamedExpression |
| name: Label |
| label: SimpleIdentifier |
| token: b @86 |
| staticElement: self::@class::A::@constructor::aaa::@parameter::b |
| staticType: null |
| colon: : @87 |
| expression: IntegerLiteral |
| literal: 2 @89 |
| staticType: int |
| rightParenthesis: ) @90 |
| staticElement: self::@class::A::@constructor::aaa |
| superConstructor: self::@class::A::@constructor::aaa |
| '''); |
| } |
| |
| test_class_constructor_initializers_superInvocation_unnamed() async { |
| var library = await checkLibrary(''' |
| class A { |
| const A(int p); |
| } |
| class C extends A { |
| const C.ccc() : super(42); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class A @6 |
| constructors |
| const @18 |
| parameters |
| requiredPositional p @24 |
| type: int |
| class C @36 |
| supertype: A |
| constructors |
| const ccc @60 |
| periodOffset: 59 |
| nameEnd: 63 |
| constantInitializers |
| SuperConstructorInvocation |
| superKeyword: super @68 |
| argumentList: ArgumentList |
| leftParenthesis: ( @73 |
| arguments |
| IntegerLiteral |
| literal: 42 @74 |
| staticType: int |
| rightParenthesis: ) @76 |
| staticElement: self::@class::A::@constructor::• |
| superConstructor: self::@class::A::@constructor::• |
| '''); |
| } |
| |
| test_class_constructor_initializers_thisInvocation_argumentContextType() async { |
| var library = await checkLibrary(''' |
| class A { |
| const A(List<String> values); |
| const A.empty() : this(const []); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class A @6 |
| constructors |
| const @18 |
| parameters |
| requiredPositional values @33 |
| type: List<String> |
| const empty @52 |
| periodOffset: 51 |
| nameEnd: 57 |
| constantInitializers |
| RedirectingConstructorInvocation |
| thisKeyword: this @62 |
| argumentList: ArgumentList |
| leftParenthesis: ( @66 |
| arguments |
| ListLiteral |
| constKeyword: const @67 |
| leftBracket: [ @73 |
| rightBracket: ] @74 |
| staticType: List<String> |
| rightParenthesis: ) @75 |
| staticElement: self::@class::A::@constructor::• |
| redirectedConstructor: self::@class::A::@constructor::• |
| '''); |
| } |
| |
| test_class_constructor_initializers_thisInvocation_named() async { |
| var library = await checkLibrary(''' |
| class C { |
| const C() : this.named(1, 'bbb'); |
| const C.named(int a, String b); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| const @18 |
| constantInitializers |
| RedirectingConstructorInvocation |
| thisKeyword: this @24 |
| period: . @28 |
| constructorName: SimpleIdentifier |
| token: named @29 |
| staticElement: self::@class::C::@constructor::named |
| staticType: null |
| argumentList: ArgumentList |
| leftParenthesis: ( @34 |
| arguments |
| IntegerLiteral |
| literal: 1 @35 |
| staticType: int |
| SimpleStringLiteral |
| literal: 'bbb' @38 |
| rightParenthesis: ) @43 |
| staticElement: self::@class::C::@constructor::named |
| redirectedConstructor: self::@class::C::@constructor::named |
| const named @56 |
| periodOffset: 55 |
| nameEnd: 61 |
| parameters |
| requiredPositional a @66 |
| type: int |
| requiredPositional b @76 |
| type: String |
| '''); |
| } |
| |
| test_class_constructor_initializers_thisInvocation_namedExpression() async { |
| var library = await checkLibrary(''' |
| class C { |
| const C() : this.named(1, b: 2); |
| const C.named(a, {int b}); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| const @18 |
| constantInitializers |
| RedirectingConstructorInvocation |
| thisKeyword: this @24 |
| period: . @28 |
| constructorName: SimpleIdentifier |
| token: named @29 |
| staticElement: self::@class::C::@constructor::named |
| staticType: null |
| argumentList: ArgumentList |
| leftParenthesis: ( @34 |
| arguments |
| IntegerLiteral |
| literal: 1 @35 |
| staticType: int |
| NamedExpression |
| name: Label |
| label: SimpleIdentifier |
| token: b @38 |
| staticElement: self::@class::C::@constructor::named::@parameter::b |
| staticType: null |
| colon: : @39 |
| expression: IntegerLiteral |
| literal: 2 @41 |
| staticType: int |
| rightParenthesis: ) @42 |
| staticElement: self::@class::C::@constructor::named |
| redirectedConstructor: self::@class::C::@constructor::named |
| const named @55 |
| periodOffset: 54 |
| nameEnd: 60 |
| parameters |
| requiredPositional a @61 |
| type: dynamic |
| optionalNamed b @69 |
| type: int |
| '''); |
| } |
| |
| test_class_constructor_initializers_thisInvocation_unnamed() async { |
| var library = await checkLibrary(''' |
| class C { |
| const C.named() : this(1, 'bbb'); |
| const C(int a, String b); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| const named @20 |
| periodOffset: 19 |
| nameEnd: 25 |
| constantInitializers |
| RedirectingConstructorInvocation |
| thisKeyword: this @30 |
| argumentList: ArgumentList |
| leftParenthesis: ( @34 |
| arguments |
| IntegerLiteral |
| literal: 1 @35 |
| staticType: int |
| SimpleStringLiteral |
| literal: 'bbb' @38 |
| rightParenthesis: ) @43 |
| staticElement: self::@class::C::@constructor::• |
| redirectedConstructor: self::@class::C::@constructor::• |
| const @54 |
| parameters |
| requiredPositional a @60 |
| type: int |
| requiredPositional b @70 |
| type: String |
| '''); |
| } |
| |
| test_class_constructor_parameters_super_explicitType_function() async { |
| var library = await checkLibrary(''' |
| class A { |
| A(Object? a); |
| } |
| |
| class B extends A { |
| B(int super.a<T extends num>(T d)?); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class A @6 |
| constructors |
| @12 |
| parameters |
| requiredPositional a @22 |
| type: Object? |
| class B @35 |
| supertype: A |
| constructors |
| @51 |
| parameters |
| requiredPositional final super.a @63 |
| type: int Function<T extends num>(T)? |
| typeParameters |
| covariant T @65 |
| bound: num |
| parameters |
| requiredPositional d @82 |
| type: T |
| superConstructorParameter: a@22 |
| superConstructor: self::@class::A::@constructor::• |
| '''); |
| } |
| |
| test_class_constructor_parameters_super_explicitType_interface() async { |
| var library = await checkLibrary(''' |
| class A { |
| A(num a); |
| } |
| |
| class B extends A { |
| B(int super.a); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class A @6 |
| constructors |
| @12 |
| parameters |
| requiredPositional a @18 |
| type: num |
| class B @31 |
| supertype: A |
| constructors |
| @47 |
| parameters |
| requiredPositional final super.a @59 |
| type: int |
| superConstructorParameter: a@18 |
| superConstructor: self::@class::A::@constructor::• |
| '''); |
| } |
| |
| test_class_constructor_parameters_super_explicitType_interface_nullable() async { |
| var library = await checkLibrary(''' |
| class A { |
| A(num? a); |
| } |
| |
| class B extends A { |
| B(int? super.a); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class A @6 |
| constructors |
| @12 |
| parameters |
| requiredPositional a @19 |
| type: num? |
| class B @32 |
| supertype: A |
| constructors |
| @48 |
| parameters |
| requiredPositional final super.a @61 |
| type: int? |
| superConstructorParameter: a@19 |
| superConstructor: self::@class::A::@constructor::• |
| '''); |
| } |
| |
| test_class_constructor_parameters_super_invalid_topFunction() async { |
| var library = await checkLibrary(''' |
| void f(super.a) {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| functions |
| f @5 |
| parameters |
| requiredPositional final super.a @13 |
| type: dynamic |
| superConstructorParameter: <null> |
| returnType: void |
| '''); |
| } |
| |
| test_class_constructor_parameters_super_optionalNamed() async { |
| var library = await checkLibrary(''' |
| class A { |
| A({required int a, required double b}); |
| } |
| |
| class B extends A { |
| B({String o1, super.a, String o2, super.b}) : super(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class A @6 |
| constructors |
| @12 |
| parameters |
| requiredNamed a @28 |
| type: int |
| requiredNamed b @47 |
| type: double |
| class B @61 |
| supertype: A |
| constructors |
| @77 |
| parameters |
| optionalNamed o1 @87 |
| type: String |
| optionalNamed final super.a @97 |
| type: int |
| superConstructorParameter: self::@class::A::@constructor::•::@parameter::a |
| optionalNamed o2 @107 |
| type: String |
| optionalNamed final super.b @117 |
| type: double |
| superConstructorParameter: self::@class::A::@constructor::•::@parameter::b |
| superConstructor: self::@class::A::@constructor::• |
| '''); |
| } |
| |
| test_class_constructor_parameters_super_optionalNamed_unresolved() async { |
| var library = await checkLibrary(''' |
| class A { |
| A({required int a}); |
| } |
| |
| class B extends A { |
| B({super.b}); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class A @6 |
| constructors |
| @12 |
| parameters |
| requiredNamed a @28 |
| type: int |
| class B @42 |
| supertype: A |
| constructors |
| @58 |
| parameters |
| optionalNamed final super.b @67 |
| type: dynamic |
| superConstructorParameter: <null> |
| superConstructor: self::@class::A::@constructor::• |
| '''); |
| } |
| |
| test_class_constructor_parameters_super_optionalNamed_unresolved2() async { |
| var library = await checkLibrary(''' |
| class A { |
| A(int a); |
| } |
| |
| class B extends A { |
| B({super.a}); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class A @6 |
| constructors |
| @12 |
| parameters |
| requiredPositional a @18 |
| type: int |
| class B @31 |
| supertype: A |
| constructors |
| @47 |
| parameters |
| optionalNamed final super.a @56 |
| type: dynamic |
| superConstructorParameter: <null> |
| superConstructor: self::@class::A::@constructor::• |
| '''); |
| } |
| |
| test_class_constructor_parameters_super_optionalPositional() async { |
| var library = await checkLibrary(''' |
| class A { |
| A(int a, double b); |
| } |
| |
| class B extends A { |
| B([String o1, super.a, String o2, super.b]) : super(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class A @6 |
| constructors |
| @12 |
| parameters |
| requiredPositional a @18 |
| type: int |
| requiredPositional b @28 |
| type: double |
| class B @41 |
| supertype: A |
| constructors |
| @57 |
| parameters |
| optionalPositional o1 @67 |
| type: String |
| optionalPositional final super.a @77 |
| type: int |
| superConstructorParameter: a@18 |
| optionalPositional o2 @87 |
| type: String |
| optionalPositional final super.b @97 |
| type: double |
| superConstructorParameter: b@28 |
| superConstructor: self::@class::A::@constructor::• |
| '''); |
| } |
| |
| test_class_constructor_parameters_super_requiredNamed() async { |
| var library = await checkLibrary(''' |
| class A { |
| A({required int a, required double b}); |
| } |
| |
| class B extends A { |
| B({ |
| required String o1, |
| required super.a, |
| required String o2, |
| required super.b, |
| }) : super(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class A @6 |
| constructors |
| @12 |
| parameters |
| requiredNamed a @28 |
| type: int |
| requiredNamed b @47 |
| type: double |
| class B @61 |
| supertype: A |
| constructors |
| @77 |
| parameters |
| requiredNamed o1 @101 |
| type: String |
| requiredNamed final super.a @124 |
| type: int |
| superConstructorParameter: self::@class::A::@constructor::•::@parameter::a |
| requiredNamed o2 @147 |
| type: String |
| requiredNamed final super.b @170 |
| type: double |
| superConstructorParameter: self::@class::A::@constructor::•::@parameter::b |
| superConstructor: self::@class::A::@constructor::• |
| '''); |
| } |
| |
| test_class_constructor_parameters_super_requiredPositional() async { |
| var library = await checkLibrary(''' |
| class A { |
| A(int a, double b); |
| } |
| |
| class B extends A { |
| B(String o1, super.a, String o2, super.b) : super(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class A @6 |
| constructors |
| @12 |
| parameters |
| requiredPositional a @18 |
| type: int |
| requiredPositional b @28 |
| type: double |
| class B @41 |
| supertype: A |
| constructors |
| @57 |
| parameters |
| requiredPositional o1 @66 |
| type: String |
| requiredPositional final super.a @76 |
| type: int |
| superConstructorParameter: a@18 |
| requiredPositional o2 @86 |
| type: String |
| requiredPositional final super.b @96 |
| type: double |
| superConstructorParameter: b@28 |
| superConstructor: self::@class::A::@constructor::• |
| '''); |
| } |
| |
| test_class_constructor_parameters_super_requiredPositional_unresolved() async { |
| var library = await checkLibrary(''' |
| class A {} |
| |
| class B extends A { |
| B(super.a); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class A @6 |
| constructors |
| synthetic @-1 |
| class B @18 |
| supertype: A |
| constructors |
| @34 |
| parameters |
| requiredPositional final super.a @42 |
| type: dynamic |
| superConstructorParameter: <null> |
| superConstructor: self::@class::A::@constructor::• |
| '''); |
| } |
| |
| test_class_constructor_parameters_super_requiredPositional_unresolved2() async { |
| var library = await checkLibrary(''' |
| class A { |
| A({required int a}) |
| } |
| |
| class B extends A { |
| B(super.a); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class A @6 |
| constructors |
| @12 |
| parameters |
| requiredNamed a @28 |
| type: int |
| class B @41 |
| supertype: A |
| constructors |
| @57 |
| parameters |
| requiredPositional final super.a @65 |
| type: dynamic |
| superConstructorParameter: <null> |
| superConstructor: self::@class::A::@constructor::• |
| '''); |
| } |
| |
| test_class_constructor_params() async { |
| var library = await checkLibrary('class C { C(x, int y); }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| @10 |
| parameters |
| requiredPositional x @12 |
| type: dynamic |
| requiredPositional y @19 |
| type: int |
| '''); |
| } |
| |
| test_class_constructor_redirected_factory_named() async { |
| var library = await checkLibrary(''' |
| class C { |
| factory C() = D.named; |
| C._(); |
| } |
| class D extends C { |
| D.named() : super._(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| factory @20 |
| redirectedConstructor: self::@class::D::@constructor::named |
| _ @39 |
| periodOffset: 38 |
| nameEnd: 40 |
| class D @52 |
| supertype: C |
| constructors |
| named @70 |
| periodOffset: 69 |
| nameEnd: 75 |
| superConstructor: self::@class::C::@constructor::_ |
| '''); |
| } |
| |
| test_class_constructor_redirected_factory_named_generic() async { |
| var library = await checkLibrary(''' |
| class C<T, U> { |
| factory C() = D<U, T>.named; |
| C._(); |
| } |
| class D<T, U> extends C<U, T> { |
| D.named() : super._(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| typeParameters |
| covariant T @8 |
| defaultType: dynamic |
| covariant U @11 |
| defaultType: dynamic |
| constructors |
| factory @26 |
| redirectedConstructor: ConstructorMember |
| base: self::@class::D::@constructor::named |
| substitution: {T: U, U: T} |
| _ @51 |
| periodOffset: 50 |
| nameEnd: 52 |
| class D @64 |
| typeParameters |
| covariant T @66 |
| defaultType: dynamic |
| covariant U @69 |
| defaultType: dynamic |
| supertype: C<U, T> |
| constructors |
| named @94 |
| periodOffset: 93 |
| nameEnd: 99 |
| superConstructor: ConstructorMember |
| base: self::@class::C::@constructor::_ |
| substitution: {T: U, U: T} |
| '''); |
| } |
| |
| test_class_constructor_redirected_factory_named_generic_viaTypeAlias() async { |
| var library = await checkLibrary(''' |
| typedef A<T, U> = C<T, U>; |
| class B<T, U> { |
| factory B() = A<U, T>.named; |
| B._(); |
| } |
| class C<T, U> extends A<U, T> { |
| C.named() : super._(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class B @33 |
| typeParameters |
| covariant T @35 |
| defaultType: dynamic |
| covariant U @38 |
| defaultType: dynamic |
| constructors |
| factory @53 |
| redirectedConstructor: ConstructorMember |
| base: self::@class::C::@constructor::named |
| substitution: {T: U, U: T} |
| _ @78 |
| periodOffset: 77 |
| nameEnd: 79 |
| class C @91 |
| typeParameters |
| covariant T @93 |
| defaultType: dynamic |
| covariant U @96 |
| defaultType: dynamic |
| supertype: C<U, T> |
| aliasElement: self::@typeAlias::A |
| aliasArguments |
| U |
| T |
| constructors |
| named @121 |
| periodOffset: 120 |
| nameEnd: 126 |
| typeAliases |
| A @8 |
| typeParameters |
| covariant T @10 |
| defaultType: dynamic |
| covariant U @13 |
| defaultType: dynamic |
| aliasedType: C<T, U> |
| '''); |
| } |
| |
| test_class_constructor_redirected_factory_named_imported() async { |
| addLibrarySource('/foo.dart', ''' |
| import 'test.dart'; |
| class D extends C { |
| D.named() : super._(); |
| } |
| '''); |
| var library = await checkLibrary(''' |
| import 'foo.dart'; |
| class C { |
| factory C() = D.named; |
| C._(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| imports |
| foo.dart |
| definingUnit |
| classes |
| class C @25 |
| constructors |
| factory @39 |
| redirectedConstructor: foo.dart::@class::D::@constructor::named |
| _ @58 |
| periodOffset: 57 |
| nameEnd: 59 |
| '''); |
| } |
| |
| test_class_constructor_redirected_factory_named_imported_generic() async { |
| addLibrarySource('/foo.dart', ''' |
| import 'test.dart'; |
| class D<T, U> extends C<U, T> { |
| D.named() : super._(); |
| } |
| '''); |
| var library = await checkLibrary(''' |
| import 'foo.dart'; |
| class C<T, U> { |
| factory C() = D<U, T>.named; |
| C._(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| imports |
| foo.dart |
| definingUnit |
| classes |
| class C @25 |
| typeParameters |
| covariant T @27 |
| defaultType: dynamic |
| covariant U @30 |
| defaultType: dynamic |
| constructors |
| factory @45 |
| redirectedConstructor: ConstructorMember |
| base: foo.dart::@class::D::@constructor::named |
| substitution: {T: U, U: T} |
| _ @70 |
| periodOffset: 69 |
| nameEnd: 71 |
| '''); |
| } |
| |
| test_class_constructor_redirected_factory_named_prefixed() async { |
| addLibrarySource('/foo.dart', ''' |
| import 'test.dart'; |
| class D extends C { |
| D.named() : super._(); |
| } |
| '''); |
| var library = await checkLibrary(''' |
| import 'foo.dart' as foo; |
| class C { |
| factory C() = foo.D.named; |
| C._(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| imports |
| foo.dart as foo @21 |
| definingUnit |
| classes |
| class C @32 |
| constructors |
| factory @46 |
| redirectedConstructor: foo.dart::@class::D::@constructor::named |
| _ @69 |
| periodOffset: 68 |
| nameEnd: 70 |
| '''); |
| } |
| |
| test_class_constructor_redirected_factory_named_prefixed_generic() async { |
| addLibrarySource('/foo.dart', ''' |
| import 'test.dart'; |
| class D<T, U> extends C<U, T> { |
| D.named() : super._(); |
| } |
| '''); |
| var library = await checkLibrary(''' |
| import 'foo.dart' as foo; |
| class C<T, U> { |
| factory C() = foo.D<U, T>.named; |
| C._(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| imports |
| foo.dart as foo @21 |
| definingUnit |
| classes |
| class C @32 |
| typeParameters |
| covariant T @34 |
| defaultType: dynamic |
| covariant U @37 |
| defaultType: dynamic |
| constructors |
| factory @52 |
| redirectedConstructor: ConstructorMember |
| base: foo.dart::@class::D::@constructor::named |
| substitution: {T: U, U: T} |
| _ @81 |
| periodOffset: 80 |
| nameEnd: 82 |
| '''); |
| } |
| |
| test_class_constructor_redirected_factory_named_unresolved_class() async { |
| var library = await checkLibrary(''' |
| class C<E> { |
| factory C() = D.named<E>; |
| } |
| ''', allowErrors: true); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| typeParameters |
| covariant E @8 |
| defaultType: dynamic |
| constructors |
| factory @23 |
| '''); |
| } |
| |
| test_class_constructor_redirected_factory_named_unresolved_constructor() async { |
| var library = await checkLibrary(''' |
| class D {} |
| class C<E> { |
| factory C() = D.named<E>; |
| } |
| ''', allowErrors: true); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class D @6 |
| constructors |
| synthetic @-1 |
| class C @17 |
| typeParameters |
| covariant E @19 |
| defaultType: dynamic |
| constructors |
| factory @34 |
| '''); |
| } |
| |
| test_class_constructor_redirected_factory_unnamed() async { |
| var library = await checkLibrary(''' |
| class C { |
| factory C() = D; |
| C._(); |
| } |
| class D extends C { |
| D() : super._(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| factory @20 |
| redirectedConstructor: self::@class::D::@constructor::• |
| _ @33 |
| periodOffset: 32 |
| nameEnd: 34 |
| class D @46 |
| supertype: C |
| constructors |
| @62 |
| superConstructor: self::@class::C::@constructor::_ |
| '''); |
| } |
| |
| test_class_constructor_redirected_factory_unnamed_generic() async { |
| var library = await checkLibrary(''' |
| class C<T, U> { |
| factory C() = D<U, T>; |
| C._(); |
| } |
| class D<T, U> extends C<U, T> { |
| D() : super._(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| typeParameters |
| covariant T @8 |
| defaultType: dynamic |
| covariant U @11 |
| defaultType: dynamic |
| constructors |
| factory @26 |
| redirectedConstructor: ConstructorMember |
| base: self::@class::D::@constructor::• |
| substitution: {T: U, U: T} |
| _ @45 |
| periodOffset: 44 |
| nameEnd: 46 |
| class D @58 |
| typeParameters |
| covariant T @60 |
| defaultType: dynamic |
| covariant U @63 |
| defaultType: dynamic |
| supertype: C<U, T> |
| constructors |
| @86 |
| superConstructor: ConstructorMember |
| base: self::@class::C::@constructor::_ |
| substitution: {T: U, U: T} |
| '''); |
| } |
| |
| test_class_constructor_redirected_factory_unnamed_generic_viaTypeAlias() async { |
| var library = await checkLibrary(''' |
| typedef A<T, U> = C<T, U>; |
| class B<T, U> { |
| factory B() = A<U, T>; |
| B_(); |
| } |
| class C<T, U> extends B<U, T> { |
| C() : super._(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class B @33 |
| typeParameters |
| covariant T @35 |
| defaultType: dynamic |
| covariant U @38 |
| defaultType: dynamic |
| constructors |
| factory @53 |
| redirectedConstructor: ConstructorMember |
| base: self::@class::C::@constructor::• |
| substitution: {T: U, U: T} |
| methods |
| abstract B_ @70 |
| returnType: dynamic |
| class C @84 |
| typeParameters |
| covariant T @86 |
| defaultType: dynamic |
| covariant U @89 |
| defaultType: dynamic |
| supertype: B<U, T> |
| constructors |
| @112 |
| typeAliases |
| A @8 |
| typeParameters |
| covariant T @10 |
| defaultType: dynamic |
| covariant U @13 |
| defaultType: dynamic |
| aliasedType: C<T, U> |
| '''); |
| } |
| |
| test_class_constructor_redirected_factory_unnamed_imported() async { |
| addLibrarySource('/foo.dart', ''' |
| import 'test.dart'; |
| class D extends C { |
| D() : super._(); |
| } |
| '''); |
| var library = await checkLibrary(''' |
| import 'foo.dart'; |
| class C { |
| factory C() = D; |
| C._(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| imports |
| foo.dart |
| definingUnit |
| classes |
| class C @25 |
| constructors |
| factory @39 |
| redirectedConstructor: foo.dart::@class::D::@constructor::• |
| _ @52 |
| periodOffset: 51 |
| nameEnd: 53 |
| '''); |
| } |
| |
| test_class_constructor_redirected_factory_unnamed_imported_generic() async { |
| addLibrarySource('/foo.dart', ''' |
| import 'test.dart'; |
| class D<T, U> extends C<U, T> { |
| D() : super._(); |
| } |
| '''); |
| var library = await checkLibrary(''' |
| import 'foo.dart'; |
| class C<T, U> { |
| factory C() = D<U, T>; |
| C._(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| imports |
| foo.dart |
| definingUnit |
| classes |
| class C @25 |
| typeParameters |
| covariant T @27 |
| defaultType: dynamic |
| covariant U @30 |
| defaultType: dynamic |
| constructors |
| factory @45 |
| redirectedConstructor: ConstructorMember |
| base: foo.dart::@class::D::@constructor::• |
| substitution: {T: U, U: T} |
| _ @64 |
| periodOffset: 63 |
| nameEnd: 65 |
| '''); |
| } |
| |
| test_class_constructor_redirected_factory_unnamed_imported_viaTypeAlias() async { |
| addLibrarySource('/foo.dart', ''' |
| import 'test.dart'; |
| typedef A = B; |
| class B extends C { |
| B() : super._(); |
| } |
| '''); |
| var library = await checkLibrary(''' |
| import 'foo.dart'; |
| class C { |
| factory C() = A; |
| C._(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| imports |
| foo.dart |
| definingUnit |
| classes |
| class C @25 |
| constructors |
| factory @39 |
| redirectedConstructor: foo.dart::@class::B::@constructor::• |
| _ @52 |
| periodOffset: 51 |
| nameEnd: 53 |
| '''); |
| } |
| |
| test_class_constructor_redirected_factory_unnamed_prefixed() async { |
| addLibrarySource('/foo.dart', ''' |
| import 'test.dart'; |
| class D extends C { |
| D() : super._(); |
| } |
| '''); |
| var library = await checkLibrary(''' |
| import 'foo.dart' as foo; |
| class C { |
| factory C() = foo.D; |
| C._(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| imports |
| foo.dart as foo @21 |
| definingUnit |
| classes |
| class C @32 |
| constructors |
| factory @46 |
| redirectedConstructor: foo.dart::@class::D::@constructor::• |
| _ @63 |
| periodOffset: 62 |
| nameEnd: 64 |
| '''); |
| } |
| |
| test_class_constructor_redirected_factory_unnamed_prefixed_generic() async { |
| addLibrarySource('/foo.dart', ''' |
| import 'test.dart'; |
| class D<T, U> extends C<U, T> { |
| D() : super._(); |
| } |
| '''); |
| var library = await checkLibrary(''' |
| import 'foo.dart' as foo; |
| class C<T, U> { |
| factory C() = foo.D<U, T>; |
| C._(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| imports |
| foo.dart as foo @21 |
| definingUnit |
| classes |
| class C @32 |
| typeParameters |
| covariant T @34 |
| defaultType: dynamic |
| covariant U @37 |
| defaultType: dynamic |
| constructors |
| factory @52 |
| redirectedConstructor: ConstructorMember |
| base: foo.dart::@class::D::@constructor::• |
| substitution: {T: U, U: T} |
| _ @75 |
| periodOffset: 74 |
| nameEnd: 76 |
| '''); |
| } |
| |
| test_class_constructor_redirected_factory_unnamed_prefixed_viaTypeAlias() async { |
| addLibrarySource('/foo.dart', ''' |
| import 'test.dart'; |
| typedef A = B; |
| class B extends C { |
| B() : super._(); |
| } |
| '''); |
| var library = await checkLibrary(''' |
| import 'foo.dart' as foo; |
| class C { |
| factory C() = foo.A; |
| C._(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| imports |
| foo.dart as foo @21 |
| definingUnit |
| classes |
| class C @32 |
| constructors |
| factory @46 |
| redirectedConstructor: foo.dart::@class::B::@constructor::• |
| _ @63 |
| periodOffset: 62 |
| nameEnd: 64 |
| '''); |
| } |
| |
| test_class_constructor_redirected_factory_unnamed_unresolved() async { |
| var library = await checkLibrary(''' |
| class C<E> { |
| factory C() = D<E>; |
| } |
| ''', allowErrors: true); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| typeParameters |
| covariant E @8 |
| defaultType: dynamic |
| constructors |
| factory @23 |
| '''); |
| } |
| |
| test_class_constructor_redirected_factory_unnamed_viaTypeAlias() async { |
| var library = await checkLibrary(''' |
| typedef A = C; |
| class B { |
| factory B() = A; |
| B._(); |
| } |
| class C extends B { |
| C() : super._(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class B @21 |
| constructors |
| factory @35 |
| redirectedConstructor: self::@class::C::@constructor::• |
| _ @48 |
| periodOffset: 47 |
| nameEnd: 49 |
| class C @61 |
| supertype: B |
| constructors |
| @77 |
| superConstructor: self::@class::B::@constructor::_ |
| typeAliases |
| A @8 |
| aliasedType: C |
| '''); |
| } |
| |
| test_class_constructor_redirected_thisInvocation_named() async { |
| var library = await checkLibrary(''' |
| class C { |
| const C.named(); |
| const C() : this.named(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| const named @20 |
| periodOffset: 19 |
| nameEnd: 25 |
| const @37 |
| constantInitializers |
| RedirectingConstructorInvocation |
| thisKeyword: this @43 |
| period: . @47 |
| constructorName: SimpleIdentifier |
| token: named @48 |
| staticElement: self::@class::C::@constructor::named |
| staticType: null |
| argumentList: ArgumentList |
| leftParenthesis: ( @53 |
| rightParenthesis: ) @54 |
| staticElement: self::@class::C::@constructor::named |
| redirectedConstructor: self::@class::C::@constructor::named |
| '''); |
| } |
| |
| test_class_constructor_redirected_thisInvocation_named_generic() async { |
| var library = await checkLibrary(''' |
| class C<T> { |
| const C.named(); |
| const C() : this.named(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| typeParameters |
| covariant T @8 |
| defaultType: dynamic |
| constructors |
| const named @23 |
| periodOffset: 22 |
| nameEnd: 28 |
| const @40 |
| constantInitializers |
| RedirectingConstructorInvocation |
| thisKeyword: this @46 |
| period: . @50 |
| constructorName: SimpleIdentifier |
| token: named @51 |
| staticElement: self::@class::C::@constructor::named |
| staticType: null |
| argumentList: ArgumentList |
| leftParenthesis: ( @56 |
| rightParenthesis: ) @57 |
| staticElement: self::@class::C::@constructor::named |
| redirectedConstructor: self::@class::C::@constructor::named |
| '''); |
| } |
| |
| test_class_constructor_redirected_thisInvocation_named_notConst() async { |
| var library = await checkLibrary(''' |
| class C { |
| C.named(); |
| C() : this.named(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| named @14 |
| periodOffset: 13 |
| nameEnd: 19 |
| @25 |
| redirectedConstructor: self::@class::C::@constructor::named |
| '''); |
| } |
| |
| test_class_constructor_redirected_thisInvocation_unnamed() async { |
| var library = await checkLibrary(''' |
| class C { |
| const C(); |
| const C.named() : this(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| const @18 |
| const named @33 |
| periodOffset: 32 |
| nameEnd: 38 |
| constantInitializers |
| RedirectingConstructorInvocation |
| thisKeyword: this @43 |
| argumentList: ArgumentList |
| leftParenthesis: ( @47 |
| rightParenthesis: ) @48 |
| staticElement: self::@class::C::@constructor::• |
| redirectedConstructor: self::@class::C::@constructor::• |
| '''); |
| } |
| |
| test_class_constructor_redirected_thisInvocation_unnamed_generic() async { |
| var library = await checkLibrary(''' |
| class C<T> { |
| const C(); |
| const C.named() : this(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| typeParameters |
| covariant T @8 |
| defaultType: dynamic |
| constructors |
| const @21 |
| const named @36 |
| periodOffset: 35 |
| nameEnd: 41 |
| constantInitializers |
| RedirectingConstructorInvocation |
| thisKeyword: this @46 |
| argumentList: ArgumentList |
| leftParenthesis: ( @50 |
| rightParenthesis: ) @51 |
| staticElement: self::@class::C::@constructor::• |
| redirectedConstructor: self::@class::C::@constructor::• |
| '''); |
| } |
| |
| test_class_constructor_redirected_thisInvocation_unnamed_notConst() async { |
| var library = await checkLibrary(''' |
| class C { |
| C(); |
| C.named() : this(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| @12 |
| named @21 |
| periodOffset: 20 |
| nameEnd: 26 |
| redirectedConstructor: self::@class::C::@constructor::• |
| '''); |
| } |
| |
| test_class_constructor_superConstructor_generic_named() async { |
| var library = await checkLibrary(''' |
| class A<T> { |
| A.named(T a); |
| } |
| class B extends A<int> { |
| B() : super.named(0); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class A @6 |
| typeParameters |
| covariant T @8 |
| defaultType: dynamic |
| constructors |
| named @17 |
| periodOffset: 16 |
| nameEnd: 22 |
| parameters |
| requiredPositional a @25 |
| type: T |
| class B @37 |
| supertype: A<int> |
| constructors |
| @58 |
| superConstructor: ConstructorMember |
| base: self::@class::A::@constructor::named |
| substitution: {T: int} |
| '''); |
| } |
| |
| test_class_constructor_superConstructor_notGeneric_named() async { |
| var library = await checkLibrary(''' |
| class A { |
| A.named(); |
| } |
| class B extends A { |
| B() : super.named(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class A @6 |
| constructors |
| named @14 |
| periodOffset: 13 |
| nameEnd: 19 |
| class B @31 |
| supertype: A |
| constructors |
| @47 |
| superConstructor: self::@class::A::@constructor::named |
| '''); |
| } |
| |
| test_class_constructor_superConstructor_notGeneric_unnamed_explicit() async { |
| var library = await checkLibrary(''' |
| class A {} |
| class B extends A { |
| B() : super(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class A @6 |
| constructors |
| synthetic @-1 |
| class B @17 |
| supertype: A |
| constructors |
| @33 |
| superConstructor: self::@class::A::@constructor::• |
| '''); |
| } |
| |
| test_class_constructor_superConstructor_notGeneric_unnamed_implicit() async { |
| var library = await checkLibrary(''' |
| class A {} |
| class B extends A { |
| B(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class A @6 |
| constructors |
| synthetic @-1 |
| class B @17 |
| supertype: A |
| constructors |
| @33 |
| superConstructor: self::@class::A::@constructor::• |
| '''); |
| } |
| |
| test_class_constructor_superConstructor_notGeneric_unnamed_implicit2() async { |
| var library = await checkLibrary(''' |
| class A {} |
| class B extends A {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class A @6 |
| constructors |
| synthetic @-1 |
| class B @17 |
| supertype: A |
| constructors |
| synthetic @-1 |
| superConstructor: self::@class::A::@constructor::• |
| '''); |
| } |
| |
| test_class_constructor_unnamed_implicit() async { |
| var library = await checkLibrary('class C {}'); |
| checkElementText( |
| library, |
| r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| synthetic @-1 |
| displayName: C |
| ''', |
| withDisplayName: true); |
| } |
| |
| test_class_constructor_withCycles_const() async { |
| var library = await checkLibrary(''' |
| class C { |
| final x; |
| const C() : x = const D(); |
| } |
| class D { |
| final x; |
| const D() : x = const C(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| final x @18 |
| type: dynamic |
| constructors |
| const @29 |
| constantInitializers |
| ConstructorFieldInitializer |
| fieldName: SimpleIdentifier |
| token: x @35 |
| staticElement: self::@class::C::@field::x |
| staticType: null |
| equals: = @37 |
| expression: InstanceCreationExpression |
| keyword: const @39 |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: D @45 |
| staticElement: self::@class::D |
| staticType: null |
| type: D |
| staticElement: self::@class::D::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @46 |
| rightParenthesis: ) @47 |
| staticType: D |
| accessors |
| synthetic get x @-1 |
| returnType: dynamic |
| class D @58 |
| fields |
| final x @70 |
| type: dynamic |
| constructors |
| const @81 |
| constantInitializers |
| ConstructorFieldInitializer |
| fieldName: SimpleIdentifier |
| token: x @87 |
| staticElement: self::@class::D::@field::x |
| staticType: null |
| equals: = @89 |
| expression: InstanceCreationExpression |
| keyword: const @91 |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: C @97 |
| staticElement: self::@class::C |
| staticType: null |
| type: C |
| staticElement: self::@class::C::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @98 |
| rightParenthesis: ) @99 |
| staticType: C |
| accessors |
| synthetic get x @-1 |
| returnType: dynamic |
| '''); |
| } |
| |
| test_class_constructor_withCycles_nonConst() async { |
| var library = await checkLibrary(''' |
| class C { |
| final x; |
| C() : x = new D(); |
| } |
| class D { |
| final x; |
| D() : x = new C(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| final x @18 |
| type: dynamic |
| constructors |
| @23 |
| accessors |
| synthetic get x @-1 |
| returnType: dynamic |
| class D @50 |
| fields |
| final x @62 |
| type: dynamic |
| constructors |
| @67 |
| accessors |
| synthetic get x @-1 |
| returnType: dynamic |
| '''); |
| } |
| |
| test_class_constructors_named() async { |
| var library = await checkLibrary(''' |
| class C { |
| C.foo(); |
| } |
| '''); |
| checkElementText( |
| library, |
| r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| foo @14 |
| displayName: C.foo |
| periodOffset: 13 |
| nameEnd: 17 |
| ''', |
| withDisplayName: true); |
| } |
| |
| test_class_constructors_unnamed() async { |
| var library = await checkLibrary(''' |
| class C { |
| C(); |
| } |
| '''); |
| checkElementText( |
| library, |
| r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| @12 |
| displayName: C |
| ''', |
| withDisplayName: true); |
| } |
| |
| test_class_constructors_unnamed_new() async { |
| var library = await checkLibrary(''' |
| class C { |
| C.new(); |
| } |
| '''); |
| checkElementText( |
| library, |
| r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| @14 |
| displayName: C |
| periodOffset: 13 |
| nameEnd: 17 |
| ''', |
| withDisplayName: true); |
| } |
| |
| test_class_documented() async { |
| var library = await checkLibrary(''' |
| /** |
| * Docs |
| */ |
| class C {}'''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @22 |
| documentationComment: /**\n * Docs\n */ |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_documented_mix() async { |
| var library = await checkLibrary(''' |
| /** |
| * aaa |
| */ |
| /** |
| * bbb |
| */ |
| class A {} |
| |
| /** |
| * aaa |
| */ |
| /// bbb |
| /// ccc |
| class B {} |
| |
| /// aaa |
| /// bbb |
| /** |
| * ccc |
| */ |
| class C {} |
| |
| /// aaa |
| /// bbb |
| /** |
| * ccc |
| */ |
| /// ddd |
| class D {} |
| |
| /** |
| * aaa |
| */ |
| // bbb |
| class E {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class A @36 |
| documentationComment: /**\n * bbb\n */ |
| constructors |
| synthetic @-1 |
| class B @79 |
| documentationComment: /// bbb\n/// ccc |
| constructors |
| synthetic @-1 |
| class C @122 |
| documentationComment: /**\n * ccc\n */ |
| constructors |
| synthetic @-1 |
| class D @173 |
| documentationComment: /// ddd |
| constructors |
| synthetic @-1 |
| class E @207 |
| documentationComment: /**\n * aaa\n */ |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_documented_tripleSlash() async { |
| var library = await checkLibrary(''' |
| /// first |
| /// second |
| /// third |
| class C {}'''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @37 |
| documentationComment: /// first\n/// second\n/// third |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_documented_with_references() async { |
| var library = await checkLibrary(''' |
| /** |
| * Docs referring to [D] and [E] |
| */ |
| class C {} |
| |
| class D {} |
| class E {}'''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @47 |
| documentationComment: /**\n * Docs referring to [D] and [E]\n */ |
| constructors |
| synthetic @-1 |
| class D @59 |
| constructors |
| synthetic @-1 |
| class E @70 |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_documented_with_windows_line_endings() async { |
| var library = await checkLibrary('/**\r\n * Docs\r\n */\r\nclass C {}'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @25 |
| documentationComment: /**\n * Docs\n */ |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_documented_withLeadingNotDocumentation() async { |
| var library = await checkLibrary(''' |
| // Extra comment so doc comment offset != 0 |
| /** |
| * Docs |
| */ |
| class C {}'''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @66 |
| documentationComment: /**\n * Docs\n */ |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_documented_withMetadata() async { |
| var library = await checkLibrary(''' |
| /// Comment 1 |
| /// Comment 2 |
| @Annotation() |
| class BeforeMeta {} |
| |
| /// Comment 1 |
| /// Comment 2 |
| @Annotation.named() |
| class BeforeMetaNamed {} |
| |
| @Annotation() |
| /// Comment 1 |
| /// Comment 2 |
| class AfterMeta {} |
| |
| /// Comment 1 |
| @Annotation() |
| /// Comment 2 |
| class AroundMeta {} |
| |
| /// Doc comment. |
| @Annotation() |
| // Not doc comment. |
| class DocBeforeMetaNotDocAfter {} |
| |
| class Annotation { |
| const Annotation(); |
| const Annotation.named(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class BeforeMeta @48 |
| documentationComment: /// Comment 1\n/// Comment 2 |
| metadata |
| Annotation |
| atSign: @ @28 |
| name: SimpleIdentifier |
| token: Annotation @29 |
| staticElement: self::@class::Annotation |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @39 |
| rightParenthesis: ) @40 |
| element: self::@class::Annotation::@constructor::• |
| constructors |
| synthetic @-1 |
| class BeforeMetaNamed @117 |
| documentationComment: /// Comment 1\n/// Comment 2 |
| metadata |
| Annotation |
| atSign: @ @91 |
| name: PrefixedIdentifier |
| prefix: SimpleIdentifier |
| token: Annotation @92 |
| staticElement: self::@class::Annotation |
| staticType: null |
| period: . @102 |
| identifier: SimpleIdentifier |
| token: named @103 |
| staticElement: self::@class::Annotation::@constructor::named |
| staticType: null |
| staticElement: self::@class::Annotation::@constructor::named |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @108 |
| rightParenthesis: ) @109 |
| element: self::@class::Annotation::@constructor::named |
| constructors |
| synthetic @-1 |
| class AfterMeta @185 |
| documentationComment: /// Comment 1\n/// Comment 2 |
| metadata |
| Annotation |
| atSign: @ @137 |
| name: SimpleIdentifier |
| token: Annotation @138 |
| staticElement: self::@class::Annotation |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @148 |
| rightParenthesis: ) @149 |
| element: self::@class::Annotation::@constructor::• |
| constructors |
| synthetic @-1 |
| class AroundMeta @247 |
| documentationComment: /// Comment 2 |
| metadata |
| Annotation |
| atSign: @ @213 |
| name: SimpleIdentifier |
| token: Annotation @214 |
| staticElement: self::@class::Annotation |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @224 |
| rightParenthesis: ) @225 |
| element: self::@class::Annotation::@constructor::• |
| constructors |
| synthetic @-1 |
| class DocBeforeMetaNotDocAfter @319 |
| documentationComment: /// Doc comment. |
| metadata |
| Annotation |
| atSign: @ @279 |
| name: SimpleIdentifier |
| token: Annotation @280 |
| staticElement: self::@class::Annotation |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @290 |
| rightParenthesis: ) @291 |
| element: self::@class::Annotation::@constructor::• |
| constructors |
| synthetic @-1 |
| class Annotation @354 |
| constructors |
| const @375 |
| const named @408 |
| periodOffset: 407 |
| nameEnd: 413 |
| '''); |
| } |
| |
| test_class_field_abstract() async { |
| var library = await checkLibrary(''' |
| abstract class C { |
| abstract int i; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| abstract class C @15 |
| fields |
| abstract i @34 |
| type: int |
| constructors |
| synthetic @-1 |
| accessors |
| synthetic abstract get i @-1 |
| returnType: int |
| synthetic abstract set i @-1 |
| parameters |
| requiredPositional _i @-1 |
| type: int |
| returnType: void |
| '''); |
| } |
| |
| test_class_field_const() async { |
| var library = await checkLibrary('class C { static const int i = 0; }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| static const i @27 |
| type: int |
| constantInitializer |
| IntegerLiteral |
| literal: 0 @31 |
| staticType: int |
| constructors |
| synthetic @-1 |
| accessors |
| synthetic static get i @-1 |
| returnType: int |
| '''); |
| } |
| |
| test_class_field_const_late() async { |
| var library = |
| await checkLibrary('class C { static late const int i = 0; }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| static late const i @32 |
| type: int |
| constantInitializer |
| IntegerLiteral |
| literal: 0 @36 |
| staticType: int |
| constructors |
| synthetic @-1 |
| accessors |
| synthetic static get i @-1 |
| returnType: int |
| '''); |
| } |
| |
| test_class_field_covariant() async { |
| var library = await checkLibrary(''' |
| class C { |
| covariant int x; |
| }'''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| covariant x @26 |
| type: int |
| constructors |
| synthetic @-1 |
| accessors |
| synthetic get x @-1 |
| returnType: int |
| synthetic set x @-1 |
| parameters |
| requiredPositional covariant _x @-1 |
| type: int |
| returnType: void |
| '''); |
| } |
| |
| test_class_field_documented() async { |
| var library = await checkLibrary(''' |
| class C { |
| /** |
| * Docs |
| */ |
| var x; |
| }'''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| x @38 |
| documentationComment: /**\n * Docs\n */ |
| type: dynamic |
| constructors |
| synthetic @-1 |
| accessors |
| synthetic get x @-1 |
| returnType: dynamic |
| synthetic set x @-1 |
| parameters |
| requiredPositional _x @-1 |
| type: dynamic |
| returnType: void |
| '''); |
| } |
| |
| test_class_field_external() async { |
| var library = await checkLibrary(''' |
| abstract class C { |
| external int i; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| abstract class C @15 |
| fields |
| external i @34 |
| type: int |
| constructors |
| synthetic @-1 |
| accessors |
| synthetic get i @-1 |
| returnType: int |
| synthetic set i @-1 |
| parameters |
| requiredPositional _i @-1 |
| type: int |
| returnType: void |
| '''); |
| } |
| |
| test_class_field_final_hasInitializer_hasConstConstructor() async { |
| var library = await checkLibrary(''' |
| class C { |
| final x = 42; |
| const C(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| final x @18 |
| type: int |
| constantInitializer |
| IntegerLiteral |
| literal: 42 @22 |
| staticType: int |
| constructors |
| const @34 |
| accessors |
| synthetic get x @-1 |
| returnType: int |
| '''); |
| } |
| |
| test_class_field_final_hasInitializer_hasConstConstructor_genericFunctionType() async { |
| var library = await checkLibrary(''' |
| class A<T> { |
| const A(); |
| } |
| class B { |
| final f = const A<int Function(double a)>(); |
| const B(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class A @6 |
| typeParameters |
| covariant T @8 |
| defaultType: dynamic |
| constructors |
| const @21 |
| class B @34 |
| fields |
| final f @46 |
| type: A<int Function(double)> |
| constantInitializer |
| InstanceCreationExpression |
| keyword: const @50 |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: A @56 |
| staticElement: self::@class::A |
| staticType: null |
| typeArguments: TypeArgumentList |
| leftBracket: < @57 |
| arguments |
| GenericFunctionType |
| returnType: NamedType |
| name: SimpleIdentifier |
| token: int @58 |
| staticElement: dart:core::@class::int |
| staticType: null |
| type: int |
| functionKeyword: Function @62 |
| parameters: FormalParameterList |
| leftParenthesis: ( @70 |
| parameter: SimpleFormalParameter |
| type: NamedType |
| name: SimpleIdentifier |
| token: double @71 |
| staticElement: dart:core::@class::double |
| staticType: null |
| type: double |
| identifier: SimpleIdentifier |
| token: a @78 |
| staticElement: a@78 |
| staticType: null |
| declaredElement: a@78 |
| declaredElementType: double |
| rightParenthesis: ) @79 |
| declaredElement: GenericFunctionTypeElement |
| parameters |
| a |
| kind: required positional |
| type: double |
| returnType: int |
| type: int Function(double) |
| type: int Function(double) |
| rightBracket: > @80 |
| type: A<int Function(double)> |
| staticElement: ConstructorMember |
| base: self::@class::A::@constructor::• |
| substitution: {T: int Function(double)} |
| argumentList: ArgumentList |
| leftParenthesis: ( @81 |
| rightParenthesis: ) @82 |
| staticType: A<int Function(double)> |
| constructors |
| const @93 |
| accessors |
| synthetic get f @-1 |
| returnType: A<int Function(double)> |
| '''); |
| } |
| |
| test_class_field_final_hasInitializer_noConstConstructor() async { |
| var library = await checkLibrary(''' |
| class C { |
| final x = 42; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| final x @18 |
| type: int |
| constructors |
| synthetic @-1 |
| accessors |
| synthetic get x @-1 |
| returnType: int |
| '''); |
| } |
| |
| test_class_field_final_withSetter() async { |
| var library = await checkLibrary(r''' |
| class A { |
| final int foo; |
| A(this.foo); |
| set foo(int newValue) {} |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class A @6 |
| fields |
| final foo @22 |
| type: int |
| constructors |
| @29 |
| parameters |
| requiredPositional final this.foo @36 |
| type: int |
| field: self::@class::A::@field::foo |
| accessors |
| synthetic get foo @-1 |
| returnType: int |
| set foo @48 |
| parameters |
| requiredPositional newValue @56 |
| type: int |
| returnType: void |
| '''); |
| } |
| |
| test_class_field_formal_param_inferred_type_implicit() async { |
| var library = await checkLibrary('class C extends D { var v; C(this.v); }' |
| ' abstract class D { int get v; }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| supertype: D |
| fields |
| v @24 |
| type: int |
| constructors |
| @27 |
| parameters |
| requiredPositional final this.v @34 |
| type: int |
| field: self::@class::C::@field::v |
| superConstructor: self::@class::D::@constructor::• |
| accessors |
| synthetic get v @-1 |
| returnType: int |
| synthetic set v @-1 |
| parameters |
| requiredPositional _v @-1 |
| type: int |
| returnType: void |
| abstract class D @55 |
| fields |
| synthetic v @-1 |
| type: int |
| constructors |
| synthetic @-1 |
| accessors |
| abstract get v @67 |
| returnType: int |
| '''); |
| } |
| |
| test_class_field_implicit_type() async { |
| var library = await checkLibrary('class C { var x; }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| x @14 |
| type: dynamic |
| constructors |
| synthetic @-1 |
| accessors |
| synthetic get x @-1 |
| returnType: dynamic |
| synthetic set x @-1 |
| parameters |
| requiredPositional _x @-1 |
| type: dynamic |
| returnType: void |
| '''); |
| } |
| |
| test_class_field_implicit_type_late() async { |
| var library = await checkLibrary('class C { late var x; }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| late x @19 |
| type: dynamic |
| constructors |
| synthetic @-1 |
| accessors |
| synthetic get x @-1 |
| returnType: dynamic |
| synthetic set x @-1 |
| parameters |
| requiredPositional _x @-1 |
| type: dynamic |
| returnType: void |
| '''); |
| } |
| |
| test_class_field_inferred_type_nonStatic_explicit_initialized() async { |
| var library = await checkLibrary('class C { num v = 0; }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| v @14 |
| type: num |
| constructors |
| synthetic @-1 |
| accessors |
| synthetic get v @-1 |
| returnType: num |
| synthetic set v @-1 |
| parameters |
| requiredPositional _v @-1 |
| type: num |
| returnType: void |
| '''); |
| } |
| |
| test_class_field_inferred_type_nonStatic_implicit_initialized() async { |
| var library = await checkLibrary('class C { var v = 0; }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| v @14 |
| type: int |
| constructors |
| synthetic @-1 |
| accessors |
| synthetic get v @-1 |
| returnType: int |
| synthetic set v @-1 |
| parameters |
| requiredPositional _v @-1 |
| type: int |
| returnType: void |
| '''); |
| } |
| |
| test_class_field_inferred_type_nonStatic_implicit_uninitialized() async { |
| var library = await checkLibrary( |
| 'class C extends D { var v; } abstract class D { int get v; }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| supertype: D |
| fields |
| v @24 |
| type: int |
| constructors |
| synthetic @-1 |
| superConstructor: self::@class::D::@constructor::• |
| accessors |
| synthetic get v @-1 |
| returnType: int |
| synthetic set v @-1 |
| parameters |
| requiredPositional _v @-1 |
| type: int |
| returnType: void |
| abstract class D @44 |
| fields |
| synthetic v @-1 |
| type: int |
| constructors |
| synthetic @-1 |
| accessors |
| abstract get v @56 |
| returnType: int |
| '''); |
| } |
| |
| test_class_field_inferred_type_nonStatic_inherited_resolveInitializer() async { |
| var library = await checkLibrary(r''' |
| const a = 0; |
| abstract class A { |
| const A(); |
| List<int> get f; |
| } |
| class B extends A { |
| const B(); |
| final f = [a]; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| abstract class A @28 |
| fields |
| synthetic f @-1 |
| type: List<int> |
| constructors |
| const @40 |
| accessors |
| abstract get f @61 |
| returnType: List<int> |
| class B @72 |
| supertype: A |
| fields |
| final f @107 |
| type: List<int> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @111 |
| elements |
| SimpleIdentifier |
| token: a @112 |
| staticElement: self::@getter::a |
| staticType: int |
| rightBracket: ] @113 |
| staticType: List<int> |
| constructors |
| const @94 |
| superConstructor: self::@class::A::@constructor::• |
| accessors |
| synthetic get f @-1 |
| returnType: List<int> |
| topLevelVariables |
| static const a @6 |
| type: int |
| constantInitializer |
| IntegerLiteral |
| literal: 0 @10 |
| staticType: int |
| accessors |
| synthetic static get a @-1 |
| returnType: int |
| '''); |
| } |
| |
| test_class_field_inferred_type_static_implicit_initialized() async { |
| var library = await checkLibrary('class C { static var v = 0; }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| static v @21 |
| type: int |
| constructors |
| synthetic @-1 |
| accessors |
| synthetic static get v @-1 |
| returnType: int |
| synthetic static set v @-1 |
| parameters |
| requiredPositional _v @-1 |
| type: int |
| returnType: void |
| '''); |
| } |
| |
| test_class_field_inheritedContextType_double() async { |
| var library = await checkLibrary(''' |
| abstract class A { |
| const A(); |
| double get foo; |
| } |
| class B extends A { |
| const B(); |
| final foo = 2; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| abstract class A @15 |
| fields |
| synthetic foo @-1 |
| type: double |
| constructors |
| const @27 |
| accessors |
| abstract get foo @45 |
| returnType: double |
| class B @58 |
| supertype: A |
| fields |
| final foo @93 |
| type: double |
| constantInitializer |
| IntegerLiteral |
| literal: 2 @99 |
| staticType: double |
| constructors |
| const @80 |
| superConstructor: self::@class::A::@constructor::• |
| accessors |
| synthetic get foo @-1 |
| returnType: double |
| '''); |
| } |
| |
| test_class_field_propagatedType_const_noDep() async { |
| var library = await checkLibrary(''' |
| class C { |
| static const x = 0; |
| }'''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| static const x @25 |
| type: int |
| constantInitializer |
| IntegerLiteral |
| literal: 0 @29 |
| staticType: int |
| constructors |
| synthetic @-1 |
| accessors |
| synthetic static get x @-1 |
| returnType: int |
| '''); |
| } |
| |
| test_class_field_propagatedType_final_dep_inLib() async { |
| addLibrarySource('/a.dart', 'final a = 1;'); |
| var library = await checkLibrary(''' |
| import "a.dart"; |
| class C { |
| final b = a / 2; |
| }'''); |
| checkElementText(library, r''' |
| library |
| imports |
| a.dart |
| definingUnit |
| classes |
| class C @23 |
| fields |
| final b @35 |
| type: double |
| constructors |
| synthetic @-1 |
| accessors |
| synthetic get b @-1 |
| returnType: double |
| '''); |
| } |
| |
| test_class_field_propagatedType_final_dep_inPart() async { |
| addSource('/a.dart', 'part of lib; final a = 1;'); |
| var library = await checkLibrary(''' |
| library lib; |
| part "a.dart"; |
| class C { |
| final b = a / 2; |
| }'''); |
| checkElementText(library, r''' |
| library |
| name: lib |
| nameOffset: 8 |
| definingUnit |
| classes |
| class C @34 |
| fields |
| final b @46 |
| type: double |
| constructors |
| synthetic @-1 |
| accessors |
| synthetic get b @-1 |
| returnType: double |
| parts |
| a.dart |
| topLevelVariables |
| static final a @19 |
| type: int |
| accessors |
| synthetic static get a @-1 |
| returnType: int |
| '''); |
| } |
| |
| test_class_field_propagatedType_final_noDep_instance() async { |
| var library = await checkLibrary(''' |
| class C { |
| final x = 0; |
| }'''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| final x @18 |
| type: int |
| constructors |
| synthetic @-1 |
| accessors |
| synthetic get x @-1 |
| returnType: int |
| '''); |
| } |
| |
| test_class_field_propagatedType_final_noDep_static() async { |
| var library = await checkLibrary(''' |
| class C { |
| static final x = 0; |
| }'''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| static final x @25 |
| type: int |
| constructors |
| synthetic @-1 |
| accessors |
| synthetic static get x @-1 |
| returnType: int |
| '''); |
| } |
| |
| test_class_field_static() async { |
| var library = await checkLibrary('class C { static int i; }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| static i @21 |
| type: int |
| constructors |
| synthetic @-1 |
| accessors |
| synthetic static get i @-1 |
| returnType: int |
| synthetic static set i @-1 |
| parameters |
| requiredPositional _i @-1 |
| type: int |
| returnType: void |
| '''); |
| } |
| |
| test_class_field_static_final_hasConstConstructor() async { |
| var library = await checkLibrary(''' |
| class C { |
| static final f = 0; |
| const C(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| static final f @25 |
| type: int |
| constructors |
| const @40 |
| accessors |
| synthetic static get f @-1 |
| returnType: int |
| '''); |
| } |
| |
| test_class_field_static_final_untyped() async { |
| var library = await checkLibrary('class C { static final x = 0; }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| static final x @23 |
| type: int |
| constructors |
| synthetic @-1 |
| accessors |
| synthetic static get x @-1 |
| returnType: int |
| '''); |
| } |
| |
| test_class_field_static_late() async { |
| var library = await checkLibrary('class C { static late int i; }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| static late i @26 |
| type: int |
| constructors |
| synthetic @-1 |
| accessors |
| synthetic static get i @-1 |
| returnType: int |
| synthetic static set i @-1 |
| parameters |
| requiredPositional _i @-1 |
| type: int |
| returnType: void |
| '''); |
| } |
| |
| test_class_field_type_inferred_Never() async { |
| var library = await checkLibrary(r''' |
| class C { |
| var a = throw 42; |
| } |
| '''); |
| |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| a @16 |
| type: Never |
| constructors |
| synthetic @-1 |
| accessors |
| synthetic get a @-1 |
| returnType: Never |
| synthetic set a @-1 |
| parameters |
| requiredPositional _a @-1 |
| type: Never |
| returnType: void |
| '''); |
| } |
| |
| test_class_field_type_inferred_nonNullify() async { |
| addSource('/a.dart', ''' |
| // @dart = 2.7 |
| var a = 0; |
| '''); |
| |
| var library = await checkLibrary(r''' |
| import 'a.dart'; |
| class C { |
| var b = a; |
| } |
| '''); |
| |
| checkElementText(library, r''' |
| library |
| imports |
| a.dart |
| definingUnit |
| classes |
| class C @23 |
| fields |
| b @33 |
| type: int |
| constructors |
| synthetic @-1 |
| accessors |
| synthetic get b @-1 |
| returnType: int |
| synthetic set b @-1 |
| parameters |
| requiredPositional _b @-1 |
| type: int |
| returnType: void |
| '''); |
| } |
| |
| test_class_field_typed() async { |
| var library = await checkLibrary('class C { int x = 0; }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| x @14 |
| type: int |
| constructors |
| synthetic @-1 |
| accessors |
| synthetic get x @-1 |
| returnType: int |
| synthetic set x @-1 |
| parameters |
| requiredPositional _x @-1 |
| type: int |
| returnType: void |
| '''); |
| } |
| |
| test_class_field_untyped() async { |
| var library = await checkLibrary('class C { var x = 0; }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| x @14 |
| type: int |
| constructors |
| synthetic @-1 |
| accessors |
| synthetic get x @-1 |
| returnType: int |
| synthetic set x @-1 |
| parameters |
| requiredPositional _x @-1 |
| type: int |
| returnType: void |
| '''); |
| } |
| |
| test_class_fields() async { |
| var library = await checkLibrary('class C { int i; int j; }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| i @14 |
| type: int |
| j @21 |
| type: int |
| constructors |
| synthetic @-1 |
| accessors |
| synthetic get i @-1 |
| returnType: int |
| synthetic set i @-1 |
| parameters |
| requiredPositional _i @-1 |
| type: int |
| returnType: void |
| synthetic get j @-1 |
| returnType: int |
| synthetic set j @-1 |
| parameters |
| requiredPositional _j @-1 |
| type: int |
| returnType: void |
| '''); |
| } |
| |
| test_class_fields_late() async { |
| var library = await checkLibrary(''' |
| class C { |
| late int foo; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| late foo @21 |
| type: int |
| constructors |
| synthetic @-1 |
| accessors |
| synthetic get foo @-1 |
| returnType: int |
| synthetic set foo @-1 |
| parameters |
| requiredPositional _foo @-1 |
| type: int |
| returnType: void |
| '''); |
| } |
| |
| test_class_fields_late_final() async { |
| var library = await checkLibrary(''' |
| class C { |
| late final int foo; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| late final foo @27 |
| type: int |
| constructors |
| synthetic @-1 |
| accessors |
| synthetic get foo @-1 |
| returnType: int |
| synthetic set foo @-1 |
| parameters |
| requiredPositional _foo @-1 |
| type: int |
| returnType: void |
| '''); |
| } |
| |
| test_class_fields_late_final_initialized() async { |
| var library = await checkLibrary(''' |
| class C { |
| late final int foo = 0; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| late final foo @27 |
| type: int |
| constructors |
| synthetic @-1 |
| accessors |
| synthetic get foo @-1 |
| returnType: int |
| '''); |
| } |
| |
| test_class_fields_late_inference_usingSuper_methodInvocation() async { |
| var library = await checkLibrary(''' |
| class A { |
| int foo() => 0; |
| } |
| |
| class B extends A { |
| late var f = super.foo(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class A @6 |
| constructors |
| synthetic @-1 |
| methods |
| foo @16 |
| returnType: int |
| class B @37 |
| supertype: A |
| fields |
| late f @62 |
| type: int |
| constructors |
| synthetic @-1 |
| superConstructor: self::@class::A::@constructor::• |
| accessors |
| synthetic get f @-1 |
| returnType: int |
| synthetic set f @-1 |
| parameters |
| requiredPositional _f @-1 |
| type: int |
| returnType: void |
| '''); |
| } |
| |
| test_class_fields_late_inference_usingSuper_propertyAccess() async { |
| var library = await checkLibrary(''' |
| class A { |
| int get foo => 0; |
| } |
| |
| class B extends A { |
| late var f = super.foo; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class A @6 |
| fields |
| synthetic foo @-1 |
| type: int |
| constructors |
| synthetic @-1 |
| accessors |
| get foo @20 |
| returnType: int |
| class B @39 |
| supertype: A |
| fields |
| late f @64 |
| type: int |
| constructors |
| synthetic @-1 |
| superConstructor: self::@class::A::@constructor::• |
| accessors |
| synthetic get f @-1 |
| returnType: int |
| synthetic set f @-1 |
| parameters |
| requiredPositional _f @-1 |
| type: int |
| returnType: void |
| '''); |
| } |
| |
| test_class_getter_abstract() async { |
| var library = await checkLibrary('abstract class C { int get x; }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| abstract class C @15 |
| fields |
| synthetic x @-1 |
| type: int |
| constructors |
| synthetic @-1 |
| accessors |
| abstract get x @27 |
| returnType: int |
| '''); |
| } |
| |
| test_class_getter_external() async { |
| var library = await checkLibrary('class C { external int get x; }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| synthetic x @-1 |
| type: int |
| constructors |
| synthetic @-1 |
| accessors |
| external get x @27 |
| returnType: int |
| '''); |
| } |
| |
| test_class_getter_implicit_return_type() async { |
| var library = await checkLibrary('class C { get x => null; }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| synthetic x @-1 |
| type: dynamic |
| constructors |
| synthetic @-1 |
| accessors |
| get x @14 |
| returnType: dynamic |
| '''); |
| } |
| |
| test_class_getter_native() async { |
| var library = await checkLibrary(''' |
| class C { |
| int get x() native; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| synthetic x @-1 |
| type: int |
| constructors |
| synthetic @-1 |
| accessors |
| external get x @20 |
| returnType: int |
| '''); |
| } |
| |
| test_class_getter_static() async { |
| var library = await checkLibrary('class C { static int get x => null; }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| synthetic static x @-1 |
| type: int |
| constructors |
| synthetic @-1 |
| accessors |
| static get x @25 |
| returnType: int |
| '''); |
| } |
| |
| test_class_getters() async { |
| var library = |
| await checkLibrary('class C { int get x => null; get y => null; }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| synthetic x @-1 |
| type: int |
| synthetic y @-1 |
| type: dynamic |
| constructors |
| synthetic @-1 |
| accessors |
| get x @18 |
| returnType: int |
| get y @33 |
| returnType: dynamic |
| '''); |
| } |
| |
| test_class_implicitField_getterFirst() async { |
| var library = await checkLibrary(''' |
| class C { |
| int get x => 0; |
| void set x(int value) {} |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| synthetic x @-1 |
| type: int |
| constructors |
| synthetic @-1 |
| accessors |
| get x @20 |
| returnType: int |
| set x @39 |
| parameters |
| requiredPositional value @45 |
| type: int |
| returnType: void |
| '''); |
| } |
| |
| test_class_implicitField_setterFirst() async { |
| var library = await checkLibrary(''' |
| class C { |
| void set x(int value) {} |
| int get x => 0; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| synthetic x @-1 |
| type: int |
| constructors |
| synthetic @-1 |
| accessors |
| set x @21 |
| parameters |
| requiredPositional value @27 |
| type: int |
| returnType: void |
| get x @47 |
| returnType: int |
| '''); |
| } |
| |
| test_class_interfaces() async { |
| var library = await checkLibrary(''' |
| class C implements D, E {} |
| class D {} |
| class E {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| interfaces |
| D |
| E |
| constructors |
| synthetic @-1 |
| class D @33 |
| constructors |
| synthetic @-1 |
| class E @44 |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_interfaces_Function() async { |
| var library = await checkLibrary(''' |
| class A {} |
| class B {} |
| class C implements A, Function, B {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class A @6 |
| constructors |
| synthetic @-1 |
| class B @17 |
| constructors |
| synthetic @-1 |
| class C @28 |
| interfaces |
| A |
| B |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_interfaces_unresolved() async { |
| var library = await checkLibrary( |
| 'class C implements X, Y, Z {} class X {} class Z {}', |
| allowErrors: true); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| interfaces |
| X |
| Z |
| constructors |
| synthetic @-1 |
| class X @36 |
| constructors |
| synthetic @-1 |
| class Z @47 |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_method_abstract() async { |
| var library = await checkLibrary('abstract class C { f(); }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| abstract class C @15 |
| constructors |
| synthetic @-1 |
| methods |
| abstract f @19 |
| returnType: dynamic |
| '''); |
| } |
| |
| test_class_method_async() async { |
| var library = await checkLibrary(r''' |
| import 'dart:async'; |
| class C { |
| Future f() async {} |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| imports |
| dart:async |
| definingUnit |
| classes |
| class C @27 |
| constructors |
| synthetic @-1 |
| methods |
| f @40 async |
| returnType: Future<dynamic> |
| '''); |
| } |
| |
| test_class_method_asyncStar() async { |
| var library = await checkLibrary(r''' |
| import 'dart:async'; |
| class C { |
| Stream f() async* {} |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| imports |
| dart:async |
| definingUnit |
| classes |
| class C @27 |
| constructors |
| synthetic @-1 |
| methods |
| f @40 async* |
| returnType: Stream<dynamic> |
| '''); |
| } |
| |
| test_class_method_documented() async { |
| var library = await checkLibrary(''' |
| class C { |
| /** |
| * Docs |
| */ |
| f() {} |
| }'''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| synthetic @-1 |
| methods |
| f @34 |
| documentationComment: /**\n * Docs\n */ |
| returnType: dynamic |
| '''); |
| } |
| |
| test_class_method_external() async { |
| var library = await checkLibrary('class C { external f(); }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| synthetic @-1 |
| methods |
| external f @19 |
| returnType: dynamic |
| '''); |
| } |
| |
| test_class_method_hasImplicitReturnType_false() async { |
| var library = await checkLibrary(''' |
| class C { |
| int m() => 0; |
| } |
| '''); |
| var c = library.definingCompilationUnit.classes.single; |
| var m = c.methods.single; |
| expect(m.hasImplicitReturnType, isFalse); |
| } |
| |
| test_class_method_hasImplicitReturnType_true() async { |
| var library = await checkLibrary(''' |
| class C { |
| m() => 0; |
| } |
| '''); |
| var c = library.definingCompilationUnit.classes.single; |
| var m = c.methods.single; |
| expect(m.hasImplicitReturnType, isTrue); |
| } |
| |
| test_class_method_inferred_type_nonStatic_implicit_param() async { |
| var library = await checkLibrary('class C extends D { void f(value) {} }' |
| ' abstract class D { void f(int value); }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| supertype: D |
| constructors |
| synthetic @-1 |
| superConstructor: self::@class::D::@constructor::• |
| methods |
| f @25 |
| parameters |
| requiredPositional value @27 |
| type: int |
| returnType: void |
| abstract class D @54 |
| constructors |
| synthetic @-1 |
| methods |
| abstract f @63 |
| parameters |
| requiredPositional value @69 |
| type: int |
| returnType: void |
| '''); |
| } |
| |
| test_class_method_inferred_type_nonStatic_implicit_return() async { |
| var library = await checkLibrary(''' |
| class C extends D { |
| f() => null; |
| } |
| abstract class D { |
| int f(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| supertype: D |
| constructors |
| synthetic @-1 |
| superConstructor: self::@class::D::@constructor::• |
| methods |
| f @22 |
| returnType: int |
| abstract class D @52 |
| constructors |
| synthetic @-1 |
| methods |
| abstract f @62 |
| returnType: int |
| '''); |
| } |
| |
| test_class_method_namedAsSupertype() async { |
| var library = await checkLibrary(r''' |
| class A {} |
| class B extends A { |
| void A() {} |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class A @6 |
| constructors |
| synthetic @-1 |
| class B @17 |
| supertype: A |
| constructors |
| synthetic @-1 |
| superConstructor: self::@class::A::@constructor::• |
| methods |
| A @38 |
| returnType: void |
| '''); |
| } |
| |
| test_class_method_native() async { |
| var library = await checkLibrary(''' |
| class C { |
| int m() native; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| synthetic @-1 |
| methods |
| external m @16 |
| returnType: int |
| '''); |
| } |
| |
| test_class_method_params() async { |
| var library = await checkLibrary('class C { f(x, y) {} }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| synthetic @-1 |
| methods |
| f @10 |
| parameters |
| requiredPositional x @12 |
| type: dynamic |
| requiredPositional y @15 |
| type: dynamic |
| returnType: dynamic |
| '''); |
| } |
| |
| test_class_method_static() async { |
| var library = await checkLibrary('class C { static f() {} }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| synthetic @-1 |
| methods |
| static f @17 |
| returnType: dynamic |
| '''); |
| } |
| |
| test_class_method_syncStar() async { |
| var library = await checkLibrary(r''' |
| class C { |
| Iterable<int> f() sync* { |
| yield 42; |
| } |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| synthetic @-1 |
| methods |
| f @26 sync* |
| returnType: Iterable<int> |
| '''); |
| } |
| |
| test_class_method_type_parameter() async { |
| var library = await checkLibrary('class C { T f<T, U>(U u) => null; }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| synthetic @-1 |
| methods |
| f @12 |
| typeParameters |
| covariant T @14 |
| covariant U @17 |
| parameters |
| requiredPositional u @22 |
| type: U |
| returnType: T |
| '''); |
| } |
| |
| test_class_method_type_parameter_in_generic_class() async { |
| var library = await checkLibrary(''' |
| class C<T, U> { |
| V f<V, W>(T t, U u, W w) => null; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| typeParameters |
| covariant T @8 |
| defaultType: dynamic |
| covariant U @11 |
| defaultType: dynamic |
| constructors |
| synthetic @-1 |
| methods |
| f @20 |
| typeParameters |
| covariant V @22 |
| covariant W @25 |
| parameters |
| requiredPositional t @30 |
| type: T |
| requiredPositional u @35 |
| type: U |
| requiredPositional w @40 |
| type: W |
| returnType: V |
| '''); |
| } |
| |
| test_class_method_type_parameter_with_function_typed_parameter() async { |
| var library = await checkLibrary('class C { void f<T, U>(T x(U u)) {} }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| synthetic @-1 |
| methods |
| f @15 |
| typeParameters |
| covariant T @17 |
| covariant U @20 |
| parameters |
| requiredPositional x @25 |
| type: T Function(U) |
| parameters |
| requiredPositional u @29 |
| type: U |
| returnType: void |
| '''); |
| } |
| |
| test_class_methods() async { |
| var library = await checkLibrary('class C { f() {} g() {} }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| synthetic @-1 |
| methods |
| f @10 |
| returnType: dynamic |
| g @17 |
| returnType: dynamic |
| '''); |
| } |
| |
| test_class_mixins() async { |
| var library = await checkLibrary(''' |
| class C extends D with E, F, G {} |
| class D {} |
| class E {} |
| class F {} |
| class G {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| supertype: D |
| mixins |
| E |
| F |
| G |
| constructors |
| synthetic @-1 |
| superConstructor: self::@class::D::@constructor::• |
| class D @40 |
| constructors |
| synthetic @-1 |
| class E @51 |
| constructors |
| synthetic @-1 |
| class F @62 |
| constructors |
| synthetic @-1 |
| class G @73 |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_mixins_generic() async { |
| var library = await checkLibrary(''' |
| class Z extends A with B<int>, C<double> {} |
| class A {} |
| class B<B1> {} |
| class C<C1> {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class Z @6 |
| supertype: A |
| mixins |
| B<int> |
| C<double> |
| constructors |
| synthetic @-1 |
| superConstructor: self::@class::A::@constructor::• |
| class A @50 |
| constructors |
| synthetic @-1 |
| class B @61 |
| typeParameters |
| covariant B1 @63 |
| defaultType: dynamic |
| constructors |
| synthetic @-1 |
| class C @76 |
| typeParameters |
| covariant C1 @78 |
| defaultType: dynamic |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_mixins_unresolved() async { |
| var library = await checkLibrary( |
| 'class C extends Object with X, Y, Z {} class X {} class Z {}', |
| allowErrors: true); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| supertype: Object |
| mixins |
| X |
| Z |
| constructors |
| synthetic @-1 |
| class X @45 |
| constructors |
| synthetic @-1 |
| class Z @56 |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_notSimplyBounded_circularity_via_typedef() async { |
| // C's type parameter T is not simply bounded because its bound, F, expands |
| // to `dynamic F(C)`, which refers to C. |
| var library = await checkLibrary(''' |
| class C<T extends F> {} |
| typedef F(C value); |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| notSimplyBounded class C @6 |
| typeParameters |
| covariant T @8 |
| bound: dynamic |
| defaultType: dynamic |
| constructors |
| synthetic @-1 |
| typeAliases |
| functionTypeAliasBased notSimplyBounded F @32 |
| aliasedType: dynamic Function(C<dynamic>) |
| aliasedElement: GenericFunctionTypeElement |
| parameters |
| requiredPositional value @36 |
| type: C<dynamic> |
| returnType: dynamic |
| '''); |
| } |
| |
| test_class_notSimplyBounded_circularity_with_type_params() async { |
| // C's type parameter T is simply bounded because even though it refers to |
| // C, it specifies a bound. |
| var library = await checkLibrary(''' |
| class C<T extends C<dynamic>> {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| typeParameters |
| covariant T @8 |
| bound: C<dynamic> |
| defaultType: C<dynamic> |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_notSimplyBounded_complex_by_cycle_class() async { |
| var library = await checkLibrary(''' |
| class C<T extends D> {} |
| class D<T extends C> {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| notSimplyBounded class C @6 |
| typeParameters |
| covariant T @8 |
| bound: D<dynamic> |
| defaultType: dynamic |
| constructors |
| synthetic @-1 |
| notSimplyBounded class D @30 |
| typeParameters |
| covariant T @32 |
| bound: C<dynamic> |
| defaultType: dynamic |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_notSimplyBounded_complex_by_cycle_typedef_functionType() async { |
| var library = await checkLibrary(''' |
| typedef C<T extends D> = void Function(); |
| typedef D<T extends C> = void Function(); |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| typeAliases |
| notSimplyBounded C @8 |
| typeParameters |
| unrelated T @10 |
| bound: dynamic |
| defaultType: dynamic |
| aliasedType: void Function() |
| aliasedElement: GenericFunctionTypeElement |
| returnType: void |
| notSimplyBounded D @50 |
| typeParameters |
| unrelated T @52 |
| bound: dynamic |
| defaultType: dynamic |
| aliasedType: void Function() |
| aliasedElement: GenericFunctionTypeElement |
| returnType: void |
| '''); |
| } |
| |
| test_class_notSimplyBounded_complex_by_cycle_typedef_interfaceType() async { |
| var library = await checkLibrary(''' |
| typedef C<T extends D> = List<T>; |
| typedef D<T extends C> = List<T>; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| typeAliases |
| notSimplyBounded C @8 |
| typeParameters |
| covariant T @10 |
| bound: dynamic |
| defaultType: dynamic |
| aliasedType: List<T> |
| notSimplyBounded D @42 |
| typeParameters |
| covariant T @44 |
| bound: dynamic |
| defaultType: dynamic |
| aliasedType: List<T> |
| '''); |
| } |
| |
| test_class_notSimplyBounded_complex_by_reference_to_cycle() async { |
| var library = await checkLibrary(''' |
| class C<T extends D> {} |
| class D<T extends D> {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| notSimplyBounded class C @6 |
| typeParameters |
| covariant T @8 |
| bound: D<dynamic> |
| defaultType: D<dynamic> |
| constructors |
| synthetic @-1 |
| notSimplyBounded class D @30 |
| typeParameters |
| covariant T @32 |
| bound: D<dynamic> |
| defaultType: dynamic |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_notSimplyBounded_complex_by_use_of_parameter() async { |
| var library = await checkLibrary(''' |
| class C<T extends D<T>> {} |
| class D<T> {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| notSimplyBounded class C @6 |
| typeParameters |
| covariant T @8 |
| bound: D<T> |
| defaultType: D<dynamic> |
| constructors |
| synthetic @-1 |
| class D @33 |
| typeParameters |
| covariant T @35 |
| defaultType: dynamic |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_notSimplyBounded_dependency_with_type_params() async { |
| // C's type parameter T is simply bounded because even though it refers to |
| // non-simply-bounded type D, it specifies a bound. |
| var library = await checkLibrary(''' |
| class C<T extends D<dynamic>> {} |
| class D<T extends D<T>> {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| typeParameters |
| covariant T @8 |
| bound: D<dynamic> |
| defaultType: D<dynamic> |
| constructors |
| synthetic @-1 |
| notSimplyBounded class D @39 |
| typeParameters |
| covariant T @41 |
| bound: D<T> |
| defaultType: D<dynamic> |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_notSimplyBounded_function_typed_bound_complex_via_parameter_type() async { |
| var library = await checkLibrary(''' |
| class C<T extends void Function(T)> {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| notSimplyBounded class C @6 |
| typeParameters |
| covariant T @8 |
| bound: void Function(T) |
| defaultType: void Function(Never) |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_notSimplyBounded_function_typed_bound_complex_via_parameter_type_legacy() async { |
| featureSet = FeatureSets.language_2_9; |
| var library = await checkLibrary(''' |
| class C<T extends void Function(T)> {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| notSimplyBounded class C @6 |
| typeParameters |
| covariant T @8 |
| bound: void Function(T*)* |
| defaultType: void Function(Null*)* |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_notSimplyBounded_function_typed_bound_complex_via_return_type() async { |
| var library = await checkLibrary(''' |
| class C<T extends T Function()> {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| notSimplyBounded class C @6 |
| typeParameters |
| covariant T @8 |
| bound: T Function() |
| defaultType: dynamic Function() |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_notSimplyBounded_function_typed_bound_simple() async { |
| var library = await checkLibrary(''' |
| class C<T extends void Function()> {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| typeParameters |
| covariant T @8 |
| bound: void Function() |
| defaultType: void Function() |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_notSimplyBounded_refers_to_circular_typedef() async { |
| // C's type parameter T has a bound of F, which is a circular typedef. This |
| // is illegal in Dart, but we need to make sure it doesn't lead to a crash |
| // or infinite loop. |
| var library = await checkLibrary(''' |
| class C<T extends F> {} |
| typedef F(G value); |
| typedef G(F value); |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| notSimplyBounded class C @6 |
| typeParameters |
| covariant T @8 |
| bound: dynamic |
| defaultType: dynamic |
| constructors |
| synthetic @-1 |
| typeAliases |
| functionTypeAliasBased notSimplyBounded F @32 |
| aliasedType: dynamic Function(dynamic) |
| aliasedElement: GenericFunctionTypeElement |
| parameters |
| requiredPositional value @36 |
| type: dynamic |
| returnType: dynamic |
| functionTypeAliasBased notSimplyBounded G @52 |
| aliasedType: dynamic Function(dynamic) |
| aliasedElement: GenericFunctionTypeElement |
| parameters |
| requiredPositional value @56 |
| type: dynamic |
| returnType: dynamic |
| '''); |
| } |
| |
| test_class_notSimplyBounded_self() async { |
| var library = await checkLibrary(''' |
| class C<T extends C> {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| notSimplyBounded class C @6 |
| typeParameters |
| covariant T @8 |
| bound: C<dynamic> |
| defaultType: dynamic |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_notSimplyBounded_simple_because_non_generic() async { |
| // If no type parameters are specified, then the class is simply bounded, so |
| // there is no reason to assign it a slot. |
| var library = await checkLibrary(''' |
| class C {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_notSimplyBounded_simple_by_lack_of_cycles() async { |
| var library = await checkLibrary(''' |
| class C<T extends D> {} |
| class D<T> {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| typeParameters |
| covariant T @8 |
| bound: D<dynamic> |
| defaultType: D<dynamic> |
| constructors |
| synthetic @-1 |
| class D @30 |
| typeParameters |
| covariant T @32 |
| defaultType: dynamic |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_notSimplyBounded_simple_by_syntax() async { |
| // If no bounds are specified, then the class is simply bounded by syntax |
| // alone, so there is no reason to assign it a slot. |
| var library = await checkLibrary(''' |
| class C<T> {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| typeParameters |
| covariant T @8 |
| defaultType: dynamic |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_operator() async { |
| var library = |
| await checkLibrary('class C { C operator+(C other) => null; }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| synthetic @-1 |
| methods |
| + @20 |
| parameters |
| requiredPositional other @24 |
| type: C |
| returnType: C |
| '''); |
| } |
| |
| test_class_operator_equal() async { |
| var library = await checkLibrary(''' |
| class C { |
| bool operator==(Object other) => false; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| synthetic @-1 |
| methods |
| == @25 |
| parameters |
| requiredPositional other @35 |
| type: Object |
| returnType: bool |
| '''); |
| } |
| |
| test_class_operator_external() async { |
| var library = |
| await checkLibrary('class C { external C operator+(C other); }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| synthetic @-1 |
| methods |
| external + @29 |
| parameters |
| requiredPositional other @33 |
| type: C |
| returnType: C |
| '''); |
| } |
| |
| test_class_operator_greater_equal() async { |
| var library = await checkLibrary(''' |
| class C { |
| bool operator>=(C other) => false; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| synthetic @-1 |
| methods |
| >= @25 |
| parameters |
| requiredPositional other @30 |
| type: C |
| returnType: bool |
| '''); |
| } |
| |
| test_class_operator_index() async { |
| var library = |
| await checkLibrary('class C { bool operator[](int i) => null; }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| synthetic @-1 |
| methods |
| [] @23 |
| parameters |
| requiredPositional i @30 |
| type: int |
| returnType: bool |
| '''); |
| } |
| |
| test_class_operator_index_set() async { |
| var library = await checkLibrary(''' |
| class C { |
| void operator[]=(int i, bool v) {} |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| synthetic @-1 |
| methods |
| []= @25 |
| parameters |
| requiredPositional i @33 |
| type: int |
| requiredPositional v @41 |
| type: bool |
| returnType: void |
| '''); |
| } |
| |
| test_class_operator_less_equal() async { |
| var library = await checkLibrary(''' |
| class C { |
| bool operator<=(C other) => false; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| synthetic @-1 |
| methods |
| <= @25 |
| parameters |
| requiredPositional other @30 |
| type: C |
| returnType: bool |
| '''); |
| } |
| |
| test_class_ref_nullability_none() async { |
| var library = await checkLibrary(''' |
| class C {} |
| C c; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| synthetic @-1 |
| topLevelVariables |
| static c @13 |
| type: C |
| accessors |
| synthetic static get c @-1 |
| returnType: C |
| synthetic static set c @-1 |
| parameters |
| requiredPositional _c @-1 |
| type: C |
| returnType: void |
| '''); |
| } |
| |
| test_class_ref_nullability_question() async { |
| var library = await checkLibrary(''' |
| class C {} |
| C? c; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| synthetic @-1 |
| topLevelVariables |
| static c @14 |
| type: C? |
| accessors |
| synthetic static get c @-1 |
| returnType: C? |
| synthetic static set c @-1 |
| parameters |
| requiredPositional _c @-1 |
| type: C? |
| returnType: void |
| '''); |
| } |
| |
| test_class_ref_nullability_star() async { |
| featureSet = FeatureSets.language_2_9; |
| var library = await checkLibrary(''' |
| class C {} |
| C c; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| synthetic @-1 |
| topLevelVariables |
| static c @13 |
| type: C* |
| accessors |
| synthetic static get c @-1 |
| returnType: C* |
| synthetic static set c @-1 |
| parameters |
| requiredPositional _c @-1 |
| type: C* |
| returnType: void |
| '''); |
| } |
| |
| test_class_setter_abstract() async { |
| var library = |
| await checkLibrary('abstract class C { void set x(int value); }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| abstract class C @15 |
| fields |
| synthetic x @-1 |
| type: int |
| constructors |
| synthetic @-1 |
| accessors |
| abstract set x @28 |
| parameters |
| requiredPositional value @34 |
| type: int |
| returnType: void |
| '''); |
| } |
| |
| test_class_setter_covariant() async { |
| var library = |
| await checkLibrary('class C { void set x(covariant int value); }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| synthetic x @-1 |
| type: int |
| constructors |
| synthetic @-1 |
| accessors |
| abstract set x @19 |
| parameters |
| requiredPositional covariant value @35 |
| type: int |
| returnType: void |
| '''); |
| } |
| |
| test_class_setter_external() async { |
| var library = |
| await checkLibrary('class C { external void set x(int value); }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| synthetic x @-1 |
| type: int |
| constructors |
| synthetic @-1 |
| accessors |
| external set x @28 |
| parameters |
| requiredPositional value @34 |
| type: int |
| returnType: void |
| '''); |
| } |
| |
| test_class_setter_implicit_param_type() async { |
| var library = await checkLibrary('class C { void set x(value) {} }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| synthetic x @-1 |
| type: dynamic |
| constructors |
| synthetic @-1 |
| accessors |
| set x @19 |
| parameters |
| requiredPositional value @21 |
| type: dynamic |
| returnType: void |
| '''); |
| } |
| |
| test_class_setter_implicit_return_type() async { |
| var library = await checkLibrary('class C { set x(int value) {} }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| synthetic x @-1 |
| type: int |
| constructors |
| synthetic @-1 |
| accessors |
| set x @14 |
| parameters |
| requiredPositional value @20 |
| type: int |
| returnType: void |
| '''); |
| } |
| |
| test_class_setter_inferred_type_conflictingInheritance() async { |
| var library = await checkLibrary(''' |
| class A { |
| int t; |
| } |
| class B extends A { |
| double t; |
| } |
| class C extends A implements B { |
| } |
| class D extends C { |
| void set t(p) {} |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class A @6 |
| fields |
| t @16 |
| type: int |
| constructors |
| synthetic @-1 |
| accessors |
| synthetic get t @-1 |
| returnType: int |
| synthetic set t @-1 |
| parameters |
| requiredPositional _t @-1 |
| type: int |
| returnType: void |
| class B @27 |
| supertype: A |
| fields |
| t @50 |
| type: double |
| constructors |
| synthetic @-1 |
| superConstructor: self::@class::A::@constructor::• |
| accessors |
| synthetic get t @-1 |
| returnType: double |
| synthetic set t @-1 |
| parameters |
| requiredPositional _t @-1 |
| type: double |
| returnType: void |
| class C @61 |
| supertype: A |
| interfaces |
| B |
| constructors |
| synthetic @-1 |
| superConstructor: self::@class::A::@constructor::• |
| class D @96 |
| supertype: C |
| fields |
| synthetic t @-1 |
| type: dynamic |
| constructors |
| synthetic @-1 |
| superConstructor: self::@class::C::@constructor::• |
| accessors |
| set t @121 |
| parameters |
| requiredPositional p @123 |
| type: dynamic |
| returnType: void |
| '''); |
| } |
| |
| test_class_setter_inferred_type_nonStatic_implicit_param() async { |
| var library = |
| await checkLibrary('class C extends D { void set f(value) {} }' |
| ' abstract class D { void set f(int value); }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| supertype: D |
| fields |
| synthetic f @-1 |
| type: int |
| constructors |
| synthetic @-1 |
| superConstructor: self::@class::D::@constructor::• |
| accessors |
| set f @29 |
| parameters |
| requiredPositional value @31 |
| type: int |
| returnType: void |
| abstract class D @58 |
| fields |
| synthetic f @-1 |
| type: int |
| constructors |
| synthetic @-1 |
| accessors |
| abstract set f @71 |
| parameters |
| requiredPositional value @77 |
| type: int |
| returnType: void |
| '''); |
| } |
| |
| test_class_setter_inferred_type_static_implicit_return() async { |
| var library = await checkLibrary(''' |
| class C { |
| static set f(int value) {} |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| synthetic static f @-1 |
| type: int |
| constructors |
| synthetic @-1 |
| accessors |
| static set f @23 |
| parameters |
| requiredPositional value @29 |
| type: int |
| returnType: void |
| '''); |
| } |
| |
| test_class_setter_invalid_named_parameter() async { |
| var library = await checkLibrary('class C { void set x({a}) {} }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| synthetic x @-1 |
| type: dynamic |
| constructors |
| synthetic @-1 |
| accessors |
| set x @19 |
| parameters |
| optionalNamed a @22 |
| type: dynamic |
| returnType: void |
| '''); |
| } |
| |
| test_class_setter_invalid_no_parameter() async { |
| var library = await checkLibrary('class C { void set x() {} }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| synthetic x @-1 |
| type: dynamic |
| constructors |
| synthetic @-1 |
| accessors |
| set x @19 |
| returnType: void |
| '''); |
| } |
| |
| test_class_setter_invalid_optional_parameter() async { |
| var library = await checkLibrary('class C { void set x([a]) {} }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| synthetic x @-1 |
| type: dynamic |
| constructors |
| synthetic @-1 |
| accessors |
| set x @19 |
| parameters |
| optionalPositional a @22 |
| type: dynamic |
| returnType: void |
| '''); |
| } |
| |
| test_class_setter_invalid_too_many_parameters() async { |
| var library = await checkLibrary('class C { void set x(a, b) {} }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| synthetic x @-1 |
| type: dynamic |
| constructors |
| synthetic @-1 |
| accessors |
| set x @19 |
| parameters |
| requiredPositional a @21 |
| type: dynamic |
| requiredPositional b @24 |
| type: dynamic |
| returnType: void |
| '''); |
| } |
| |
| test_class_setter_native() async { |
| var library = await checkLibrary(''' |
| class C { |
| void set x(int value) native; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| synthetic x @-1 |
| type: int |
| constructors |
| synthetic @-1 |
| accessors |
| external set x @21 |
| parameters |
| requiredPositional value @27 |
| type: int |
| returnType: void |
| '''); |
| } |
| |
| test_class_setter_static() async { |
| var library = |
| await checkLibrary('class C { static void set x(int value) {} }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| synthetic static x @-1 |
| type: int |
| constructors |
| synthetic @-1 |
| accessors |
| static set x @26 |
| parameters |
| requiredPositional value @32 |
| type: int |
| returnType: void |
| '''); |
| } |
| |
| test_class_setters() async { |
| var library = await checkLibrary(''' |
| class C { |
| void set x(int value) {} |
| set y(value) {} |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| synthetic x @-1 |
| type: int |
| synthetic y @-1 |
| type: dynamic |
| constructors |
| synthetic @-1 |
| accessors |
| set x @21 |
| parameters |
| requiredPositional value @27 |
| type: int |
| returnType: void |
| set y @43 |
| parameters |
| requiredPositional value @45 |
| type: dynamic |
| returnType: void |
| '''); |
| } |
| |
| test_class_supertype() async { |
| var library = await checkLibrary(''' |
| class C extends D {} |
| class D {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| supertype: D |
| constructors |
| synthetic @-1 |
| superConstructor: self::@class::D::@constructor::• |
| class D @27 |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_supertype_typeArguments() async { |
| var library = await checkLibrary(''' |
| class C extends D<int, double> {} |
| class D<T1, T2> {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| supertype: D<int, double> |
| constructors |
| synthetic @-1 |
| superConstructor: ConstructorMember |
| base: self::@class::D::@constructor::• |
| substitution: {T1: int, T2: double} |
| class D @40 |
| typeParameters |
| covariant T1 @42 |
| defaultType: dynamic |
| covariant T2 @46 |
| defaultType: dynamic |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_supertype_typeArguments_self() async { |
| var library = await checkLibrary(''' |
| class A<T> {} |
| class B extends A<B> {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class A @6 |
| typeParameters |
| covariant T @8 |
| defaultType: dynamic |
| constructors |
| synthetic @-1 |
| class B @20 |
| supertype: A<B> |
| constructors |
| synthetic @-1 |
| superConstructor: ConstructorMember |
| base: self::@class::A::@constructor::• |
| substitution: {T: B} |
| '''); |
| } |
| |
| test_class_supertype_unresolved() async { |
| var library = await checkLibrary('class C extends D {}', allowErrors: true); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_typeParameters() async { |
| var library = await checkLibrary('class C<T, U> {}'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| typeParameters |
| covariant T @8 |
| defaultType: dynamic |
| covariant U @11 |
| defaultType: dynamic |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_typeParameters_bound() async { |
| var library = await checkLibrary(''' |
| class C<T extends Object, U extends D> {} |
| class D {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| typeParameters |
| covariant T @8 |
| bound: Object |
| defaultType: Object |
| covariant U @26 |
| bound: D |
| defaultType: D |
| constructors |
| synthetic @-1 |
| class D @48 |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_typeParameters_cycle_1of1() async { |
| var library = await checkLibrary('class C<T extends T> {}'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| notSimplyBounded class C @6 |
| typeParameters |
| covariant T @8 |
| bound: dynamic |
| defaultType: dynamic |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_typeParameters_cycle_2of3() async { |
| var library = await checkLibrary(r''' |
| class C<T extends V, U, V extends T> {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| notSimplyBounded class C @6 |
| typeParameters |
| covariant T @8 |
| bound: dynamic |
| defaultType: dynamic |
| covariant U @21 |
| defaultType: dynamic |
| covariant V @24 |
| bound: dynamic |
| defaultType: dynamic |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_typeParameters_defaultType_cycle_genericFunctionType() async { |
| var library = await checkLibrary(r''' |
| class A<T extends void Function(A)> {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| notSimplyBounded class A @6 |
| typeParameters |
| covariant T @8 |
| bound: void Function(A<dynamic>) |
| defaultType: dynamic |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_typeParameters_defaultType_cycle_genericFunctionType2() async { |
| var library = await checkLibrary(r''' |
| class C<T extends void Function<U extends C>()> {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| notSimplyBounded class C @6 |
| typeParameters |
| covariant T @8 |
| bound: void Function<U extends C<dynamic>>() |
| defaultType: dynamic |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_typeParameters_defaultType_functionTypeAlias_contravariant_legacy() async { |
| featureSet = FeatureSets.language_2_9; |
| var library = await checkLibrary(r''' |
| typedef F<X> = void Function(X); |
| |
| class A<X extends F<X>> {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| notSimplyBounded class A @40 |
| typeParameters |
| covariant X @42 |
| bound: void Function(X*)* |
| aliasElement: self::@typeAlias::F |
| aliasArguments |
| X* |
| defaultType: void Function(Null*)* |
| aliasElement: self::@typeAlias::F |
| aliasArguments |
| Null* |
| constructors |
| synthetic @-1 |
| typeAliases |
| F @8 |
| typeParameters |
| contravariant X @10 |
| defaultType: dynamic |
| aliasedType: void Function(X*)* |
| aliasedElement: GenericFunctionTypeElement |
| parameters |
| requiredPositional @-1 |
| type: X* |
| returnType: void |
| '''); |
| } |
| |
| test_class_typeParameters_defaultType_functionTypeAlias_contravariant_nullSafe() async { |
| var library = await checkLibrary(r''' |
| typedef F<X> = void Function(X); |
| |
| class A<X extends F<X>> {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| notSimplyBounded class A @40 |
| typeParameters |
| covariant X @42 |
| bound: void Function(X) |
| aliasElement: self::@typeAlias::F |
| aliasArguments |
| X |
| defaultType: void Function(Never) |
| aliasElement: self::@typeAlias::F |
| aliasArguments |
| Never |
| constructors |
| synthetic @-1 |
| typeAliases |
| F @8 |
| typeParameters |
| contravariant X @10 |
| defaultType: dynamic |
| aliasedType: void Function(X) |
| aliasedElement: GenericFunctionTypeElement |
| parameters |
| requiredPositional @-1 |
| type: X |
| returnType: void |
| '''); |
| } |
| |
| test_class_typeParameters_defaultType_functionTypeAlias_covariant_nullSafe() async { |
| var library = await checkLibrary(r''' |
| typedef F<X> = X Function(); |
| |
| class A<X extends F<X>> {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| notSimplyBounded class A @36 |
| typeParameters |
| covariant X @38 |
| bound: X Function() |
| aliasElement: self::@typeAlias::F |
| aliasArguments |
| X |
| defaultType: dynamic Function() |
| aliasElement: self::@typeAlias::F |
| aliasArguments |
| dynamic |
| constructors |
| synthetic @-1 |
| typeAliases |
| F @8 |
| typeParameters |
| covariant X @10 |
| defaultType: dynamic |
| aliasedType: X Function() |
| aliasedElement: GenericFunctionTypeElement |
| returnType: X |
| '''); |
| } |
| |
| test_class_typeParameters_defaultType_functionTypeAlias_invariant_legacy() async { |
| var library = await checkLibrary(r''' |
| typedef F<X> = X Function(X); |
| |
| class A<X extends F<X>> {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| notSimplyBounded class A @37 |
| typeParameters |
| covariant X @39 |
| bound: X Function(X) |
| aliasElement: self::@typeAlias::F |
| aliasArguments |
| X |
| defaultType: dynamic Function(dynamic) |
| aliasElement: self::@typeAlias::F |
| aliasArguments |
| dynamic |
| constructors |
| synthetic @-1 |
| typeAliases |
| F @8 |
| typeParameters |
| invariant X @10 |
| defaultType: dynamic |
| aliasedType: X Function(X) |
| aliasedElement: GenericFunctionTypeElement |
| parameters |
| requiredPositional @-1 |
| type: X |
| returnType: X |
| '''); |
| } |
| |
| test_class_typeParameters_defaultType_functionTypeAlias_invariant_nullSafe() async { |
| var library = await checkLibrary(r''' |
| typedef F<X> = X Function(X); |
| |
| class A<X extends F<X>> {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| notSimplyBounded class A @37 |
| typeParameters |
| covariant X @39 |
| bound: X Function(X) |
| aliasElement: self::@typeAlias::F |
| aliasArguments |
| X |
| defaultType: dynamic Function(dynamic) |
| aliasElement: self::@typeAlias::F |
| aliasArguments |
| dynamic |
| constructors |
| synthetic @-1 |
| typeAliases |
| F @8 |
| typeParameters |
| invariant X @10 |
| defaultType: dynamic |
| aliasedType: X Function(X) |
| aliasedElement: GenericFunctionTypeElement |
| parameters |
| requiredPositional @-1 |
| type: X |
| returnType: X |
| '''); |
| } |
| |
| test_class_typeParameters_defaultType_genericFunctionType_both_legacy() async { |
| featureSet = FeatureSets.language_2_9; |
| var library = await checkLibrary(r''' |
| class A<X extends X Function(X)> {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| notSimplyBounded class A @6 |
| typeParameters |
| covariant X @8 |
| bound: X* Function(X*)* |
| defaultType: dynamic Function(Null*)* |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_typeParameters_defaultType_genericFunctionType_both_nullSafe() async { |
| var library = await checkLibrary(r''' |
| class A<X extends X Function(X)> {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| notSimplyBounded class A @6 |
| typeParameters |
| covariant X @8 |
| bound: X Function(X) |
| defaultType: dynamic Function(Never) |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_typeParameters_defaultType_genericFunctionType_contravariant_legacy() async { |
| featureSet = FeatureSets.language_2_9; |
| var library = await checkLibrary(r''' |
| class A<X extends void Function(X)> {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| notSimplyBounded class A @6 |
| typeParameters |
| covariant X @8 |
| bound: void Function(X*)* |
| defaultType: void Function(Null*)* |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_typeParameters_defaultType_genericFunctionType_contravariant_nullSafe() async { |
| var library = await checkLibrary(r''' |
| class A<X extends void Function(X)> {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| notSimplyBounded class A @6 |
| typeParameters |
| covariant X @8 |
| bound: void Function(X) |
| defaultType: void Function(Never) |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_typeParameters_defaultType_genericFunctionType_covariant_legacy() async { |
| var library = await checkLibrary(r''' |
| class A<X extends X Function()> {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| notSimplyBounded class A @6 |
| typeParameters |
| covariant X @8 |
| bound: X Function() |
| defaultType: dynamic Function() |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_typeParameters_defaultType_genericFunctionType_covariant_nullSafe() async { |
| var library = await checkLibrary(r''' |
| class A<X extends X Function()> {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| notSimplyBounded class A @6 |
| typeParameters |
| covariant X @8 |
| bound: X Function() |
| defaultType: dynamic Function() |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_typeParameters_defaultType_typeAlias_interface_contravariant() async { |
| var library = await checkLibrary(r''' |
| typedef A<X> = List<void Function(X)>; |
| |
| class B<X extends A<X>> {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| notSimplyBounded class B @46 |
| typeParameters |
| covariant X @48 |
| bound: List<void Function(X)> |
| aliasElement: self::@typeAlias::A |
| aliasArguments |
| X |
| defaultType: List<void Function(Never)> |
| aliasElement: self::@typeAlias::A |
| aliasArguments |
| Never |
| constructors |
| synthetic @-1 |
| typeAliases |
| A @8 |
| typeParameters |
| contravariant X @10 |
| defaultType: dynamic |
| aliasedType: List<void Function(X)> |
| '''); |
| } |
| |
| test_class_typeParameters_defaultType_typeAlias_interface_covariant() async { |
| var library = await checkLibrary(r''' |
| typedef A<X> = Map<X, int>; |
| |
| class B<X extends A<X>> {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| notSimplyBounded class B @35 |
| typeParameters |
| covariant X @37 |
| bound: Map<X, int> |
| aliasElement: self::@typeAlias::A |
| aliasArguments |
| X |
| defaultType: Map<dynamic, int> |
| aliasElement: self::@typeAlias::A |
| aliasArguments |
| dynamic |
| constructors |
| synthetic @-1 |
| typeAliases |
| A @8 |
| typeParameters |
| covariant X @10 |
| defaultType: dynamic |
| aliasedType: Map<X, int> |
| '''); |
| } |
| |
| test_class_typeParameters_f_bound_complex() async { |
| var library = await checkLibrary('class C<T extends List<U>, U> {}'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| notSimplyBounded class C @6 |
| typeParameters |
| covariant T @8 |
| bound: List<U> |
| defaultType: List<dynamic> |
| covariant U @27 |
| defaultType: dynamic |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_typeParameters_f_bound_simple() async { |
| var library = await checkLibrary('class C<T extends U, U> {}'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| notSimplyBounded class C @6 |
| typeParameters |
| covariant T @8 |
| bound: U |
| defaultType: dynamic |
| covariant U @21 |
| defaultType: dynamic |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_typeParameters_variance_contravariant() async { |
| var library = await checkLibrary('class C<in T> {}'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| typeParameters |
| contravariant T @11 |
| defaultType: dynamic |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_typeParameters_variance_covariant() async { |
| var library = await checkLibrary('class C<out T> {}'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| typeParameters |
| covariant T @12 |
| defaultType: dynamic |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_typeParameters_variance_invariant() async { |
| var library = await checkLibrary('class C<inout T> {}'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| typeParameters |
| invariant T @14 |
| defaultType: dynamic |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_class_typeParameters_variance_multiple() async { |
| var library = await checkLibrary('class C<inout T, in U, out V> {}'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| typeParameters |
| invariant T @14 |
| defaultType: dynamic |
| contravariant U @20 |
| defaultType: dynamic |
| covariant V @27 |
| defaultType: dynamic |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_classAlias() async { |
| var library = await checkLibrary(''' |
| class C = D with E, F, G; |
| class D {} |
| class E {} |
| class F {} |
| class G {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class alias C @6 |
| supertype: D |
| mixins |
| E |
| F |
| G |
| constructors |
| synthetic @-1 |
| constantInitializers |
| SuperConstructorInvocation |
| superKeyword: super @0 |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticElement: self::@class::D::@constructor::• |
| superConstructor: self::@class::D::@constructor::• |
| class D @32 |
| constructors |
| synthetic @-1 |
| class E @43 |
| constructors |
| synthetic @-1 |
| class F @54 |
| constructors |
| synthetic @-1 |
| class G @65 |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_classAlias_abstract() async { |
| var library = await checkLibrary(''' |
| abstract class C = D with E; |
| class D {} |
| class E {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| abstract class alias C @15 |
| supertype: D |
| mixins |
| E |
| constructors |
| synthetic @-1 |
| constantInitializers |
| SuperConstructorInvocation |
| superKeyword: super @0 |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticElement: self::@class::D::@constructor::• |
| superConstructor: self::@class::D::@constructor::• |
| class D @35 |
| constructors |
| synthetic @-1 |
| class E @46 |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_classAlias_documented() async { |
| var library = await checkLibrary(''' |
| /** |
| * Docs |
| */ |
| class C = D with E; |
| |
| class D {} |
| class E {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class alias C @22 |
| documentationComment: /**\n * Docs\n */ |
| supertype: D |
| mixins |
| E |
| constructors |
| synthetic @-1 |
| constantInitializers |
| SuperConstructorInvocation |
| superKeyword: super @0 |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticElement: self::@class::D::@constructor::• |
| superConstructor: self::@class::D::@constructor::• |
| class D @43 |
| constructors |
| synthetic @-1 |
| class E @54 |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_classAlias_documented_tripleSlash() async { |
| var library = await checkLibrary(''' |
| /// aaa |
| /// b |
| /// cc |
| class C = D with E; |
| |
| class D {} |
| class E {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class alias C @27 |
| documentationComment: /// aaa\n/// b\n/// cc |
| supertype: D |
| mixins |
| E |
| constructors |
| synthetic @-1 |
| constantInitializers |
| SuperConstructorInvocation |
| superKeyword: super @0 |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticElement: self::@class::D::@constructor::• |
| superConstructor: self::@class::D::@constructor::• |
| class D @48 |
| constructors |
| synthetic @-1 |
| class E @59 |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_classAlias_documented_withLeadingNonDocumentation() async { |
| var library = await checkLibrary(''' |
| // Extra comment so doc comment offset != 0 |
| /** |
| * Docs |
| */ |
| class C = D with E; |
| |
| class D {} |
| class E {}'''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class alias C @66 |
| documentationComment: /**\n * Docs\n */ |
| supertype: D |
| mixins |
| E |
| constructors |
| synthetic @-1 |
| constantInitializers |
| SuperConstructorInvocation |
| superKeyword: super @0 |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticElement: self::@class::D::@constructor::• |
| superConstructor: self::@class::D::@constructor::• |
| class D @87 |
| constructors |
| synthetic @-1 |
| class E @98 |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_classAlias_generic() async { |
| var library = await checkLibrary(''' |
| class Z = A with B<int>, C<double>; |
| class A {} |
| class B<B1> {} |
| class C<C1> {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class alias Z @6 |
| supertype: A |
| mixins |
| B<int> |
| C<double> |
| constructors |
| synthetic @-1 |
| constantInitializers |
| SuperConstructorInvocation |
| superKeyword: super @0 |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticElement: self::@class::A::@constructor::• |
| superConstructor: self::@class::A::@constructor::• |
| class A @42 |
| constructors |
| synthetic @-1 |
| class B @53 |
| typeParameters |
| covariant B1 @55 |
| defaultType: dynamic |
| constructors |
| synthetic @-1 |
| class C @68 |
| typeParameters |
| covariant C1 @70 |
| defaultType: dynamic |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_classAlias_notSimplyBounded_self() async { |
| var library = await checkLibrary(''' |
| class C<T extends C> = D with E; |
| class D {} |
| class E {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| notSimplyBounded class alias C @6 |
| typeParameters |
| covariant T @8 |
| bound: C<dynamic> |
| defaultType: dynamic |
| supertype: D |
| mixins |
| E |
| constructors |
| synthetic @-1 |
| constantInitializers |
| SuperConstructorInvocation |
| superKeyword: super @0 |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticElement: self::@class::D::@constructor::• |
| superConstructor: self::@class::D::@constructor::• |
| class D @39 |
| constructors |
| synthetic @-1 |
| class E @50 |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_classAlias_notSimplyBounded_simple_no_type_parameter_bound() async { |
| // If no bounds are specified, then the class is simply bounded by syntax |
| // alone, so there is no reason to assign it a slot. |
| var library = await checkLibrary(''' |
| class C<T> = D with E; |
| class D {} |
| class E {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class alias C @6 |
| typeParameters |
| covariant T @8 |
| defaultType: dynamic |
| supertype: D |
| mixins |
| E |
| constructors |
| synthetic @-1 |
| constantInitializers |
| SuperConstructorInvocation |
| superKeyword: super @0 |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticElement: self::@class::D::@constructor::• |
| superConstructor: self::@class::D::@constructor::• |
| class D @29 |
| constructors |
| synthetic @-1 |
| class E @40 |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_classAlias_notSimplyBounded_simple_non_generic() async { |
| // If no type parameters are specified, then the class is simply bounded, so |
| // there is no reason to assign it a slot. |
| var library = await checkLibrary(''' |
| class C = D with E; |
| class D {} |
| class E {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class alias C @6 |
| supertype: D |
| mixins |
| E |
| constructors |
| synthetic @-1 |
| constantInitializers |
| SuperConstructorInvocation |
| superKeyword: super @0 |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticElement: self::@class::D::@constructor::• |
| superConstructor: self::@class::D::@constructor::• |
| class D @26 |
| constructors |
| synthetic @-1 |
| class E @37 |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_classAlias_with_const_constructors() async { |
| testFile = convertPath('/home/test/lib/test.dart'); |
| addLibrarySource('/home/test/lib/a.dart', r''' |
| class Base { |
| const Base._priv(); |
| const Base(); |
| const Base.named(); |
| } |
| '''); |
| var library = await checkLibrary(''' |
| import "a.dart"; |
| class M {} |
| class MixinApp = Base with M; |
| '''); |
| checkElementText(library, r''' |
| library |
| imports |
| package:test/a.dart |
| definingUnit |
| classes |
| class M @23 |
| constructors |
| synthetic @-1 |
| class alias MixinApp @34 |
| supertype: Base |
| mixins |
| M |
| constructors |
| synthetic const @-1 |
| constantInitializers |
| SuperConstructorInvocation |
| superKeyword: super @0 |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticElement: package:test/a.dart::@class::Base::@constructor::• |
| superConstructor: package:test/a.dart::@class::Base::@constructor::• |
| synthetic const named @-1 |
| constantInitializers |
| SuperConstructorInvocation |
| superKeyword: super @0 |
| period: . @0 |
| constructorName: SimpleIdentifier |
| token: named @-1 |
| staticElement: package:test/a.dart::@class::Base::@constructor::named |
| staticType: null |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticElement: package:test/a.dart::@class::Base::@constructor::named |
| superConstructor: package:test/a.dart::@class::Base::@constructor::named |
| '''); |
| } |
| |
| test_classAlias_with_forwarding_constructors() async { |
| testFile = convertPath('/home/test/lib/test.dart'); |
| addLibrarySource('/home/test/lib/a.dart', r''' |
| class Base { |
| bool x = true; |
| Base._priv(); |
| Base(); |
| Base.noArgs(); |
| Base.requiredArg(x); |
| Base.positionalArg([bool x = true]); |
| Base.positionalArg2([this.x = true]); |
| Base.namedArg({int x = 42}); |
| Base.namedArg2({this.x = true}); |
| factory Base.fact() => Base(); |
| factory Base.fact2() = Base.noArgs; |
| } |
| '''); |
| var library = await checkLibrary(''' |
| import "a.dart"; |
| class M {} |
| class MixinApp = Base with M; |
| '''); |
| checkElementText(library, r''' |
| library |
| imports |
| package:test/a.dart |
| definingUnit |
| classes |
| class M @23 |
| constructors |
| synthetic @-1 |
| class alias MixinApp @34 |
| supertype: Base |
| mixins |
| M |
| constructors |
| synthetic @-1 |
| constantInitializers |
| SuperConstructorInvocation |
| superKeyword: super @0 |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticElement: package:test/a.dart::@class::Base::@constructor::• |
| superConstructor: package:test/a.dart::@class::Base::@constructor::• |
| synthetic noArgs @-1 |
| constantInitializers |
| SuperConstructorInvocation |
| superKeyword: super @0 |
| period: . @0 |
| constructorName: SimpleIdentifier |
| token: noArgs @-1 |
| staticElement: package:test/a.dart::@class::Base::@constructor::noArgs |
| staticType: null |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticElement: package:test/a.dart::@class::Base::@constructor::noArgs |
| superConstructor: package:test/a.dart::@class::Base::@constructor::noArgs |
| synthetic requiredArg @-1 |
| parameters |
| requiredPositional x @-1 |
| type: dynamic |
| constantInitializers |
| SuperConstructorInvocation |
| superKeyword: super @0 |
| period: . @0 |
| constructorName: SimpleIdentifier |
| token: requiredArg @-1 |
| staticElement: package:test/a.dart::@class::Base::@constructor::requiredArg |
| staticType: null |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| arguments |
| SimpleIdentifier |
| token: x @-1 |
| staticElement: x@-1 |
| staticType: dynamic |
| rightParenthesis: ) @0 |
| staticElement: package:test/a.dart::@class::Base::@constructor::requiredArg |
| superConstructor: package:test/a.dart::@class::Base::@constructor::requiredArg |
| synthetic positionalArg @-1 |
| parameters |
| optionalPositional x @-1 |
| type: bool |
| constantInitializer |
| BooleanLiteral |
| literal: true @127 |
| staticType: bool |
| constantInitializers |
| SuperConstructorInvocation |
| superKeyword: super @0 |
| period: . @0 |
| constructorName: SimpleIdentifier |
| token: positionalArg @-1 |
| staticElement: package:test/a.dart::@class::Base::@constructor::positionalArg |
| staticType: null |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| arguments |
| SimpleIdentifier |
| token: x @-1 |
| staticElement: x@-1 |
| staticType: bool |
| rightParenthesis: ) @0 |
| staticElement: package:test/a.dart::@class::Base::@constructor::positionalArg |
| superConstructor: package:test/a.dart::@class::Base::@constructor::positionalArg |
| synthetic positionalArg2 @-1 |
| parameters |
| optionalPositional final x @-1 |
| type: bool |
| constantInitializer |
| BooleanLiteral |
| literal: true @167 |
| staticType: bool |
| constantInitializers |
| SuperConstructorInvocation |
| superKeyword: super @0 |
| period: . @0 |
| constructorName: SimpleIdentifier |
| token: positionalArg2 @-1 |
| staticElement: package:test/a.dart::@class::Base::@constructor::positionalArg2 |
| staticType: null |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| arguments |
| SimpleIdentifier |
| token: x @-1 |
| staticElement: x@-1 |
| staticType: bool |
| rightParenthesis: ) @0 |
| staticElement: package:test/a.dart::@class::Base::@constructor::positionalArg2 |
| superConstructor: package:test/a.dart::@class::Base::@constructor::positionalArg2 |
| synthetic namedArg @-1 |
| parameters |
| optionalNamed x @-1 |
| type: int |
| constantInitializer |
| IntegerLiteral |
| literal: 42 @200 |
| staticType: int |
| constantInitializers |
| SuperConstructorInvocation |
| superKeyword: super @0 |
| period: . @0 |
| constructorName: SimpleIdentifier |
| token: namedArg @-1 |
| staticElement: package:test/a.dart::@class::Base::@constructor::namedArg |
| staticType: null |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| arguments |
| SimpleIdentifier |
| token: x @-1 |
| staticElement: x@-1 |
| staticType: int |
| rightParenthesis: ) @0 |
| staticElement: package:test/a.dart::@class::Base::@constructor::namedArg |
| superConstructor: package:test/a.dart::@class::Base::@constructor::namedArg |
| synthetic namedArg2 @-1 |
| parameters |
| optionalNamed final x @-1 |
| type: bool |
| constantInitializer |
| BooleanLiteral |
| literal: true @233 |
| staticType: bool |
| constantInitializers |
| SuperConstructorInvocation |
| superKeyword: super @0 |
| period: . @0 |
| constructorName: SimpleIdentifier |
| token: namedArg2 @-1 |
| staticElement: package:test/a.dart::@class::Base::@constructor::namedArg2 |
| staticType: null |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| arguments |
| SimpleIdentifier |
| token: x @-1 |
| staticElement: x@-1 |
| staticType: bool |
| rightParenthesis: ) @0 |
| staticElement: package:test/a.dart::@class::Base::@constructor::namedArg2 |
| superConstructor: package:test/a.dart::@class::Base::@constructor::namedArg2 |
| '''); |
| } |
| |
| test_classAlias_with_forwarding_constructors_type_substitution() async { |
| var library = await checkLibrary(''' |
| class Base<T> { |
| Base.ctor(T t, List<T> l); |
| } |
| class M {} |
| class MixinApp = Base with M; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class Base @6 |
| typeParameters |
| covariant T @11 |
| defaultType: dynamic |
| constructors |
| ctor @23 |
| periodOffset: 22 |
| nameEnd: 27 |
| parameters |
| requiredPositional t @30 |
| type: T |
| requiredPositional l @41 |
| type: List<T> |
| class M @53 |
| constructors |
| synthetic @-1 |
| class alias MixinApp @64 |
| supertype: Base<dynamic> |
| mixins |
| M |
| constructors |
| synthetic ctor @-1 |
| parameters |
| requiredPositional t @-1 |
| type: dynamic |
| requiredPositional l @-1 |
| type: List<dynamic> |
| constantInitializers |
| SuperConstructorInvocation |
| superKeyword: super @0 |
| period: . @0 |
| constructorName: SimpleIdentifier |
| token: ctor @-1 |
| staticElement: self::@class::Base::@constructor::ctor |
| staticType: null |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| arguments |
| SimpleIdentifier |
| token: t @-1 |
| staticElement: t@-1 |
| staticType: dynamic |
| SimpleIdentifier |
| token: l @-1 |
| staticElement: l@-1 |
| staticType: List<dynamic> |
| rightParenthesis: ) @0 |
| staticElement: self::@class::Base::@constructor::ctor |
| superConstructor: ConstructorMember |
| base: self::@class::Base::@constructor::ctor |
| substitution: {T: dynamic} |
| '''); |
| } |
| |
| test_classAlias_with_forwarding_constructors_type_substitution_complex() async { |
| var library = await checkLibrary(''' |
| class Base<T> { |
| Base.ctor(T t, List<T> l); |
| } |
| class M {} |
| class MixinApp<U> = Base<List<U>> with M; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class Base @6 |
| typeParameters |
| covariant T @11 |
| defaultType: dynamic |
| constructors |
| ctor @23 |
| periodOffset: 22 |
| nameEnd: 27 |
| parameters |
| requiredPositional t @30 |
| type: T |
| requiredPositional l @41 |
| type: List<T> |
| class M @53 |
| constructors |
| synthetic @-1 |
| class alias MixinApp @64 |
| typeParameters |
| covariant U @73 |
| defaultType: dynamic |
| supertype: Base<List<U>> |
| mixins |
| M |
| constructors |
| synthetic ctor @-1 |
| parameters |
| requiredPositional t @-1 |
| type: List<U> |
| requiredPositional l @-1 |
| type: List<List<U>> |
| constantInitializers |
| SuperConstructorInvocation |
| superKeyword: super @0 |
| period: . @0 |
| constructorName: SimpleIdentifier |
| token: ctor @-1 |
| staticElement: self::@class::Base::@constructor::ctor |
| staticType: null |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| arguments |
| SimpleIdentifier |
| token: t @-1 |
| staticElement: t@-1 |
| staticType: List<U> |
| SimpleIdentifier |
| token: l @-1 |
| staticElement: l@-1 |
| staticType: List<List<U>> |
| rightParenthesis: ) @0 |
| staticElement: self::@class::Base::@constructor::ctor |
| superConstructor: ConstructorMember |
| base: self::@class::Base::@constructor::ctor |
| substitution: {T: List<U>} |
| '''); |
| } |
| |
| test_classAlias_with_mixin_members() async { |
| var library = await checkLibrary(''' |
| class C = D with E; |
| class D {} |
| class E { |
| int get a => null; |
| void set b(int i) {} |
| void f() {} |
| int x; |
| }'''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class alias C @6 |
| supertype: D |
| mixins |
| E |
| constructors |
| synthetic @-1 |
| constantInitializers |
| SuperConstructorInvocation |
| superKeyword: super @0 |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticElement: self::@class::D::@constructor::• |
| superConstructor: self::@class::D::@constructor::• |
| class D @26 |
| constructors |
| synthetic @-1 |
| class E @37 |
| fields |
| x @105 |
| type: int |
| synthetic a @-1 |
| type: int |
| synthetic b @-1 |
| type: int |
| constructors |
| synthetic @-1 |
| accessors |
| synthetic get x @-1 |
| returnType: int |
| synthetic set x @-1 |
| parameters |
| requiredPositional _x @-1 |
| type: int |
| returnType: void |
| get a @51 |
| returnType: int |
| set b @73 |
| parameters |
| requiredPositional i @79 |
| type: int |
| returnType: void |
| methods |
| f @92 |
| returnType: void |
| '''); |
| } |
| |
| test_classes() async { |
| var library = await checkLibrary('class C {} class D {}'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| synthetic @-1 |
| class D @17 |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_closure_executable_with_return_type_from_closure() async { |
| var library = await checkLibrary(''' |
| f() { |
| print(() {}); |
| print(() => () => 0); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| functions |
| f @0 |
| returnType: dynamic |
| '''); |
| } |
| |
| test_closure_generic() async { |
| var library = await checkLibrary(r''' |
| final f = <U, V>(U x, V y) => y; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static final f @6 |
| type: V Function<U, V>(U, V) |
| accessors |
| synthetic static get f @-1 |
| returnType: V Function<U, V>(U, V) |
| '''); |
| } |
| |
| test_closure_in_variable_declaration_in_part() async { |
| addSource('/a.dart', 'part of lib; final f = (int i) => i.toDouble();'); |
| var library = await checkLibrary(''' |
| library lib; |
| part "a.dart"; |
| '''); |
| checkElementText(library, r''' |
| library |
| name: lib |
| nameOffset: 8 |
| definingUnit |
| parts |
| a.dart |
| topLevelVariables |
| static final f @19 |
| type: double Function(int) |
| accessors |
| synthetic static get f @-1 |
| returnType: double Function(int) |
| '''); |
| } |
| |
| test_codeRange_class() async { |
| var library = await checkLibrary(''' |
| class Raw {} |
| |
| /// Comment 1. |
| /// Comment 2. |
| class HasDocComment {} |
| |
| @Object() |
| class HasAnnotation {} |
| |
| @Object() |
| /// Comment 1. |
| /// Comment 2. |
| class AnnotationThenComment {} |
| |
| /// Comment 1. |
| /// Comment 2. |
| @Object() |
| class CommentThenAnnotation {} |
| |
| /// Comment 1. |
| @Object() |
| /// Comment 2. |
| class CommentAroundAnnotation {} |
| '''); |
| checkElementText( |
| library, |
| r''' |
| library |
| definingUnit |
| classes |
| class Raw @6 |
| codeOffset: 0 |
| codeLength: 12 |
| constructors |
| synthetic @-1 |
| class HasDocComment @50 |
| documentationComment: /// Comment 1.\n/// Comment 2. |
| codeOffset: 14 |
| codeLength: 52 |
| constructors |
| synthetic @-1 |
| class HasAnnotation @84 |
| metadata |
| Annotation |
| atSign: @ @68 |
| name: SimpleIdentifier |
| token: Object @69 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @75 |
| rightParenthesis: ) @76 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 68 |
| codeLength: 32 |
| constructors |
| synthetic @-1 |
| class AnnotationThenComment @148 |
| documentationComment: /// Comment 1.\n/// Comment 2. |
| metadata |
| Annotation |
| atSign: @ @102 |
| name: SimpleIdentifier |
| token: Object @103 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @109 |
| rightParenthesis: ) @110 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 102 |
| codeLength: 70 |
| constructors |
| synthetic @-1 |
| class CommentThenAnnotation @220 |
| documentationComment: /// Comment 1.\n/// Comment 2. |
| metadata |
| Annotation |
| atSign: @ @204 |
| name: SimpleIdentifier |
| token: Object @205 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @211 |
| rightParenthesis: ) @212 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 174 |
| codeLength: 70 |
| constructors |
| synthetic @-1 |
| class CommentAroundAnnotation @292 |
| documentationComment: /// Comment 2. |
| metadata |
| Annotation |
| atSign: @ @261 |
| name: SimpleIdentifier |
| token: Object @262 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @268 |
| rightParenthesis: ) @269 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 261 |
| codeLength: 57 |
| constructors |
| synthetic @-1 |
| ''', |
| withCodeRanges: true); |
| } |
| |
| test_codeRange_class_namedMixin() async { |
| var library = await checkLibrary(''' |
| class A {} |
| |
| class B {} |
| |
| class Raw = Object with A, B; |
| |
| /// Comment 1. |
| /// Comment 2. |
| class HasDocComment = Object with A, B; |
| |
| @Object() |
| class HasAnnotation = Object with A, B; |
| |
| @Object() |
| /// Comment 1. |
| /// Comment 2. |
| class AnnotationThenComment = Object with A, B; |
| |
| /// Comment 1. |
| /// Comment 2. |
| @Object() |
| class CommentThenAnnotation = Object with A, B; |
| |
| /// Comment 1. |
| @Object() |
| /// Comment 2. |
| class CommentAroundAnnotation = Object with A, B; |
| '''); |
| checkElementText( |
| library, |
| r''' |
| library |
| definingUnit |
| classes |
| class A @6 |
| codeOffset: 0 |
| codeLength: 10 |
| constructors |
| synthetic @-1 |
| class B @18 |
| codeOffset: 12 |
| codeLength: 10 |
| constructors |
| synthetic @-1 |
| class alias Raw @30 |
| codeOffset: 24 |
| codeLength: 29 |
| supertype: Object |
| mixins |
| A |
| B |
| constructors |
| synthetic const @-1 |
| constantInitializers |
| SuperConstructorInvocation |
| superKeyword: super @0 |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticElement: dart:core::@class::Object::@constructor::• |
| class alias HasDocComment @91 |
| documentationComment: /// Comment 1.\n/// Comment 2. |
| codeOffset: 55 |
| codeLength: 69 |
| supertype: Object |
| mixins |
| A |
| B |
| constructors |
| synthetic const @-1 |
| constantInitializers |
| SuperConstructorInvocation |
| superKeyword: super @0 |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticElement: dart:core::@class::Object::@constructor::• |
| class alias HasAnnotation @142 |
| metadata |
| Annotation |
| atSign: @ @126 |
| name: SimpleIdentifier |
| token: Object @127 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @133 |
| rightParenthesis: ) @134 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 126 |
| codeLength: 49 |
| supertype: Object |
| mixins |
| A |
| B |
| constructors |
| synthetic const @-1 |
| constantInitializers |
| SuperConstructorInvocation |
| superKeyword: super @0 |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticElement: dart:core::@class::Object::@constructor::• |
| class alias AnnotationThenComment @223 |
| documentationComment: /// Comment 1.\n/// Comment 2. |
| metadata |
| Annotation |
| atSign: @ @177 |
| name: SimpleIdentifier |
| token: Object @178 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @184 |
| rightParenthesis: ) @185 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 177 |
| codeLength: 87 |
| supertype: Object |
| mixins |
| A |
| B |
| constructors |
| synthetic const @-1 |
| constantInitializers |
| SuperConstructorInvocation |
| superKeyword: super @0 |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticElement: dart:core::@class::Object::@constructor::• |
| class alias CommentThenAnnotation @312 |
| documentationComment: /// Comment 1.\n/// Comment 2. |
| metadata |
| Annotation |
| atSign: @ @296 |
| name: SimpleIdentifier |
| token: Object @297 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @303 |
| rightParenthesis: ) @304 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 266 |
| codeLength: 87 |
| supertype: Object |
| mixins |
| A |
| B |
| constructors |
| synthetic const @-1 |
| constantInitializers |
| SuperConstructorInvocation |
| superKeyword: super @0 |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticElement: dart:core::@class::Object::@constructor::• |
| class alias CommentAroundAnnotation @401 |
| documentationComment: /// Comment 2. |
| metadata |
| Annotation |
| atSign: @ @370 |
| name: SimpleIdentifier |
| token: Object @371 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @377 |
| rightParenthesis: ) @378 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 370 |
| codeLength: 74 |
| supertype: Object |
| mixins |
| A |
| B |
| constructors |
| synthetic const @-1 |
| constantInitializers |
| SuperConstructorInvocation |
| superKeyword: super @0 |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticElement: dart:core::@class::Object::@constructor::• |
| ''', |
| withCodeRanges: true); |
| } |
| |
| test_codeRange_constructor() async { |
| var library = await checkLibrary(''' |
| class C { |
| C(); |
| |
| C.raw() {} |
| |
| /// Comment 1. |
| /// Comment 2. |
| C.hasDocComment() {} |
| |
| @Object() |
| C.hasAnnotation() {} |
| |
| @Object() |
| /// Comment 1. |
| /// Comment 2. |
| C.annotationThenComment() {} |
| |
| /// Comment 1. |
| /// Comment 2. |
| @Object() |
| C.commentThenAnnotation() {} |
| |
| /// Comment 1. |
| @Object() |
| /// Comment 2. |
| C.commentAroundAnnotation() {} |
| } |
| '''); |
| checkElementText( |
| library, |
| r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| codeOffset: 0 |
| codeLength: 362 |
| constructors |
| @12 |
| codeOffset: 12 |
| codeLength: 4 |
| raw @22 |
| codeOffset: 20 |
| codeLength: 10 |
| periodOffset: 21 |
| nameEnd: 25 |
| hasDocComment @70 |
| documentationComment: /// Comment 1.\n/// Comment 2. |
| codeOffset: 34 |
| codeLength: 54 |
| periodOffset: 69 |
| nameEnd: 83 |
| hasAnnotation @106 |
| metadata |
| Annotation |
| atSign: @ @92 |
| name: SimpleIdentifier |
| token: Object @93 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @99 |
| rightParenthesis: ) @100 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 92 |
| codeLength: 32 |
| periodOffset: 105 |
| nameEnd: 119 |
| annotationThenComment @176 |
| documentationComment: /// Comment 1.\n/// Comment 2. |
| metadata |
| Annotation |
| atSign: @ @128 |
| name: SimpleIdentifier |
| token: Object @129 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @135 |
| rightParenthesis: ) @136 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 128 |
| codeLength: 74 |
| periodOffset: 175 |
| nameEnd: 197 |
| commentThenAnnotation @254 |
| documentationComment: /// Comment 1.\n/// Comment 2. |
| metadata |
| Annotation |
| atSign: @ @240 |
| name: SimpleIdentifier |
| token: Object @241 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @247 |
| rightParenthesis: ) @248 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 206 |
| codeLength: 74 |
| periodOffset: 253 |
| nameEnd: 275 |
| commentAroundAnnotation @332 |
| documentationComment: /// Comment 2. |
| metadata |
| Annotation |
| atSign: @ @301 |
| name: SimpleIdentifier |
| token: Object @302 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @308 |
| rightParenthesis: ) @309 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 301 |
| codeLength: 59 |
| periodOffset: 331 |
| nameEnd: 355 |
| ''', |
| withCodeRanges: true); |
| } |
| |
| test_codeRange_constructor_factory() async { |
| var library = await checkLibrary(''' |
| class C { |
| factory C() => throw 0; |
| |
| factory C.raw() => throw 0; |
| |
| /// Comment 1. |
| /// Comment 2. |
| factory C.hasDocComment() => throw 0; |
| |
| @Object() |
| factory C.hasAnnotation() => throw 0; |
| |
| @Object() |
| /// Comment 1. |
| /// Comment 2. |
| factory C.annotationThenComment() => throw 0; |
| |
| /// Comment 1. |
| /// Comment 2. |
| @Object() |
| factory C.commentThenAnnotation() => throw 0; |
| |
| /// Comment 1. |
| @Object() |
| /// Comment 2. |
| factory C.commentAroundAnnotation() => throw 0; |
| } |
| '''); |
| checkElementText( |
| library, |
| r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| codeOffset: 0 |
| codeLength: 483 |
| constructors |
| factory @20 |
| codeOffset: 12 |
| codeLength: 23 |
| factory raw @49 |
| codeOffset: 39 |
| codeLength: 27 |
| periodOffset: 48 |
| nameEnd: 52 |
| factory hasDocComment @114 |
| documentationComment: /// Comment 1.\n/// Comment 2. |
| codeOffset: 70 |
| codeLength: 71 |
| periodOffset: 113 |
| nameEnd: 127 |
| factory hasAnnotation @167 |
| metadata |
| Annotation |
| atSign: @ @145 |
| name: SimpleIdentifier |
| token: Object @146 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @152 |
| rightParenthesis: ) @153 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 145 |
| codeLength: 49 |
| periodOffset: 166 |
| nameEnd: 180 |
| factory annotationThenComment @254 |
| documentationComment: /// Comment 1.\n/// Comment 2. |
| metadata |
| Annotation |
| atSign: @ @198 |
| name: SimpleIdentifier |
| token: Object @199 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @205 |
| rightParenthesis: ) @206 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 198 |
| codeLength: 91 |
| periodOffset: 253 |
| nameEnd: 275 |
| factory commentThenAnnotation @349 |
| documentationComment: /// Comment 1.\n/// Comment 2. |
| metadata |
| Annotation |
| atSign: @ @327 |
| name: SimpleIdentifier |
| token: Object @328 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @334 |
| rightParenthesis: ) @335 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 293 |
| codeLength: 91 |
| periodOffset: 348 |
| nameEnd: 370 |
| factory commentAroundAnnotation @444 |
| documentationComment: /// Comment 2. |
| metadata |
| Annotation |
| atSign: @ @405 |
| name: SimpleIdentifier |
| token: Object @406 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @412 |
| rightParenthesis: ) @413 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 405 |
| codeLength: 76 |
| periodOffset: 443 |
| nameEnd: 467 |
| ''', |
| withCodeRanges: true); |
| } |
| |
| test_codeRange_enum() async { |
| var library = await checkLibrary(''' |
| enum E { |
| aaa, bbb, ccc |
| } |
| '''); |
| checkElementText( |
| library, |
| r''' |
| library |
| definingUnit |
| enums |
| enum E @5 |
| codeOffset: 0 |
| codeLength: 26 |
| supertype: Enum |
| fields |
| static const enumConstant aaa @11 |
| codeOffset: 11 |
| codeLength: 3 |
| type: E |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: self::@enum::E::@constructor::• |
| staticType: null |
| staticElement: self::@enum::E::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| static const enumConstant bbb @16 |
| codeOffset: 16 |
| codeLength: 3 |
| type: E |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: self::@enum::E::@constructor::• |
| staticType: null |
| staticElement: self::@enum::E::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| static const enumConstant ccc @21 |
| codeOffset: 21 |
| codeLength: 3 |
| type: E |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: self::@enum::E::@constructor::• |
| staticType: null |
| staticElement: self::@enum::E::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: aaa @-1 |
| staticElement: self::@enum::E::@getter::aaa |
| staticType: E |
| SimpleIdentifier |
| token: bbb @-1 |
| staticElement: self::@enum::E::@getter::bbb |
| staticType: E |
| SimpleIdentifier |
| token: ccc @-1 |
| staticElement: self::@enum::E::@getter::ccc |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| constructors |
| synthetic const @-1 |
| accessors |
| synthetic static get aaa @-1 |
| returnType: E |
| synthetic static get bbb @-1 |
| returnType: E |
| synthetic static get ccc @-1 |
| returnType: E |
| synthetic static get values @-1 |
| returnType: List<E> |
| ''', |
| withCodeRanges: true); |
| } |
| |
| test_codeRange_extensions() async { |
| var library = await checkLibrary(''' |
| class A {} |
| |
| extension Raw on A {} |
| |
| /// Comment 1. |
| /// Comment 2. |
| extension HasDocComment on A {} |
| |
| @Object() |
| extension HasAnnotation on A {} |
| |
| @Object() |
| /// Comment 1. |
| /// Comment 2. |
| extension AnnotationThenComment on A {} |
| |
| /// Comment 1. |
| /// Comment 2. |
| @Object() |
| extension CommentThenAnnotation on A {} |
| |
| /// Comment 1. |
| @Object() |
| /// Comment 2. |
| extension CommentAroundAnnotation on A {} |
| '''); |
| checkElementText( |
| library, |
| r''' |
| library |
| definingUnit |
| classes |
| class A @6 |
| codeOffset: 0 |
| codeLength: 10 |
| constructors |
| synthetic @-1 |
| extensions |
| Raw @22 |
| codeOffset: 12 |
| codeLength: 21 |
| extendedType: A |
| HasDocComment @75 |
| documentationComment: /// Comment 1.\n/// Comment 2. |
| codeOffset: 35 |
| codeLength: 61 |
| extendedType: A |
| HasAnnotation @118 |
| metadata |
| Annotation |
| atSign: @ @98 |
| name: SimpleIdentifier |
| token: Object @99 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @105 |
| rightParenthesis: ) @106 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 98 |
| codeLength: 41 |
| extendedType: A |
| AnnotationThenComment @191 |
| documentationComment: /// Comment 1.\n/// Comment 2. |
| metadata |
| Annotation |
| atSign: @ @141 |
| name: SimpleIdentifier |
| token: Object @142 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @148 |
| rightParenthesis: ) @149 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 141 |
| codeLength: 79 |
| extendedType: A |
| CommentThenAnnotation @272 |
| documentationComment: /// Comment 1.\n/// Comment 2. |
| metadata |
| Annotation |
| atSign: @ @252 |
| name: SimpleIdentifier |
| token: Object @253 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @259 |
| rightParenthesis: ) @260 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 222 |
| codeLength: 79 |
| extendedType: A |
| CommentAroundAnnotation @353 |
| documentationComment: /// Comment 2. |
| metadata |
| Annotation |
| atSign: @ @318 |
| name: SimpleIdentifier |
| token: Object @319 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @325 |
| rightParenthesis: ) @326 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 318 |
| codeLength: 66 |
| extendedType: A |
| ''', |
| withCodeRanges: true); |
| } |
| |
| test_codeRange_field() async { |
| var library = await checkLibrary(''' |
| class C { |
| int withInit = 1; |
| |
| int withoutInit; |
| |
| int multiWithInit = 2, multiWithoutInit, multiWithInit2 = 3; |
| } |
| '''); |
| checkElementText( |
| library, |
| r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| codeOffset: 0 |
| codeLength: 115 |
| fields |
| withInit @16 |
| codeOffset: 12 |
| codeLength: 16 |
| type: int |
| withoutInit @37 |
| codeOffset: 33 |
| codeLength: 15 |
| type: int |
| multiWithInit @57 |
| codeOffset: 53 |
| codeLength: 21 |
| type: int |
| multiWithoutInit @76 |
| codeOffset: 76 |
| codeLength: 16 |
| type: int |
| multiWithInit2 @94 |
| codeOffset: 94 |
| codeLength: 18 |
| type: int |
| constructors |
| synthetic @-1 |
| accessors |
| synthetic get withInit @-1 |
| returnType: int |
| synthetic set withInit @-1 |
| parameters |
| requiredPositional _withInit @-1 |
| type: int |
| returnType: void |
| synthetic get withoutInit @-1 |
| returnType: int |
| synthetic set withoutInit @-1 |
| parameters |
| requiredPositional _withoutInit @-1 |
| type: int |
| returnType: void |
| synthetic get multiWithInit @-1 |
| returnType: int |
| synthetic set multiWithInit @-1 |
| parameters |
| requiredPositional _multiWithInit @-1 |
| type: int |
| returnType: void |
| synthetic get multiWithoutInit @-1 |
| returnType: int |
| synthetic set multiWithoutInit @-1 |
| parameters |
| requiredPositional _multiWithoutInit @-1 |
| type: int |
| returnType: void |
| synthetic get multiWithInit2 @-1 |
| returnType: int |
| synthetic set multiWithInit2 @-1 |
| parameters |
| requiredPositional _multiWithInit2 @-1 |
| type: int |
| returnType: void |
| ''', |
| withCodeRanges: true); |
| } |
| |
| test_codeRange_field_annotations() async { |
| var library = await checkLibrary(''' |
| class C { |
| /// Comment 1. |
| /// Comment 2. |
| int hasDocComment, hasDocComment2; |
| |
| @Object() |
| int hasAnnotation, hasAnnotation2; |
| |
| @Object() |
| /// Comment 1. |
| /// Comment 2. |
| int annotationThenComment, annotationThenComment2; |
| |
| /// Comment 1. |
| /// Comment 2. |
| @Object() |
| int commentThenAnnotation, commentThenAnnotation2; |
| |
| /// Comment 1. |
| @Object() |
| /// Comment 2. |
| int commentAroundAnnotation, commentAroundAnnotation2; |
| } |
| '''); |
| checkElementText( |
| library, |
| r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| codeOffset: 0 |
| codeLength: 436 |
| fields |
| hasDocComment @50 |
| documentationComment: /// Comment 1.\n/// Comment 2. |
| codeOffset: 12 |
| codeLength: 51 |
| type: int |
| hasDocComment2 @65 |
| documentationComment: /// Comment 1.\n/// Comment 2. |
| codeOffset: 65 |
| codeLength: 14 |
| type: int |
| hasAnnotation @100 |
| metadata |
| Annotation |
| atSign: @ @84 |
| name: SimpleIdentifier |
| token: Object @85 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @91 |
| rightParenthesis: ) @92 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 84 |
| codeLength: 29 |
| type: int |
| hasAnnotation2 @115 |
| metadata |
| Annotation |
| atSign: @ @84 |
| name: SimpleIdentifier |
| token: Object @85 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @91 |
| rightParenthesis: ) @92 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 115 |
| codeLength: 14 |
| type: int |
| annotationThenComment @184 |
| documentationComment: /// Comment 1.\n/// Comment 2. |
| metadata |
| Annotation |
| atSign: @ @134 |
| name: SimpleIdentifier |
| token: Object @135 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @141 |
| rightParenthesis: ) @142 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 134 |
| codeLength: 71 |
| type: int |
| annotationThenComment2 @207 |
| documentationComment: /// Comment 1.\n/// Comment 2. |
| metadata |
| Annotation |
| atSign: @ @134 |
| name: SimpleIdentifier |
| token: Object @135 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @141 |
| rightParenthesis: ) @142 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 207 |
| codeLength: 22 |
| type: int |
| commentThenAnnotation @284 |
| documentationComment: /// Comment 1.\n/// Comment 2. |
| metadata |
| Annotation |
| atSign: @ @268 |
| name: SimpleIdentifier |
| token: Object @269 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @275 |
| rightParenthesis: ) @276 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 234 |
| codeLength: 71 |
| type: int |
| commentThenAnnotation2 @307 |
| documentationComment: /// Comment 1.\n/// Comment 2. |
| metadata |
| Annotation |
| atSign: @ @268 |
| name: SimpleIdentifier |
| token: Object @269 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @275 |
| rightParenthesis: ) @276 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 307 |
| codeLength: 22 |
| type: int |
| commentAroundAnnotation @384 |
| documentationComment: /// Comment 2. |
| metadata |
| Annotation |
| atSign: @ @351 |
| name: SimpleIdentifier |
| token: Object @352 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @358 |
| rightParenthesis: ) @359 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 351 |
| codeLength: 56 |
| type: int |
| commentAroundAnnotation2 @409 |
| documentationComment: /// Comment 2. |
| metadata |
| Annotation |
| atSign: @ @351 |
| name: SimpleIdentifier |
| token: Object @352 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @358 |
| rightParenthesis: ) @359 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 409 |
| codeLength: 24 |
| type: int |
| constructors |
| synthetic @-1 |
| accessors |
| synthetic get hasDocComment @-1 |
| returnType: int |
| synthetic set hasDocComment @-1 |
| parameters |
| requiredPositional _hasDocComment @-1 |
| type: int |
| returnType: void |
| synthetic get hasDocComment2 @-1 |
| returnType: int |
| synthetic set hasDocComment2 @-1 |
| parameters |
| requiredPositional _hasDocComment2 @-1 |
| type: int |
| returnType: void |
| synthetic get hasAnnotation @-1 |
| returnType: int |
| synthetic set hasAnnotation @-1 |
| parameters |
| requiredPositional _hasAnnotation @-1 |
| type: int |
| returnType: void |
| synthetic get hasAnnotation2 @-1 |
| returnType: int |
| synthetic set hasAnnotation2 @-1 |
| parameters |
| requiredPositional _hasAnnotation2 @-1 |
| type: int |
| returnType: void |
| synthetic get annotationThenComment @-1 |
| returnType: int |
| synthetic set annotationThenComment @-1 |
| parameters |
| requiredPositional _annotationThenComment @-1 |
| type: int |
| returnType: void |
| synthetic get annotationThenComment2 @-1 |
| returnType: int |
| synthetic set annotationThenComment2 @-1 |
| parameters |
| requiredPositional _annotationThenComment2 @-1 |
| type: int |
| returnType: void |
| synthetic get commentThenAnnotation @-1 |
| returnType: int |
| synthetic set commentThenAnnotation @-1 |
| parameters |
| requiredPositional _commentThenAnnotation @-1 |
| type: int |
| returnType: void |
| synthetic get commentThenAnnotation2 @-1 |
| returnType: int |
| synthetic set commentThenAnnotation2 @-1 |
| parameters |
| requiredPositional _commentThenAnnotation2 @-1 |
| type: int |
| returnType: void |
| synthetic get commentAroundAnnotation @-1 |
| returnType: int |
| synthetic set commentAroundAnnotation @-1 |
| parameters |
| requiredPositional _commentAroundAnnotation @-1 |
| type: int |
| returnType: void |
| synthetic get commentAroundAnnotation2 @-1 |
| returnType: int |
| synthetic set commentAroundAnnotation2 @-1 |
| parameters |
| requiredPositional _commentAroundAnnotation2 @-1 |
| type: int |
| returnType: void |
| ''', |
| withCodeRanges: true); |
| } |
| |
| test_codeRange_function() async { |
| var library = await checkLibrary(''' |
| void raw() {} |
| |
| /// Comment 1. |
| /// Comment 2. |
| void hasDocComment() {} |
| |
| @Object() |
| void hasAnnotation() {} |
| |
| @Object() |
| /// Comment 1. |
| /// Comment 2. |
| void annotationThenComment() {} |
| |
| /// Comment 1. |
| /// Comment 2. |
| @Object() |
| void commentThenAnnotation() {} |
| |
| /// Comment 1. |
| @Object() |
| /// Comment 2. |
| void commentAroundAnnotation() {} |
| '''); |
| checkElementText( |
| library, |
| r''' |
| library |
| definingUnit |
| functions |
| raw @5 |
| codeOffset: 0 |
| codeLength: 13 |
| returnType: void |
| hasDocComment @50 |
| documentationComment: /// Comment 1.\n/// Comment 2. |
| codeOffset: 15 |
| codeLength: 53 |
| returnType: void |
| hasAnnotation @85 |
| metadata |
| Annotation |
| atSign: @ @70 |
| name: SimpleIdentifier |
| token: Object @71 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @77 |
| rightParenthesis: ) @78 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 70 |
| codeLength: 33 |
| returnType: void |
| annotationThenComment @150 |
| documentationComment: /// Comment 1.\n/// Comment 2. |
| metadata |
| Annotation |
| atSign: @ @105 |
| name: SimpleIdentifier |
| token: Object @106 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @112 |
| rightParenthesis: ) @113 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 105 |
| codeLength: 71 |
| returnType: void |
| commentThenAnnotation @223 |
| documentationComment: /// Comment 1.\n/// Comment 2. |
| metadata |
| Annotation |
| atSign: @ @208 |
| name: SimpleIdentifier |
| token: Object @209 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @215 |
| rightParenthesis: ) @216 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 178 |
| codeLength: 71 |
| returnType: void |
| commentAroundAnnotation @296 |
| documentationComment: /// Comment 2. |
| metadata |
| Annotation |
| atSign: @ @266 |
| name: SimpleIdentifier |
| token: Object @267 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @273 |
| rightParenthesis: ) @274 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 266 |
| codeLength: 58 |
| returnType: void |
| ''', |
| withCodeRanges: true); |
| } |
| |
| test_codeRange_functionTypeAlias() async { |
| var library = await checkLibrary(''' |
| typedef Raw(); |
| |
| /// Comment 1. |
| /// Comment 2. |
| typedef HasDocComment(); |
| |
| @Object() |
| typedef HasAnnotation(); |
| |
| @Object() |
| /// Comment 1. |
| /// Comment 2. |
| typedef AnnotationThenComment(); |
| |
| /// Comment 1. |
| /// Comment 2. |
| @Object() |
| typedef CommentThenAnnotation(); |
| |
| /// Comment 1. |
| @Object() |
| /// Comment 2. |
| typedef CommentAroundAnnotation(); |
| '''); |
| checkElementText( |
| library, |
| r''' |
| library |
| definingUnit |
| typeAliases |
| functionTypeAliasBased Raw @8 |
| codeOffset: 0 |
| codeLength: 14 |
| aliasedType: dynamic Function() |
| aliasedElement: GenericFunctionTypeElement |
| returnType: dynamic |
| functionTypeAliasBased HasDocComment @54 |
| documentationComment: /// Comment 1.\n/// Comment 2. |
| codeOffset: 16 |
| codeLength: 54 |
| aliasedType: dynamic Function() |
| aliasedElement: GenericFunctionTypeElement |
| returnType: dynamic |
| functionTypeAliasBased HasAnnotation @90 |
| metadata |
| Annotation |
| atSign: @ @72 |
| name: SimpleIdentifier |
| token: Object @73 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @79 |
| rightParenthesis: ) @80 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 72 |
| codeLength: 34 |
| aliasedType: dynamic Function() |
| aliasedElement: GenericFunctionTypeElement |
| returnType: dynamic |
| functionTypeAliasBased AnnotationThenComment @156 |
| documentationComment: /// Comment 1.\n/// Comment 2. |
| metadata |
| Annotation |
| atSign: @ @108 |
| name: SimpleIdentifier |
| token: Object @109 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @115 |
| rightParenthesis: ) @116 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 108 |
| codeLength: 72 |
| aliasedType: dynamic Function() |
| aliasedElement: GenericFunctionTypeElement |
| returnType: dynamic |
| functionTypeAliasBased CommentThenAnnotation @230 |
| documentationComment: /// Comment 1.\n/// Comment 2. |
| metadata |
| Annotation |
| atSign: @ @212 |
| name: SimpleIdentifier |
| token: Object @213 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @219 |
| rightParenthesis: ) @220 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 182 |
| codeLength: 72 |
| aliasedType: dynamic Function() |
| aliasedElement: GenericFunctionTypeElement |
| returnType: dynamic |
| functionTypeAliasBased CommentAroundAnnotation @304 |
| documentationComment: /// Comment 2. |
| metadata |
| Annotation |
| atSign: @ @271 |
| name: SimpleIdentifier |
| token: Object @272 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @278 |
| rightParenthesis: ) @279 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 271 |
| codeLength: 59 |
| aliasedType: dynamic Function() |
| aliasedElement: GenericFunctionTypeElement |
| returnType: dynamic |
| ''', |
| withCodeRanges: true); |
| } |
| |
| test_codeRange_genericTypeAlias() async { |
| var library = await checkLibrary(''' |
| typedef Raw = Function(); |
| |
| /// Comment 1. |
| /// Comment 2. |
| typedef HasDocComment = Function(); |
| |
| @Object() |
| typedef HasAnnotation = Function(); |
| |
| @Object() |
| /// Comment 1. |
| /// Comment 2. |
| typedef AnnotationThenComment = Function(); |
| |
| /// Comment 1. |
| /// Comment 2. |
| @Object() |
| typedef CommentThenAnnotation = Function(); |
| |
| /// Comment 1. |
| @Object() |
| /// Comment 2. |
| typedef CommentAroundAnnotation = Function(); |
| '''); |
| checkElementText( |
| library, |
| r''' |
| library |
| definingUnit |
| typeAliases |
| Raw @8 |
| codeOffset: 0 |
| codeLength: 25 |
| aliasedType: dynamic Function() |
| aliasedElement: GenericFunctionTypeElement |
| returnType: dynamic |
| HasDocComment @65 |
| documentationComment: /// Comment 1.\n/// Comment 2. |
| codeOffset: 27 |
| codeLength: 65 |
| aliasedType: dynamic Function() |
| aliasedElement: GenericFunctionTypeElement |
| returnType: dynamic |
| HasAnnotation @112 |
| metadata |
| Annotation |
| atSign: @ @94 |
| name: SimpleIdentifier |
| token: Object @95 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @101 |
| rightParenthesis: ) @102 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 94 |
| codeLength: 45 |
| aliasedType: dynamic Function() |
| aliasedElement: GenericFunctionTypeElement |
| returnType: dynamic |
| AnnotationThenComment @189 |
| documentationComment: /// Comment 1.\n/// Comment 2. |
| metadata |
| Annotation |
| atSign: @ @141 |
| name: SimpleIdentifier |
| token: Object @142 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @148 |
| rightParenthesis: ) @149 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 141 |
| codeLength: 83 |
| aliasedType: dynamic Function() |
| aliasedElement: GenericFunctionTypeElement |
| returnType: dynamic |
| CommentThenAnnotation @274 |
| documentationComment: /// Comment 1.\n/// Comment 2. |
| metadata |
| Annotation |
| atSign: @ @256 |
| name: SimpleIdentifier |
| token: Object @257 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @263 |
| rightParenthesis: ) @264 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 226 |
| codeLength: 83 |
| aliasedType: dynamic Function() |
| aliasedElement: GenericFunctionTypeElement |
| returnType: dynamic |
| CommentAroundAnnotation @359 |
| documentationComment: /// Comment 2. |
| metadata |
| Annotation |
| atSign: @ @326 |
| name: SimpleIdentifier |
| token: Object @327 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @333 |
| rightParenthesis: ) @334 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 326 |
| codeLength: 70 |
| aliasedType: dynamic Function() |
| aliasedElement: GenericFunctionTypeElement |
| returnType: dynamic |
| ''', |
| withCodeRanges: true); |
| } |
| |
| test_codeRange_method() async { |
| var library = await checkLibrary(''' |
| class C { |
| void raw() {} |
| |
| /// Comment 1. |
| /// Comment 2. |
| void hasDocComment() {} |
| |
| @Object() |
| void hasAnnotation() {} |
| |
| @Object() |
| /// Comment 1. |
| /// Comment 2. |
| void annotationThenComment() {} |
| |
| /// Comment 1. |
| /// Comment 2. |
| @Object() |
| void commentThenAnnotation() {} |
| |
| /// Comment 1. |
| @Object() |
| /// Comment 2. |
| void commentAroundAnnotation() {} |
| } |
| '''); |
| checkElementText( |
| library, |
| r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| codeOffset: 0 |
| codeLength: 372 |
| constructors |
| synthetic @-1 |
| methods |
| raw @17 |
| codeOffset: 12 |
| codeLength: 13 |
| returnType: void |
| hasDocComment @68 |
| documentationComment: /// Comment 1.\n/// Comment 2. |
| codeOffset: 29 |
| codeLength: 57 |
| returnType: void |
| hasAnnotation @107 |
| metadata |
| Annotation |
| atSign: @ @90 |
| name: SimpleIdentifier |
| token: Object @91 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @97 |
| rightParenthesis: ) @98 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 90 |
| codeLength: 35 |
| returnType: void |
| annotationThenComment @180 |
| documentationComment: /// Comment 1.\n/// Comment 2. |
| metadata |
| Annotation |
| atSign: @ @129 |
| name: SimpleIdentifier |
| token: Object @130 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @136 |
| rightParenthesis: ) @137 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 129 |
| codeLength: 77 |
| returnType: void |
| commentThenAnnotation @261 |
| documentationComment: /// Comment 1.\n/// Comment 2. |
| metadata |
| Annotation |
| atSign: @ @244 |
| name: SimpleIdentifier |
| token: Object @245 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @251 |
| rightParenthesis: ) @252 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 210 |
| codeLength: 77 |
| returnType: void |
| commentAroundAnnotation @342 |
| documentationComment: /// Comment 2. |
| metadata |
| Annotation |
| atSign: @ @308 |
| name: SimpleIdentifier |
| token: Object @309 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @315 |
| rightParenthesis: ) @316 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 308 |
| codeLength: 62 |
| returnType: void |
| ''', |
| withCodeRanges: true); |
| } |
| |
| test_codeRange_parameter() async { |
| var library = await checkLibrary(''' |
| main({int a = 1, int b, int c = 2}) {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| functions |
| main @0 |
| parameters |
| optionalNamed a @10 |
| type: int |
| constantInitializer |
| IntegerLiteral |
| literal: 1 @14 |
| staticType: int |
| optionalNamed b @21 |
| type: int |
| optionalNamed c @28 |
| type: int |
| constantInitializer |
| IntegerLiteral |
| literal: 2 @32 |
| staticType: int |
| returnType: dynamic |
| '''); |
| } |
| |
| test_codeRange_parameter_annotations() async { |
| var library = await checkLibrary(''' |
| main(@Object() int a, int b, @Object() int c) {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| functions |
| main @0 |
| parameters |
| requiredPositional a @19 |
| type: int |
| metadata |
| Annotation |
| atSign: @ @5 |
| name: SimpleIdentifier |
| token: Object @6 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @12 |
| rightParenthesis: ) @13 |
| element: dart:core::@class::Object::@constructor::• |
| requiredPositional b @26 |
| type: int |
| requiredPositional c @43 |
| type: int |
| metadata |
| Annotation |
| atSign: @ @29 |
| name: SimpleIdentifier |
| token: Object @30 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @36 |
| rightParenthesis: ) @37 |
| element: dart:core::@class::Object::@constructor::• |
| returnType: dynamic |
| '''); |
| } |
| |
| test_codeRange_topLevelVariable() async { |
| var library = await checkLibrary(''' |
| int withInit = 1 + 2 * 3; |
| |
| int withoutInit; |
| |
| int multiWithInit = 2, multiWithoutInit, multiWithInit2 = 3; |
| '''); |
| checkElementText( |
| library, |
| r''' |
| library |
| definingUnit |
| topLevelVariables |
| static withInit @4 |
| codeOffset: 0 |
| codeLength: 24 |
| type: int |
| static withoutInit @31 |
| codeOffset: 27 |
| codeLength: 15 |
| type: int |
| static multiWithInit @49 |
| codeOffset: 45 |
| codeLength: 21 |
| type: int |
| static multiWithoutInit @68 |
| codeOffset: 68 |
| codeLength: 16 |
| type: int |
| static multiWithInit2 @86 |
| codeOffset: 86 |
| codeLength: 18 |
| type: int |
| accessors |
| synthetic static get withInit @-1 |
| returnType: int |
| synthetic static set withInit @-1 |
| parameters |
| requiredPositional _withInit @-1 |
| type: int |
| returnType: void |
| synthetic static get withoutInit @-1 |
| returnType: int |
| synthetic static set withoutInit @-1 |
| parameters |
| requiredPositional _withoutInit @-1 |
| type: int |
| returnType: void |
| synthetic static get multiWithInit @-1 |
| returnType: int |
| synthetic static set multiWithInit @-1 |
| parameters |
| requiredPositional _multiWithInit @-1 |
| type: int |
| returnType: void |
| synthetic static get multiWithoutInit @-1 |
| returnType: int |
| synthetic static set multiWithoutInit @-1 |
| parameters |
| requiredPositional _multiWithoutInit @-1 |
| type: int |
| returnType: void |
| synthetic static get multiWithInit2 @-1 |
| returnType: int |
| synthetic static set multiWithInit2 @-1 |
| parameters |
| requiredPositional _multiWithInit2 @-1 |
| type: int |
| returnType: void |
| ''', |
| withCodeRanges: true); |
| } |
| |
| test_codeRange_topLevelVariable_annotations() async { |
| var library = await checkLibrary(''' |
| /// Comment 1. |
| /// Comment 2. |
| int hasDocComment, hasDocComment2; |
| |
| @Object() |
| int hasAnnotation, hasAnnotation2; |
| |
| @Object() |
| /// Comment 1. |
| /// Comment 2. |
| int annotationThenComment, annotationThenComment2; |
| |
| /// Comment 1. |
| /// Comment 2. |
| @Object() |
| int commentThenAnnotation, commentThenAnnotation2; |
| |
| /// Comment 1. |
| @Object() |
| /// Comment 2. |
| int commentAroundAnnotation, commentAroundAnnotation2; |
| '''); |
| checkElementText( |
| library, |
| r''' |
| library |
| definingUnit |
| topLevelVariables |
| static hasDocComment @34 |
| documentationComment: /// Comment 1.\n/// Comment 2. |
| codeOffset: 0 |
| codeLength: 47 |
| type: int |
| static hasDocComment2 @49 |
| documentationComment: /// Comment 1.\n/// Comment 2. |
| codeOffset: 49 |
| codeLength: 14 |
| type: int |
| static hasAnnotation @80 |
| metadata |
| Annotation |
| atSign: @ @66 |
| name: SimpleIdentifier |
| token: Object @67 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @73 |
| rightParenthesis: ) @74 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 66 |
| codeLength: 27 |
| type: int |
| static hasAnnotation2 @95 |
| metadata |
| Annotation |
| atSign: @ @66 |
| name: SimpleIdentifier |
| token: Object @67 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @73 |
| rightParenthesis: ) @74 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 95 |
| codeLength: 14 |
| type: int |
| static annotationThenComment @156 |
| documentationComment: /// Comment 1.\n/// Comment 2. |
| metadata |
| Annotation |
| atSign: @ @112 |
| name: SimpleIdentifier |
| token: Object @113 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @119 |
| rightParenthesis: ) @120 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 112 |
| codeLength: 65 |
| type: int |
| static annotationThenComment2 @179 |
| documentationComment: /// Comment 1.\n/// Comment 2. |
| metadata |
| Annotation |
| atSign: @ @112 |
| name: SimpleIdentifier |
| token: Object @113 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @119 |
| rightParenthesis: ) @120 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 179 |
| codeLength: 22 |
| type: int |
| static commentThenAnnotation @248 |
| documentationComment: /// Comment 1.\n/// Comment 2. |
| metadata |
| Annotation |
| atSign: @ @234 |
| name: SimpleIdentifier |
| token: Object @235 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @241 |
| rightParenthesis: ) @242 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 204 |
| codeLength: 65 |
| type: int |
| static commentThenAnnotation2 @271 |
| documentationComment: /// Comment 1.\n/// Comment 2. |
| metadata |
| Annotation |
| atSign: @ @234 |
| name: SimpleIdentifier |
| token: Object @235 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @241 |
| rightParenthesis: ) @242 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 271 |
| codeLength: 22 |
| type: int |
| static commentAroundAnnotation @340 |
| documentationComment: /// Comment 2. |
| metadata |
| Annotation |
| atSign: @ @311 |
| name: SimpleIdentifier |
| token: Object @312 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @318 |
| rightParenthesis: ) @319 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 311 |
| codeLength: 52 |
| type: int |
| static commentAroundAnnotation2 @365 |
| documentationComment: /// Comment 2. |
| metadata |
| Annotation |
| atSign: @ @311 |
| name: SimpleIdentifier |
| token: Object @312 |
| staticElement: dart:core::@class::Object |
| staticType: null |
| arguments: ArgumentList |
| leftParenthesis: ( @318 |
| rightParenthesis: ) @319 |
| element: dart:core::@class::Object::@constructor::• |
| codeOffset: 365 |
| codeLength: 24 |
| type: int |
| accessors |
| synthetic static get hasDocComment @-1 |
| returnType: int |
| synthetic static set hasDocComment @-1 |
| parameters |
| requiredPositional _hasDocComment @-1 |
| type: int |
| returnType: void |
| synthetic static get hasDocComment2 @-1 |
| returnType: int |
| synthetic static set hasDocComment2 @-1 |
| parameters |
| requiredPositional _hasDocComment2 @-1 |
| type: int |
| returnType: void |
| synthetic static get hasAnnotation @-1 |
| returnType: int |
| synthetic static set hasAnnotation @-1 |
| parameters |
| requiredPositional _hasAnnotation @-1 |
| type: int |
| returnType: void |
| synthetic static get hasAnnotation2 @-1 |
| returnType: int |
| synthetic static set hasAnnotation2 @-1 |
| parameters |
| requiredPositional _hasAnnotation2 @-1 |
| type: int |
| returnType: void |
| synthetic static get annotationThenComment @-1 |
| returnType: int |
| synthetic static set annotationThenComment @-1 |
| parameters |
| requiredPositional _annotationThenComment @-1 |
| type: int |
| returnType: void |
| synthetic static get annotationThenComment2 @-1 |
| returnType: int |
| synthetic static set annotationThenComment2 @-1 |
| parameters |
| requiredPositional _annotationThenComment2 @-1 |
| type: int |
| returnType: void |
| synthetic static get commentThenAnnotation @-1 |
| returnType: int |
| synthetic static set commentThenAnnotation @-1 |
| parameters |
| requiredPositional _commentThenAnnotation @-1 |
| type: int |
| returnType: void |
| synthetic static get commentThenAnnotation2 @-1 |
| returnType: int |
| synthetic static set commentThenAnnotation2 @-1 |
| parameters |
| requiredPositional _commentThenAnnotation2 @-1 |
| type: int |
| returnType: void |
| synthetic static get commentAroundAnnotation @-1 |
| returnType: int |
| synthetic static set commentAroundAnnotation @-1 |
| parameters |
| requiredPositional _commentAroundAnnotation @-1 |
| type: int |
| returnType: void |
| synthetic static get commentAroundAnnotation2 @-1 |
| returnType: int |
| synthetic static set commentAroundAnnotation2 @-1 |
| parameters |
| requiredPositional _commentAroundAnnotation2 @-1 |
| type: int |
| returnType: void |
| ''', |
| withCodeRanges: true); |
| } |
| |
| test_codeRange_type_parameter() async { |
| var library = await checkLibrary(''' |
| class A<T> {} |
| void f<U extends num> {} |
| '''); |
| checkElementText( |
| library, |
| r''' |
| library |
| definingUnit |
| classes |
| class A @6 |
| codeOffset: 0 |
| codeLength: 13 |
| typeParameters |
| covariant T @8 |
| codeOffset: 8 |
| codeLength: 1 |
| defaultType: dynamic |
| constructors |
| synthetic @-1 |
| functions |
| f @19 |
| codeOffset: 14 |
| codeLength: 24 |
| typeParameters |
| covariant U @21 |
| codeOffset: 21 |
| codeLength: 13 |
| bound: num |
| returnType: void |
| ''', |
| withCodeRanges: true); |
| } |
| |
| test_compilationUnit_nnbd_disabled_via_dart_directive() async { |
| var library = await checkLibrary(''' |
| // @dart=2.2 |
| '''); |
| expect(library.isNonNullableByDefault, isFalse); |
| } |
| |
| test_compilationUnit_nnbd_disabled_via_feature_set() async { |
| featureSet = FeatureSets.language_2_9; |
| var library = await checkLibrary(''); |
| expect(library.isNonNullableByDefault, isFalse); |
| } |
| |
| test_compilationUnit_nnbd_enabled() async { |
| var library = await checkLibrary(''); |
| expect(library.isNonNullableByDefault, isTrue); |
| } |
| |
| test_const_asExpression() async { |
| var library = await checkLibrary(''' |
| const num a = 0; |
| const b = a as int; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const a @10 |
| type: num |
| constantInitializer |
| IntegerLiteral |
| literal: 0 @14 |
| staticType: int |
| static const b @23 |
| type: int |
| constantInitializer |
| AsExpression |
| expression: SimpleIdentifier |
| token: a @27 |
| staticElement: self::@getter::a |
| staticType: num |
| asOperator: as @29 |
| type: NamedType |
| name: SimpleIdentifier |
| token: int @32 |
| staticElement: dart:core::@class::int |
| staticType: null |
| type: int |
| staticType: int |
| accessors |
| synthetic static get a @-1 |
| returnType: num |
| synthetic static get b @-1 |
| returnType: int |
| '''); |
| } |
| |
| test_const_assignmentExpression() async { |
| var library = await checkLibrary(r''' |
| const a = 0; |
| const b = (a += 1); |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const a @6 |
| type: int |
| constantInitializer |
| IntegerLiteral |
| literal: 0 @10 |
| staticType: int |
| static const b @19 |
| type: int |
| constantInitializer |
| ParenthesizedExpression |
| leftParenthesis: ( @23 |
| expression: AssignmentExpression |
| leftHandSide: SimpleIdentifier |
| token: a @24 |
| staticElement: <null> |
| staticType: null |
| operator: += @26 |
| rightHandSide: IntegerLiteral |
| literal: 1 @29 |
| staticType: int |
| readElement: self::@getter::a |
| readType: int |
| writeElement: self::@getter::a |
| writeType: dynamic |
| staticElement: dart:core::@class::num::@method::+ |
| staticType: int |
| rightParenthesis: ) @30 |
| staticType: int |
| accessors |
| synthetic static get a @-1 |
| returnType: int |
| synthetic static get b @-1 |
| returnType: int |
| '''); |
| } |
| |
| test_const_cascadeExpression() async { |
| var library = await checkLibrary(r''' |
| const a = 0..isEven..abs(); |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const a @6 |
| type: int |
| constantInitializer |
| CascadeExpression |
| target: IntegerLiteral |
| literal: 0 @10 |
| staticType: int |
| cascadeSections |
| PropertyAccess |
| operator: .. @11 |
| propertyName: SimpleIdentifier |
| token: isEven @13 |
| staticElement: dart:core::@class::int::@getter::isEven |
| staticType: bool |
| staticType: bool |
| MethodInvocation |
| operator: .. @19 |
| methodName: SimpleIdentifier |
| token: abs @21 |
| staticElement: dart:core::@class::int::@method::abs |
| staticType: int Function() |
| argumentList: ArgumentList |
| leftParenthesis: ( @24 |
| rightParenthesis: ) @25 |
| staticInvokeType: int Function() |
| staticType: int |
| staticType: int |
| accessors |
| synthetic static get a @-1 |
| returnType: int |
| '''); |
| } |
| |
| test_const_classField() async { |
| var library = await checkLibrary(r''' |
| class C { |
| static const int f1 = 1; |
| static const int f2 = C.f1, f3 = C.f2; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| static const f1 @29 |
| type: int |
| constantInitializer |
| IntegerLiteral |
| literal: 1 @34 |
| staticType: int |
| static const f2 @56 |
| type: int |
| constantInitializer |
| PrefixedIdentifier |
| prefix: SimpleIdentifier |
| token: C @61 |
| staticElement: self::@class::C |
| staticType: null |
| period: . @62 |
| identifier: SimpleIdentifier |
| token: f1 @63 |
| staticElement: self::@class::C::@getter::f1 |
| staticType: int |
| staticElement: self::@class::C::@getter::f1 |
| staticType: int |
| static const f3 @67 |
| type: int |
| constantInitializer |
| PrefixedIdentifier |
| prefix: SimpleIdentifier |
| token: C @72 |
| staticElement: self::@class::C |
| staticType: null |
| period: . @73 |
| identifier: SimpleIdentifier |
| token: f2 @74 |
| staticElement: self::@class::C::@getter::f2 |
| staticType: int |
| staticElement: self::@class::C::@getter::f2 |
| staticType: int |
| constructors |
| synthetic @-1 |
| accessors |
| synthetic static get f1 @-1 |
| returnType: int |
| synthetic static get f2 @-1 |
| returnType: int |
| synthetic static get f3 @-1 |
| returnType: int |
| '''); |
| } |
| |
| test_const_constructor_inferred_args() async { |
| var library = await checkLibrary(''' |
| class C<T> { |
| final T t; |
| const C(this.t); |
| const C.named(this.t); |
| } |
| const Object x = const C(0); |
| const Object y = const C.named(0); |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| typeParameters |
| covariant T @8 |
| defaultType: dynamic |
| fields |
| final t @23 |
| type: T |
| constructors |
| const @34 |
| parameters |
| requiredPositional final this.t @41 |
| type: T |
| field: self::@class::C::@field::t |
| const named @55 |
| periodOffset: 54 |
| nameEnd: 60 |
| parameters |
| requiredPositional final this.t @66 |
| type: T |
| field: self::@class::C::@field::t |
| accessors |
| synthetic get t @-1 |
| returnType: T |
| topLevelVariables |
| static const x @85 |
| type: Object |
| constantInitializer |
| InstanceCreationExpression |
| keyword: const @89 |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: C @95 |
| staticElement: self::@class::C |
| staticType: null |
| type: C<int> |
| staticElement: ConstructorMember |
| base: self::@class::C::@constructor::• |
| substitution: {T: int} |
| argumentList: ArgumentList |
| leftParenthesis: ( @96 |
| arguments |
| IntegerLiteral |
| literal: 0 @97 |
| staticType: int |
| rightParenthesis: ) @98 |
| staticType: C<int> |
| static const y @114 |
| type: Object |
| constantInitializer |
| InstanceCreationExpression |
| keyword: const @118 |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: C @124 |
| staticElement: self::@class::C |
| staticType: null |
| type: C<int> |
| period: . @125 |
| name: SimpleIdentifier |
| token: named @126 |
| staticElement: ConstructorMember |
| base: self::@class::C::@constructor::named |
| substitution: {T: dynamic} |
| staticType: null |
| staticElement: ConstructorMember |
| base: self::@class::C::@constructor::named |
| substitution: {T: int} |
| argumentList: ArgumentList |
| leftParenthesis: ( @131 |
| arguments |
| IntegerLiteral |
| literal: 0 @132 |
| staticType: int |
| rightParenthesis: ) @133 |
| staticType: C<int> |
| accessors |
| synthetic static get x @-1 |
| returnType: Object |
| synthetic static get y @-1 |
| returnType: Object |
| '''); |
| var x = library.definingCompilationUnit.topLevelVariables[0] |
| as TopLevelVariableElementImpl; |
| var xExpr = x.constantInitializer as InstanceCreationExpression; |
| var xType = xExpr.constructorName.staticElement!.returnType; |
| _assertTypeStr( |
| xType, |
| 'C<int>', |
| ); |
| var y = library.definingCompilationUnit.topLevelVariables[0] |
| as TopLevelVariableElementImpl; |
| var yExpr = y.constantInitializer as InstanceCreationExpression; |
| var yType = yExpr.constructorName.staticElement!.returnType; |
| _assertTypeStr(yType, 'C<int>'); |
| } |
| |
| test_const_constructorReference() async { |
| var library = await checkLibrary(r''' |
| class A { |
| A.named(); |
| } |
| const v = A.named; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class A @6 |
| constructors |
| named @14 |
| periodOffset: 13 |
| nameEnd: 19 |
| topLevelVariables |
| static const v @31 |
| type: A Function() |
| constantInitializer |
| ConstructorReference |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: A @35 |
| staticElement: self::@class::A |
| staticType: null |
| type: null |
| period: . @36 |
| name: SimpleIdentifier |
| token: named @37 |
| staticElement: self::@class::A::@constructor::named |
| staticType: null |
| staticElement: self::@class::A::@constructor::named |
| staticType: A Function() |
| accessors |
| synthetic static get v @-1 |
| returnType: A Function() |
| '''); |
| } |
| |
| test_const_finalField_hasConstConstructor() async { |
| var library = await checkLibrary(r''' |
| class C { |
| final int f = 42; |
| const C(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| final f @22 |
| type: int |
| constantInitializer |
| IntegerLiteral |
| literal: 42 @26 |
| staticType: int |
| constructors |
| const @38 |
| accessors |
| synthetic get f @-1 |
| returnType: int |
| '''); |
| } |
| |
| test_const_functionExpression_typeArgumentTypes() async { |
| var library = await checkLibrary(''' |
| void f<T>(T a) {} |
| |
| const void Function(int) v = f; |
| '''); |
| checkElementText(library, ''' |
| library |
| definingUnit |
| topLevelVariables |
| static const v @44 |
| type: void Function(int) |
| constantInitializer |
| FunctionReference |
| function: SimpleIdentifier |
| token: f @48 |
| staticElement: self::@function::f |
| staticType: void Function<T>(T) |
| staticType: void Function(int) |
| typeArgumentTypes |
| int |
| accessors |
| synthetic static get v @-1 |
| returnType: void Function(int) |
| functions |
| f @5 |
| typeParameters |
| covariant T @7 |
| parameters |
| requiredPositional a @12 |
| type: T |
| returnType: void |
| '''); |
| } |
| |
| test_const_functionReference() async { |
| var library = await checkLibrary(r''' |
| void f<T>(T a) {} |
| const v = f<int>; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const v @24 |
| type: void Function(int) |
| constantInitializer |
| FunctionReference |
| function: SimpleIdentifier |
| token: f @28 |
| staticElement: self::@function::f |
| staticType: void Function<T>(T) |
| typeArguments: TypeArgumentList |
| leftBracket: < @29 |
| arguments |
| NamedType |
| name: SimpleIdentifier |
| token: int @30 |
| staticElement: dart:core::@class::int |
| staticType: null |
| type: int |
| rightBracket: > @33 |
| staticType: void Function(int) |
| typeArgumentTypes |
| int |
| accessors |
| synthetic static get v @-1 |
| returnType: void Function(int) |
| functions |
| f @5 |
| typeParameters |
| covariant T @7 |
| parameters |
| requiredPositional a @12 |
| type: T |
| returnType: void |
| '''); |
| } |
| |
| test_const_indexExpression() async { |
| var library = await checkLibrary(r''' |
| const a = [0]; |
| const b = 0; |
| const c = a[b]; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const a @6 |
| type: List<int> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @10 |
| elements |
| IntegerLiteral |
| literal: 0 @11 |
| staticType: int |
| rightBracket: ] @12 |
| staticType: List<int> |
| static const b @21 |
| type: int |
| constantInitializer |
| IntegerLiteral |
| literal: 0 @25 |
| staticType: int |
| static const c @34 |
| type: int |
| constantInitializer |
| IndexExpression |
| target: SimpleIdentifier |
| token: a @38 |
| staticElement: self::@getter::a |
| staticType: List<int> |
| leftBracket: [ @39 |
| index: SimpleIdentifier |
| token: b @40 |
| staticElement: self::@getter::b |
| staticType: int |
| rightBracket: ] @41 |
| staticElement: MethodMember |
| base: dart:core::@class::List::@method::[] |
| substitution: {E: int} |
| staticType: int |
| accessors |
| synthetic static get a @-1 |
| returnType: List<int> |
| synthetic static get b @-1 |
| returnType: int |
| synthetic static get c @-1 |
| returnType: int |
| '''); |
| } |
| |
| test_const_inference_downward_list() async { |
| var library = await checkLibrary(''' |
| class P<T> { |
| const P(); |
| } |
| |
| class P1<T> extends P<T> { |
| const P1(); |
| } |
| |
| class P2<T> extends P<T> { |
| const P2(); |
| } |
| |
| const List<P> values = [ |
| P1(), |
| P2<int>(), |
| ]; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class P @6 |
| typeParameters |
| covariant T @8 |
| defaultType: dynamic |
| constructors |
| const @21 |
| class P1 @35 |
| typeParameters |
| covariant T @38 |
| defaultType: dynamic |
| supertype: P<T> |
| constructors |
| const @64 |
| superConstructor: ConstructorMember |
| base: self::@class::P::@constructor::• |
| substitution: {T: T} |
| class P2 @79 |
| typeParameters |
| covariant T @82 |
| defaultType: dynamic |
| supertype: P<T> |
| constructors |
| const @108 |
| superConstructor: ConstructorMember |
| base: self::@class::P::@constructor::• |
| substitution: {T: T} |
| topLevelVariables |
| static const values @131 |
| type: List<P<dynamic>> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @140 |
| elements |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: P1 @144 |
| staticElement: self::@class::P1 |
| staticType: null |
| type: P1<dynamic> |
| staticElement: ConstructorMember |
| base: self::@class::P1::@constructor::• |
| substitution: {T: dynamic} |
| argumentList: ArgumentList |
| leftParenthesis: ( @146 |
| rightParenthesis: ) @147 |
| staticType: P1<dynamic> |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: P2 @152 |
| staticElement: self::@class::P2 |
| staticType: null |
| typeArguments: TypeArgumentList |
| leftBracket: < @154 |
| arguments |
| NamedType |
| name: SimpleIdentifier |
| token: int @155 |
| staticElement: dart:core::@class::int |
| staticType: null |
| type: int |
| rightBracket: > @158 |
| type: P2<int> |
| staticElement: ConstructorMember |
| base: self::@class::P2::@constructor::• |
| substitution: {T: int} |
| argumentList: ArgumentList |
| leftParenthesis: ( @159 |
| rightParenthesis: ) @160 |
| staticType: P2<int> |
| rightBracket: ] @163 |
| staticType: List<P<dynamic>> |
| accessors |
| synthetic static get values @-1 |
| returnType: List<P<dynamic>> |
| '''); |
| } |
| |
| test_const_invalid_field_const() async { |
| var library = await checkLibrary(r''' |
| class C { |
| static const f = 1 + foo(); |
| } |
| int foo() => 42; |
| ''', allowErrors: true); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| static const f @25 |
| type: int |
| constantInitializer |
| BinaryExpression |
| leftOperand: IntegerLiteral |
| literal: 1 @29 |
| staticType: int |
| operator: + @31 |
| rightOperand: MethodInvocation |
| methodName: SimpleIdentifier |
| token: foo @33 |
| staticElement: self::@function::foo |
| staticType: int Function() |
| argumentList: ArgumentList |
| leftParenthesis: ( @36 |
| rightParenthesis: ) @37 |
| staticInvokeType: int Function() |
| staticType: int |
| staticElement: dart:core::@class::num::@method::+ |
| staticInvokeType: num Function(num) |
| staticType: int |
| constructors |
| synthetic @-1 |
| accessors |
| synthetic static get f @-1 |
| returnType: int |
| functions |
| foo @46 |
| returnType: int |
| '''); |
| } |
| |
| test_const_invalid_field_final() async { |
| var library = await checkLibrary(r''' |
| class C { |
| final f = 1 + foo(); |
| } |
| int foo() => 42; |
| ''', allowErrors: true); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| final f @18 |
| type: int |
| constructors |
| synthetic @-1 |
| accessors |
| synthetic get f @-1 |
| returnType: int |
| functions |
| foo @39 |
| returnType: int |
| '''); |
| } |
| |
| test_const_invalid_functionExpression() async { |
| var library = await checkLibrary(''' |
| const v = () { return 0; }; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const v @6 |
| type: int Function() |
| constantInitializer |
| FunctionExpression |
| parameters: FormalParameterList |
| leftParenthesis: ( @10 |
| rightParenthesis: ) @0 |
| body: BlockFunctionBody |
| block: Block |
| leftBracket: { @0 |
| rightBracket: } @25 |
| declaredElement: <null> |
| staticType: null |
| accessors |
| synthetic static get v @-1 |
| returnType: int Function() |
| '''); |
| } |
| |
| test_const_invalid_functionExpression_nested() async { |
| var library = await checkLibrary(''' |
| const v = () { return 0; } + 2; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const v @6 |
| type: dynamic |
| constantInitializer |
| BinaryExpression |
| leftOperand: FunctionExpression |
| parameters: FormalParameterList |
| leftParenthesis: ( @10 |
| rightParenthesis: ) @0 |
| body: BlockFunctionBody |
| block: Block |
| leftBracket: { @0 |
| rightBracket: } @25 |
| declaredElement: <null> |
| staticType: null |
| operator: + @27 |
| rightOperand: IntegerLiteral |
| literal: 2 @29 |
| staticType: int |
| staticElement: <null> |
| staticInvokeType: null |
| staticType: dynamic |
| accessors |
| synthetic static get v @-1 |
| returnType: dynamic |
| '''); |
| } |
| |
| @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/44522') |
| test_const_invalid_intLiteral() async { |
| var library = await checkLibrary(r''' |
| const int x = 0x; |
| ''', allowErrors: true); |
| checkElementText(library, r''' |
| const int x = 0; |
| '''); |
| } |
| |
| test_const_invalid_topLevel() async { |
| var library = await checkLibrary(r''' |
| const v = 1 + foo(); |
| int foo() => 42; |
| ''', allowErrors: true); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const v @6 |
| type: int |
| constantInitializer |
| BinaryExpression |
| leftOperand: IntegerLiteral |
| literal: 1 @10 |
| staticType: int |
| operator: + @12 |
| rightOperand: MethodInvocation |
| methodName: SimpleIdentifier |
| token: foo @14 |
| staticElement: self::@function::foo |
| staticType: int Function() |
| argumentList: ArgumentList |
| leftParenthesis: ( @17 |
| rightParenthesis: ) @18 |
| staticInvokeType: int Function() |
| staticType: int |
| staticElement: dart:core::@class::num::@method::+ |
| staticInvokeType: num Function(num) |
| staticType: int |
| accessors |
| synthetic static get v @-1 |
| returnType: int |
| functions |
| foo @25 |
| returnType: int |
| '''); |
| } |
| |
| test_const_invalid_typeMismatch() async { |
| var library = await checkLibrary(r''' |
| const int a = 0; |
| const bool b = a + 5; |
| ''', allowErrors: true); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const a @10 |
| type: int |
| constantInitializer |
| IntegerLiteral |
| literal: 0 @14 |
| staticType: int |
| static const b @28 |
| type: bool |
| constantInitializer |
| BinaryExpression |
| leftOperand: SimpleIdentifier |
| token: a @32 |
| staticElement: self::@getter::a |
| staticType: int |
| operator: + @34 |
| rightOperand: IntegerLiteral |
| literal: 5 @36 |
| staticType: int |
| staticElement: dart:core::@class::num::@method::+ |
| staticInvokeType: num Function(num) |
| staticType: int |
| accessors |
| synthetic static get a @-1 |
| returnType: int |
| synthetic static get b @-1 |
| returnType: bool |
| '''); |
| } |
| |
| test_const_invokeConstructor_generic_named() async { |
| var library = await checkLibrary(r''' |
| class C<K, V> { |
| const C.named(K k, V v); |
| } |
| const V = const C<int, String>.named(1, '222'); |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| typeParameters |
| covariant K @8 |
| defaultType: dynamic |
| covariant V @11 |
| defaultType: dynamic |
| constructors |
| const named @26 |
| periodOffset: 25 |
| nameEnd: 31 |
| parameters |
| requiredPositional k @34 |
| type: K |
| requiredPositional v @39 |
| type: V |
| topLevelVariables |
| static const V @51 |
| type: C<int, String> |
| constantInitializer |
| InstanceCreationExpression |
| keyword: const @55 |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: C @61 |
| staticElement: self::@class::C |
| staticType: null |
| typeArguments: TypeArgumentList |
| leftBracket: < @62 |
| arguments |
| NamedType |
| name: SimpleIdentifier |
| token: int @63 |
| staticElement: dart:core::@class::int |
| staticType: null |
| type: int |
| NamedType |
| name: SimpleIdentifier |
| token: String @68 |
| staticElement: dart:core::@class::String |
| staticType: null |
| type: String |
| rightBracket: > @74 |
| type: C<int, String> |
| period: . @75 |
| name: SimpleIdentifier |
| token: named @76 |
| staticElement: ConstructorMember |
| base: self::@class::C::@constructor::named |
| substitution: {K: int, V: String} |
| staticType: null |
| staticElement: ConstructorMember |
| base: self::@class::C::@constructor::named |
| substitution: {K: int, V: String} |
| argumentList: ArgumentList |
| leftParenthesis: ( @81 |
| arguments |
| IntegerLiteral |
| literal: 1 @82 |
| staticType: int |
| SimpleStringLiteral |
| literal: '222' @85 |
| rightParenthesis: ) @90 |
| staticType: C<int, String> |
| accessors |
| synthetic static get V @-1 |
| returnType: C<int, String> |
| '''); |
| } |
| |
| test_const_invokeConstructor_generic_named_imported() async { |
| addLibrarySource('/a.dart', r''' |
| class C<K, V> { |
| const C.named(K k, V v); |
| } |
| '''); |
| var library = await checkLibrary(r''' |
| import 'a.dart'; |
| const V = const C<int, String>.named(1, '222'); |
| '''); |
| checkElementText(library, r''' |
| library |
| imports |
| a.dart |
| definingUnit |
| topLevelVariables |
| static const V @23 |
| type: C<int, String> |
| constantInitializer |
| InstanceCreationExpression |
| keyword: const @27 |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: C @33 |
| staticElement: a.dart::@class::C |
| staticType: null |
| typeArguments: TypeArgumentList |
| leftBracket: < @34 |
| arguments |
| NamedType |
| name: SimpleIdentifier |
| token: int @35 |
| staticElement: dart:core::@class::int |
| staticType: null |
| type: int |
| NamedType |
| name: SimpleIdentifier |
| token: String @40 |
| staticElement: dart:core::@class::String |
| staticType: null |
| type: String |
| rightBracket: > @46 |
| type: C<int, String> |
| period: . @47 |
| name: SimpleIdentifier |
| token: named @48 |
| staticElement: ConstructorMember |
| base: a.dart::@class::C::@constructor::named |
| substitution: {K: int, V: String} |
| staticType: null |
| staticElement: ConstructorMember |
| base: a.dart::@class::C::@constructor::named |
| substitution: {K: int, V: String} |
| argumentList: ArgumentList |
| leftParenthesis: ( @53 |
| arguments |
| IntegerLiteral |
| literal: 1 @54 |
| staticType: int |
| SimpleStringLiteral |
| literal: '222' @57 |
| rightParenthesis: ) @62 |
| staticType: C<int, String> |
| accessors |
| synthetic static get V @-1 |
| returnType: C<int, String> |
| '''); |
| } |
| |
| test_const_invokeConstructor_generic_named_imported_withPrefix() async { |
| addLibrarySource('/a.dart', r''' |
| class C<K, V> { |
| const C.named(K k, V v); |
| } |
| '''); |
| var library = await checkLibrary(r''' |
| import 'a.dart' as p; |
| const V = const p.C<int, String>.named(1, '222'); |
| '''); |
| checkElementText(library, r''' |
| library |
| imports |
| a.dart as p @19 |
| definingUnit |
| topLevelVariables |
| static const V @28 |
| type: C<int, String> |
| constantInitializer |
| InstanceCreationExpression |
| keyword: const @32 |
| constructorName: ConstructorName |
| type: NamedType |
| name: PrefixedIdentifier |
| prefix: SimpleIdentifier |
| token: p @38 |
| staticElement: self::@prefix::p |
| staticType: null |
| period: . @39 |
| identifier: SimpleIdentifier |
| token: C @40 |
| staticElement: a.dart::@class::C |
| staticType: null |
| staticElement: a.dart::@class::C |
| staticType: null |
| typeArguments: TypeArgumentList |
| leftBracket: < @41 |
| arguments |
| NamedType |
| name: SimpleIdentifier |
| token: int @42 |
| staticElement: dart:core::@class::int |
| staticType: null |
| type: int |
| NamedType |
| name: SimpleIdentifier |
| token: String @47 |
| staticElement: dart:core::@class::String |
| staticType: null |
| type: String |
| rightBracket: > @53 |
| type: C<int, String> |
| period: . @54 |
| name: SimpleIdentifier |
| token: named @55 |
| staticElement: ConstructorMember |
| base: a.dart::@class::C::@constructor::named |
| substitution: {K: int, V: String} |
| staticType: null |
| staticElement: ConstructorMember |
| base: a.dart::@class::C::@constructor::named |
| substitution: {K: int, V: String} |
| argumentList: ArgumentList |
| leftParenthesis: ( @60 |
| arguments |
| IntegerLiteral |
| literal: 1 @61 |
| staticType: int |
| SimpleStringLiteral |
| literal: '222' @64 |
| rightParenthesis: ) @69 |
| staticType: C<int, String> |
| accessors |
| synthetic static get V @-1 |
| returnType: C<int, String> |
| '''); |
| } |
| |
| test_const_invokeConstructor_generic_noTypeArguments() async { |
| var library = await checkLibrary(r''' |
| class C<K, V> { |
| const C(); |
| } |
| const V = const C(); |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| typeParameters |
| covariant K @8 |
| defaultType: dynamic |
| covariant V @11 |
| defaultType: dynamic |
| constructors |
| const @24 |
| topLevelVariables |
| static const V @37 |
| type: C<dynamic, dynamic> |
| constantInitializer |
| InstanceCreationExpression |
| keyword: const @41 |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: C @47 |
| staticElement: self::@class::C |
| staticType: null |
| type: C<dynamic, dynamic> |
| staticElement: ConstructorMember |
| base: self::@class::C::@constructor::• |
| substitution: {K: dynamic, V: dynamic} |
| argumentList: ArgumentList |
| leftParenthesis: ( @48 |
| rightParenthesis: ) @49 |
| staticType: C<dynamic, dynamic> |
| accessors |
| synthetic static get V @-1 |
| returnType: C<dynamic, dynamic> |
| '''); |
| } |
| |
| test_const_invokeConstructor_generic_unnamed() async { |
| var library = await checkLibrary(r''' |
| class C<K, V> { |
| const C(); |
| } |
| const V = const C<int, String>(); |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| typeParameters |
| covariant K @8 |
| defaultType: dynamic |
| covariant V @11 |
| defaultType: dynamic |
| constructors |
| const @24 |
| topLevelVariables |
| static const V @37 |
| type: C<int, String> |
| constantInitializer |
| InstanceCreationExpression |
| keyword: const @41 |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: C @47 |
| staticElement: self::@class::C |
| staticType: null |
| typeArguments: TypeArgumentList |
| leftBracket: < @48 |
| arguments |
| NamedType |
| name: SimpleIdentifier |
| token: int @49 |
| staticElement: dart:core::@class::int |
| staticType: null |
| type: int |
| NamedType |
| name: SimpleIdentifier |
| token: String @54 |
| staticElement: dart:core::@class::String |
| staticType: null |
| type: String |
| rightBracket: > @60 |
| type: C<int, String> |
| staticElement: ConstructorMember |
| base: self::@class::C::@constructor::• |
| substitution: {K: int, V: String} |
| argumentList: ArgumentList |
| leftParenthesis: ( @61 |
| rightParenthesis: ) @62 |
| staticType: C<int, String> |
| accessors |
| synthetic static get V @-1 |
| returnType: C<int, String> |
| '''); |
| } |
| |
| test_const_invokeConstructor_generic_unnamed_imported() async { |
| addLibrarySource('/a.dart', r''' |
| class C<K, V> { |
| const C(); |
| } |
| '''); |
| var library = await checkLibrary(r''' |
| import 'a.dart'; |
| const V = const C<int, String>(); |
| '''); |
| checkElementText(library, r''' |
| library |
| imports |
| a.dart |
| definingUnit |
| topLevelVariables |
| static const V @23 |
| type: C<int, String> |
| constantInitializer |
| InstanceCreationExpression |
| keyword: const @27 |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: C @33 |
| staticElement: a.dart::@class::C |
| staticType: null |
| typeArguments: TypeArgumentList |
| leftBracket: < @34 |
| arguments |
| NamedType |
| name: SimpleIdentifier |
| token: int @35 |
| staticElement: dart:core::@class::int |
| staticType: null |
| type: int |
| NamedType |
| name: SimpleIdentifier |
| token: String @40 |
| staticElement: dart:core::@class::String |
| staticType: null |
| type: String |
| rightBracket: > @46 |
| type: C<int, String> |
| staticElement: ConstructorMember |
| base: a.dart::@class::C::@constructor::• |
| substitution: {K: int, V: String} |
| argumentList: ArgumentList |
| leftParenthesis: ( @47 |
| rightParenthesis: ) @48 |
| staticType: C<int, String> |
| accessors |
| synthetic static get V @-1 |
| returnType: C<int, String> |
| '''); |
| } |
| |
| test_const_invokeConstructor_generic_unnamed_imported_withPrefix() async { |
| addLibrarySource('/a.dart', r''' |
| class C<K, V> { |
| const C(); |
| } |
| '''); |
| var library = await checkLibrary(r''' |
| import 'a.dart' as p; |
| const V = const p.C<int, String>(); |
| '''); |
| checkElementText(library, r''' |
| library |
| imports |
| a.dart as p @19 |
| definingUnit |
| topLevelVariables |
| static const V @28 |
| type: C<int, String> |
| constantInitializer |
| InstanceCreationExpression |
| keyword: const @32 |
| constructorName: ConstructorName |
| type: NamedType |
| name: PrefixedIdentifier |
| prefix: SimpleIdentifier |
| token: p @38 |
| staticElement: self::@prefix::p |
| staticType: null |
| period: . @39 |
| identifier: SimpleIdentifier |
| token: C @40 |
| staticElement: a.dart::@class::C |
| staticType: null |
| staticElement: a.dart::@class::C |
| staticType: null |
| typeArguments: TypeArgumentList |
| leftBracket: < @41 |
| arguments |
| NamedType |
| name: SimpleIdentifier |
| token: int @42 |
| staticElement: dart:core::@class::int |
| staticType: null |
| type: int |
| NamedType |
| name: SimpleIdentifier |
| token: String @47 |
| staticElement: dart:core::@class::String |
| staticType: null |
| type: String |
| rightBracket: > @53 |
| type: C<int, String> |
| staticElement: ConstructorMember |
| base: a.dart::@class::C::@constructor::• |
| substitution: {K: int, V: String} |
| argumentList: ArgumentList |
| leftParenthesis: ( @54 |
| rightParenthesis: ) @55 |
| staticType: C<int, String> |
| accessors |
| synthetic static get V @-1 |
| returnType: C<int, String> |
| '''); |
| } |
| |
| test_const_invokeConstructor_named() async { |
| var library = await checkLibrary(r''' |
| class C { |
| const C.named(bool a, int b, int c, {String d, double e}); |
| } |
| const V = const C.named(true, 1, 2, d: 'ccc', e: 3.4); |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| const named @20 |
| periodOffset: 19 |
| nameEnd: 25 |
| parameters |
| requiredPositional a @31 |
| type: bool |
| requiredPositional b @38 |
| type: int |
| requiredPositional c @45 |
| type: int |
| optionalNamed d @56 |
| type: String |
| optionalNamed e @66 |
| type: double |
| topLevelVariables |
| static const V @79 |
| type: C |
| constantInitializer |
| InstanceCreationExpression |
| keyword: const @83 |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: C @89 |
| staticElement: self::@class::C |
| staticType: null |
| type: C |
| period: . @90 |
| name: SimpleIdentifier |
| token: named @91 |
| staticElement: self::@class::C::@constructor::named |
| staticType: null |
| staticElement: self::@class::C::@constructor::named |
| argumentList: ArgumentList |
| leftParenthesis: ( @96 |
| arguments |
| BooleanLiteral |
| literal: true @97 |
| staticType: bool |
| IntegerLiteral |
| literal: 1 @103 |
| staticType: int |
| IntegerLiteral |
| literal: 2 @106 |
| staticType: int |
| NamedExpression |
| name: Label |
| label: SimpleIdentifier |
| token: d @109 |
| staticElement: self::@class::C::@constructor::named::@parameter::d |
| staticType: null |
| colon: : @110 |
| expression: SimpleStringLiteral |
| literal: 'ccc' @112 |
| NamedExpression |
| name: Label |
| label: SimpleIdentifier |
| token: e @119 |
| staticElement: self::@class::C::@constructor::named::@parameter::e |
| staticType: null |
| colon: : @120 |
| expression: DoubleLiteral |
| literal: 3.4 @122 |
| staticType: double |
| rightParenthesis: ) @125 |
| staticType: C |
| accessors |
| synthetic static get V @-1 |
| returnType: C |
| '''); |
| } |
| |
| test_const_invokeConstructor_named_imported() async { |
| addLibrarySource('/a.dart', r''' |
| class C { |
| const C.named(); |
| } |
| '''); |
| var library = await checkLibrary(r''' |
| import 'a.dart'; |
| const V = const C.named(); |
| '''); |
| checkElementText(library, r''' |
| library |
| imports |
| a.dart |
| definingUnit |
| topLevelVariables |
| static const V @23 |
| type: C |
| constantInitializer |
| InstanceCreationExpression |
| keyword: const @27 |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: C @33 |
| staticElement: a.dart::@class::C |
| staticType: null |
| type: C |
| period: . @34 |
| name: SimpleIdentifier |
| token: named @35 |
| staticElement: a.dart::@class::C::@constructor::named |
| staticType: null |
| staticElement: a.dart::@class::C::@constructor::named |
| argumentList: ArgumentList |
| leftParenthesis: ( @40 |
| rightParenthesis: ) @41 |
| staticType: C |
| accessors |
| synthetic static get V @-1 |
| returnType: C |
| '''); |
| } |
| |
| test_const_invokeConstructor_named_imported_withPrefix() async { |
| addLibrarySource('/a.dart', r''' |
| class C { |
| const C.named(); |
| } |
| '''); |
| var library = await checkLibrary(r''' |
| import 'a.dart' as p; |
| const V = const p.C.named(); |
| '''); |
| checkElementText(library, r''' |
| library |
| imports |
| a.dart as p @19 |
| definingUnit |
| topLevelVariables |
| static const V @28 |
| type: C |
| constantInitializer |
| InstanceCreationExpression |
| keyword: const @32 |
| constructorName: ConstructorName |
| type: NamedType |
| name: PrefixedIdentifier |
| prefix: SimpleIdentifier |
| token: p @38 |
| staticElement: self::@prefix::p |
| staticType: null |
| period: . @39 |
| identifier: SimpleIdentifier |
| token: C @40 |
| staticElement: a.dart::@class::C |
| staticType: null |
| staticElement: a.dart::@class::C |
| staticType: null |
| type: C |
| period: . @41 |
| name: SimpleIdentifier |
| token: named @42 |
| staticElement: a.dart::@class::C::@constructor::named |
| staticType: null |
| staticElement: a.dart::@class::C::@constructor::named |
| argumentList: ArgumentList |
| leftParenthesis: ( @47 |
| rightParenthesis: ) @48 |
| staticType: C |
| accessors |
| synthetic static get V @-1 |
| returnType: C |
| '''); |
| } |
| |
| test_const_invokeConstructor_named_unresolved() async { |
| var library = await checkLibrary(r''' |
| class C {} |
| const V = const C.named(); |
| ''', allowErrors: true); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| synthetic @-1 |
| topLevelVariables |
| static const V @17 |
| type: C |
| constantInitializer |
| InstanceCreationExpression |
| keyword: const @21 |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: C @27 |
| staticElement: self::@class::C |
| staticType: null |
| type: C |
| period: . @28 |
| name: SimpleIdentifier |
| token: named @29 |
| staticElement: <null> |
| staticType: null |
| staticElement: <null> |
| argumentList: ArgumentList |
| leftParenthesis: ( @34 |
| rightParenthesis: ) @35 |
| staticType: C |
| accessors |
| synthetic static get V @-1 |
| returnType: C |
| '''); |
| } |
| |
| test_const_invokeConstructor_named_unresolved2() async { |
| var library = await checkLibrary(r''' |
| const V = const C.named(); |
| ''', allowErrors: true); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const V @6 |
| type: dynamic |
| constantInitializer |
| InstanceCreationExpression |
| keyword: const @10 |
| constructorName: ConstructorName |
| type: NamedType |
| name: PrefixedIdentifier |
| prefix: SimpleIdentifier |
| token: C @16 |
| staticElement: <null> |
| staticType: null |
| period: . @17 |
| identifier: SimpleIdentifier |
| token: named @18 |
| staticElement: <null> |
| staticType: null |
| staticElement: <null> |
| staticType: null |
| type: dynamic |
| staticElement: <null> |
| argumentList: ArgumentList |
| leftParenthesis: ( @23 |
| rightParenthesis: ) @24 |
| staticType: dynamic |
| accessors |
| synthetic static get V @-1 |
| returnType: dynamic |
| '''); |
| } |
| |
| test_const_invokeConstructor_named_unresolved3() async { |
| addLibrarySource('/a.dart', r''' |
| class C { |
| } |
| '''); |
| var library = await checkLibrary(r''' |
| import 'a.dart' as p; |
| const V = const p.C.named(); |
| ''', allowErrors: true); |
| checkElementText(library, r''' |
| library |
| imports |
| a.dart as p @19 |
| definingUnit |
| topLevelVariables |
| static const V @28 |
| type: C |
| constantInitializer |
| InstanceCreationExpression |
| keyword: const @32 |
| constructorName: ConstructorName |
| type: NamedType |
| name: PrefixedIdentifier |
| prefix: SimpleIdentifier |
| token: p @38 |
| staticElement: self::@prefix::p |
| staticType: null |
| period: . @39 |
| identifier: SimpleIdentifier |
| token: C @40 |
| staticElement: a.dart::@class::C |
| staticType: null |
| staticElement: a.dart::@class::C |
| staticType: null |
| type: C |
| period: . @41 |
| name: SimpleIdentifier |
| token: named @42 |
| staticElement: <null> |
| staticType: null |
| staticElement: <null> |
| argumentList: ArgumentList |
| leftParenthesis: ( @47 |
| rightParenthesis: ) @48 |
| staticType: C |
| accessors |
| synthetic static get V @-1 |
| returnType: C |
| '''); |
| } |
| |
| test_const_invokeConstructor_named_unresolved4() async { |
| addLibrarySource('/a.dart', ''); |
| var library = await checkLibrary(r''' |
| import 'a.dart' as p; |
| const V = const p.C.named(); |
| ''', allowErrors: true); |
| checkElementText(library, r''' |
| library |
| imports |
| a.dart as p @19 |
| definingUnit |
| topLevelVariables |
| static const V @28 |
| type: dynamic |
| constantInitializer |
| InstanceCreationExpression |
| keyword: const @32 |
| constructorName: ConstructorName |
| type: NamedType |
| name: PrefixedIdentifier |
| prefix: SimpleIdentifier |
| token: p @38 |
| staticElement: self::@prefix::p |
| staticType: null |
| period: . @39 |
| identifier: SimpleIdentifier |
| token: C @40 |
| staticElement: <null> |
| staticType: null |
| staticElement: <null> |
| staticType: null |
| type: dynamic |
| period: . @41 |
| name: SimpleIdentifier |
| token: named @42 |
| staticElement: <null> |
| staticType: null |
| staticElement: <null> |
| argumentList: ArgumentList |
| leftParenthesis: ( @47 |
| rightParenthesis: ) @48 |
| staticType: dynamic |
| accessors |
| synthetic static get V @-1 |
| returnType: dynamic |
| '''); |
| } |
| |
| test_const_invokeConstructor_named_unresolved5() async { |
| var library = await checkLibrary(r''' |
| const V = const p.C.named(); |
| ''', allowErrors: true); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const V @6 |
| type: dynamic |
| constantInitializer |
| InstanceCreationExpression |
| keyword: const @10 |
| constructorName: ConstructorName |
| type: NamedType |
| name: PrefixedIdentifier |
| prefix: SimpleIdentifier |
| token: p @16 |
| staticElement: <null> |
| staticType: null |
| period: . @17 |
| identifier: SimpleIdentifier |
| token: C @18 |
| staticElement: <null> |
| staticType: null |
| staticElement: <null> |
| staticType: null |
| type: dynamic |
| period: . @19 |
| name: SimpleIdentifier |
| token: named @20 |
| staticElement: <null> |
| staticType: null |
| staticElement: <null> |
| argumentList: ArgumentList |
| leftParenthesis: ( @25 |
| rightParenthesis: ) @26 |
| staticType: dynamic |
| accessors |
| synthetic static get V @-1 |
| returnType: dynamic |
| '''); |
| } |
| |
| test_const_invokeConstructor_named_unresolved6() async { |
| var library = await checkLibrary(r''' |
| class C<T> {} |
| const V = const C.named(); |
| ''', allowErrors: true); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| typeParameters |
| covariant T @8 |
| defaultType: dynamic |
| constructors |
| synthetic @-1 |
| topLevelVariables |
| static const V @20 |
| type: C<dynamic> |
| constantInitializer |
| InstanceCreationExpression |
| keyword: const @24 |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: C @30 |
| staticElement: self::@class::C |
| staticType: null |
| type: C<dynamic> |
| period: . @31 |
| name: SimpleIdentifier |
| token: named @32 |
| staticElement: <null> |
| staticType: null |
| staticElement: <null> |
| argumentList: ArgumentList |
| leftParenthesis: ( @37 |
| rightParenthesis: ) @38 |
| staticType: C<dynamic> |
| accessors |
| synthetic static get V @-1 |
| returnType: C<dynamic> |
| '''); |
| } |
| |
| test_const_invokeConstructor_unnamed() async { |
| var library = await checkLibrary(r''' |
| class C { |
| const C(); |
| } |
| const V = const C(); |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| const @18 |
| topLevelVariables |
| static const V @31 |
| type: C |
| constantInitializer |
| InstanceCreationExpression |
| keyword: const @35 |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: C @41 |
| staticElement: self::@class::C |
| staticType: null |
| type: C |
| staticElement: self::@class::C::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @42 |
| rightParenthesis: ) @43 |
| staticType: C |
| accessors |
| synthetic static get V @-1 |
| returnType: C |
| '''); |
| } |
| |
| test_const_invokeConstructor_unnamed_imported() async { |
| addLibrarySource('/a.dart', r''' |
| class C { |
| const C(); |
| } |
| '''); |
| var library = await checkLibrary(r''' |
| import 'a.dart'; |
| const V = const C(); |
| '''); |
| checkElementText(library, r''' |
| library |
| imports |
| a.dart |
| definingUnit |
| topLevelVariables |
| static const V @23 |
| type: C |
| constantInitializer |
| InstanceCreationExpression |
| keyword: const @27 |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: C @33 |
| staticElement: a.dart::@class::C |
| staticType: null |
| type: C |
| staticElement: a.dart::@class::C::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @34 |
| rightParenthesis: ) @35 |
| staticType: C |
| accessors |
| synthetic static get V @-1 |
| returnType: C |
| '''); |
| } |
| |
| test_const_invokeConstructor_unnamed_imported_withPrefix() async { |
| addLibrarySource('/a.dart', r''' |
| class C { |
| const C(); |
| } |
| '''); |
| var library = await checkLibrary(r''' |
| import 'a.dart' as p; |
| const V = const p.C(); |
| '''); |
| checkElementText(library, r''' |
| library |
| imports |
| a.dart as p @19 |
| definingUnit |
| topLevelVariables |
| static const V @28 |
| type: C |
| constantInitializer |
| InstanceCreationExpression |
| keyword: const @32 |
| constructorName: ConstructorName |
| type: NamedType |
| name: PrefixedIdentifier |
| prefix: SimpleIdentifier |
| token: p @38 |
| staticElement: self::@prefix::p |
| staticType: null |
| period: . @39 |
| identifier: SimpleIdentifier |
| token: C @40 |
| staticElement: a.dart::@class::C |
| staticType: null |
| staticElement: a.dart::@class::C |
| staticType: null |
| type: C |
| staticElement: a.dart::@class::C::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @41 |
| rightParenthesis: ) @42 |
| staticType: C |
| accessors |
| synthetic static get V @-1 |
| returnType: C |
| '''); |
| } |
| |
| test_const_invokeConstructor_unnamed_unresolved() async { |
| var library = await checkLibrary(r''' |
| const V = const C(); |
| ''', allowErrors: true); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const V @6 |
| type: dynamic |
| constantInitializer |
| InstanceCreationExpression |
| keyword: const @10 |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: C @16 |
| staticElement: <null> |
| staticType: null |
| type: dynamic |
| staticElement: <null> |
| argumentList: ArgumentList |
| leftParenthesis: ( @17 |
| rightParenthesis: ) @18 |
| staticType: dynamic |
| accessors |
| synthetic static get V @-1 |
| returnType: dynamic |
| '''); |
| } |
| |
| test_const_invokeConstructor_unnamed_unresolved2() async { |
| addLibrarySource('/a.dart', ''); |
| var library = await checkLibrary(r''' |
| import 'a.dart' as p; |
| const V = const p.C(); |
| ''', allowErrors: true); |
| checkElementText(library, r''' |
| library |
| imports |
| a.dart as p @19 |
| definingUnit |
| topLevelVariables |
| static const V @28 |
| type: dynamic |
| constantInitializer |
| InstanceCreationExpression |
| keyword: const @32 |
| constructorName: ConstructorName |
| type: NamedType |
| name: PrefixedIdentifier |
| prefix: SimpleIdentifier |
| token: p @38 |
| staticElement: self::@prefix::p |
| staticType: null |
| period: . @39 |
| identifier: SimpleIdentifier |
| token: C @40 |
| staticElement: <null> |
| staticType: null |
| staticElement: <null> |
| staticType: null |
| type: dynamic |
| staticElement: <null> |
| argumentList: ArgumentList |
| leftParenthesis: ( @41 |
| rightParenthesis: ) @42 |
| staticType: dynamic |
| accessors |
| synthetic static get V @-1 |
| returnType: dynamic |
| '''); |
| } |
| |
| test_const_invokeConstructor_unnamed_unresolved3() async { |
| var library = await checkLibrary(r''' |
| const V = const p.C(); |
| ''', allowErrors: true); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const V @6 |
| type: dynamic |
| constantInitializer |
| InstanceCreationExpression |
| keyword: const @10 |
| constructorName: ConstructorName |
| type: NamedType |
| name: PrefixedIdentifier |
| prefix: SimpleIdentifier |
| token: p @16 |
| staticElement: <null> |
| staticType: null |
| period: . @17 |
| identifier: SimpleIdentifier |
| token: C @18 |
| staticElement: <null> |
| staticType: null |
| staticElement: <null> |
| staticType: null |
| type: dynamic |
| staticElement: <null> |
| argumentList: ArgumentList |
| leftParenthesis: ( @19 |
| rightParenthesis: ) @20 |
| staticType: dynamic |
| accessors |
| synthetic static get V @-1 |
| returnType: dynamic |
| '''); |
| } |
| |
| test_const_isExpression() async { |
| var library = await checkLibrary(''' |
| const a = 0; |
| const b = a is int; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const a @6 |
| type: int |
| constantInitializer |
| IntegerLiteral |
| literal: 0 @10 |
| staticType: int |
| static const b @19 |
| type: bool |
| constantInitializer |
| IsExpression |
| expression: SimpleIdentifier |
| token: a @23 |
| staticElement: self::@getter::a |
| staticType: int |
| isOperator: is @25 |
| type: NamedType |
| name: SimpleIdentifier |
| token: int @28 |
| staticElement: dart:core::@class::int |
| staticType: null |
| type: int |
| staticType: bool |
| accessors |
| synthetic static get a @-1 |
| returnType: int |
| synthetic static get b @-1 |
| returnType: bool |
| '''); |
| } |
| |
| test_const_length_ofClassConstField() async { |
| var library = await checkLibrary(r''' |
| class C { |
| static const String F = ''; |
| } |
| const int v = C.F.length; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| static const F @32 |
| type: String |
| constantInitializer |
| SimpleStringLiteral |
| literal: '' @36 |
| constructors |
| synthetic @-1 |
| accessors |
| synthetic static get F @-1 |
| returnType: String |
| topLevelVariables |
| static const v @52 |
| type: int |
| constantInitializer |
| PropertyAccess |
| target: PrefixedIdentifier |
| prefix: SimpleIdentifier |
| token: C @56 |
| staticElement: self::@class::C |
| staticType: null |
| period: . @57 |
| identifier: SimpleIdentifier |
| token: F @58 |
| staticElement: self::@class::C::@getter::F |
| staticType: String |
| staticElement: self::@class::C::@getter::F |
| staticType: String |
| operator: . @59 |
| propertyName: SimpleIdentifier |
| token: length @60 |
| staticElement: dart:core::@class::String::@getter::length |
| staticType: int |
| staticType: int |
| accessors |
| synthetic static get v @-1 |
| returnType: int |
| '''); |
| } |
| |
| test_const_length_ofClassConstField_imported() async { |
| addLibrarySource('/a.dart', r''' |
| class C { |
| static const String F = ''; |
| } |
| '''); |
| var library = await checkLibrary(r''' |
| import 'a.dart'; |
| const int v = C.F.length; |
| '''); |
| checkElementText(library, r''' |
| library |
| imports |
| a.dart |
| definingUnit |
| topLevelVariables |
| static const v @27 |
| type: int |
| constantInitializer |
| PropertyAccess |
| target: PrefixedIdentifier |
| prefix: SimpleIdentifier |
| token: C @31 |
| staticElement: a.dart::@class::C |
| staticType: null |
| period: . @32 |
| identifier: SimpleIdentifier |
| token: F @33 |
| staticElement: a.dart::@class::C::@getter::F |
| staticType: String |
| staticElement: a.dart::@class::C::@getter::F |
| staticType: String |
| operator: . @34 |
| propertyName: SimpleIdentifier |
| token: length @35 |
| staticElement: dart:core::@class::String::@getter::length |
| staticType: int |
| staticType: int |
| accessors |
| synthetic static get v @-1 |
| returnType: int |
| '''); |
| } |
| |
| test_const_length_ofClassConstField_imported_withPrefix() async { |
| addLibrarySource('/a.dart', r''' |
| class C { |
| static const String F = ''; |
| } |
| '''); |
| var library = await checkLibrary(r''' |
| import 'a.dart' as p; |
| const int v = p.C.F.length; |
| '''); |
| checkElementText(library, r''' |
| library |
| imports |
| a.dart as p @19 |
| definingUnit |
| topLevelVariables |
| static const v @32 |
| type: int |
| constantInitializer |
| PropertyAccess |
| target: PropertyAccess |
| target: PrefixedIdentifier |
| prefix: SimpleIdentifier |
| token: p @36 |
| staticElement: self::@prefix::p |
| staticType: null |
| period: . @37 |
| identifier: SimpleIdentifier |
| token: C @38 |
| staticElement: a.dart::@class::C |
| staticType: null |
| staticElement: a.dart::@class::C |
| staticType: null |
| operator: . @39 |
| propertyName: SimpleIdentifier |
| token: F @40 |
| staticElement: a.dart::@class::C::@getter::F |
| staticType: String |
| staticType: String |
| operator: . @41 |
| propertyName: SimpleIdentifier |
| token: length @42 |
| staticElement: dart:core::@class::String::@getter::length |
| staticType: int |
| staticType: int |
| accessors |
| synthetic static get v @-1 |
| returnType: int |
| '''); |
| } |
| |
| test_const_length_ofStringLiteral() async { |
| var library = await checkLibrary(r''' |
| const v = 'abc'.length; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const v @6 |
| type: int |
| constantInitializer |
| PropertyAccess |
| target: SimpleStringLiteral |
| literal: 'abc' @10 |
| operator: . @15 |
| propertyName: SimpleIdentifier |
| token: length @16 |
| staticElement: dart:core::@class::String::@getter::length |
| staticType: int |
| staticType: int |
| accessors |
| synthetic static get v @-1 |
| returnType: int |
| '''); |
| } |
| |
| test_const_length_ofTopLevelVariable() async { |
| var library = await checkLibrary(r''' |
| const String S = 'abc'; |
| const v = S.length; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const S @13 |
| type: String |
| constantInitializer |
| SimpleStringLiteral |
| literal: 'abc' @17 |
| static const v @30 |
| type: int |
| constantInitializer |
| PrefixedIdentifier |
| prefix: SimpleIdentifier |
| token: S @34 |
| staticElement: self::@getter::S |
| staticType: String |
| period: . @35 |
| identifier: SimpleIdentifier |
| token: length @36 |
| staticElement: dart:core::@class::String::@getter::length |
| staticType: int |
| staticElement: dart:core::@class::String::@getter::length |
| staticType: int |
| accessors |
| synthetic static get S @-1 |
| returnType: String |
| synthetic static get v @-1 |
| returnType: int |
| '''); |
| } |
| |
| test_const_length_ofTopLevelVariable_imported() async { |
| addLibrarySource('/a.dart', r''' |
| const String S = 'abc'; |
| '''); |
| var library = await checkLibrary(r''' |
| import 'a.dart'; |
| const v = S.length; |
| '''); |
| checkElementText(library, r''' |
| library |
| imports |
| a.dart |
| definingUnit |
| topLevelVariables |
| static const v @23 |
| type: int |
| constantInitializer |
| PrefixedIdentifier |
| prefix: SimpleIdentifier |
| token: S @27 |
| staticElement: a.dart::@getter::S |
| staticType: String |
| period: . @28 |
| identifier: SimpleIdentifier |
| token: length @29 |
| staticElement: dart:core::@class::String::@getter::length |
| staticType: int |
| staticElement: dart:core::@class::String::@getter::length |
| staticType: int |
| accessors |
| synthetic static get v @-1 |
| returnType: int |
| '''); |
| } |
| |
| test_const_length_ofTopLevelVariable_imported_withPrefix() async { |
| addLibrarySource('/a.dart', r''' |
| const String S = 'abc'; |
| '''); |
| var library = await checkLibrary(r''' |
| import 'a.dart' as p; |
| const v = p.S.length; |
| '''); |
| checkElementText(library, r''' |
| library |
| imports |
| a.dart as p @19 |
| definingUnit |
| topLevelVariables |
| static const v @28 |
| type: int |
| constantInitializer |
| PropertyAccess |
| target: PrefixedIdentifier |
| prefix: SimpleIdentifier |
| token: p @32 |
| staticElement: self::@prefix::p |
| staticType: null |
| period: . @33 |
| identifier: SimpleIdentifier |
| token: S @34 |
| staticElement: a.dart::@getter::S |
| staticType: String |
| staticElement: a.dart::@getter::S |
| staticType: String |
| operator: . @35 |
| propertyName: SimpleIdentifier |
| token: length @36 |
| staticElement: dart:core::@class::String::@getter::length |
| staticType: int |
| staticType: int |
| accessors |
| synthetic static get v @-1 |
| returnType: int |
| '''); |
| } |
| |
| test_const_length_staticMethod() async { |
| var library = await checkLibrary(r''' |
| class C { |
| static int length() => 42; |
| } |
| const v = C.length; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| synthetic @-1 |
| methods |
| static length @23 |
| returnType: int |
| topLevelVariables |
| static const v @47 |
| type: int Function() |
| constantInitializer |
| PrefixedIdentifier |
| prefix: SimpleIdentifier |
| token: C @51 |
| staticElement: self::@class::C |
| staticType: null |
| period: . @52 |
| identifier: SimpleIdentifier |
| token: length @53 |
| staticElement: self::@class::C::@method::length |
| staticType: int Function() |
| staticElement: self::@class::C::@method::length |
| staticType: int Function() |
| accessors |
| synthetic static get v @-1 |
| returnType: int Function() |
| '''); |
| } |
| |
| test_const_list_if() async { |
| var library = await checkLibrary(''' |
| const Object x = const <int>[if (true) 1]; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const x @13 |
| type: Object |
| constantInitializer |
| ListLiteral |
| constKeyword: const @17 |
| typeArguments: TypeArgumentList |
| leftBracket: < @23 |
| arguments |
| NamedType |
| name: SimpleIdentifier |
| token: int @24 |
| staticElement: dart:core::@class::int |
| staticType: null |
| type: int |
| rightBracket: > @27 |
| leftBracket: [ @28 |
| elements |
| IfElement |
| ifKeyword: if @29 |
| leftParenthesis: ( @32 |
| condition: BooleanLiteral |
| literal: true @33 |
| staticType: bool |
| rightParenthesis: ) @37 |
| thenElement: IntegerLiteral |
| literal: 1 @39 |
| staticType: int |
| rightBracket: ] @40 |
| staticType: List<int> |
| accessors |
| synthetic static get x @-1 |
| returnType: Object |
| '''); |
| } |
| |
| test_const_list_if_else() async { |
| var library = await checkLibrary(''' |
| const Object x = const <int>[if (true) 1 else 2]; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const x @13 |
| type: Object |
| constantInitializer |
| ListLiteral |
| constKeyword: const @17 |
| typeArguments: TypeArgumentList |
| leftBracket: < @23 |
| arguments |
| NamedType |
| name: SimpleIdentifier |
| token: int @24 |
| staticElement: dart:core::@class::int |
| staticType: null |
| type: int |
| rightBracket: > @27 |
| leftBracket: [ @28 |
| elements |
| IfElement |
| ifKeyword: if @29 |
| leftParenthesis: ( @32 |
| condition: BooleanLiteral |
| literal: true @33 |
| staticType: bool |
| rightParenthesis: ) @37 |
| thenElement: IntegerLiteral |
| literal: 1 @39 |
| staticType: int |
| elseKeyword: else @41 |
| elseElement: IntegerLiteral |
| literal: 2 @46 |
| staticType: int |
| rightBracket: ] @47 |
| staticType: List<int> |
| accessors |
| synthetic static get x @-1 |
| returnType: Object |
| '''); |
| } |
| |
| test_const_list_inferredType() async { |
| // The summary needs to contain enough information so that when the constant |
| // is resynthesized, the constant value can get the type that was computed |
| // by type inference. |
| var library = await checkLibrary(''' |
| const Object x = const [1]; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const x @13 |
| type: Object |
| constantInitializer |
| ListLiteral |
| constKeyword: const @17 |
| leftBracket: [ @23 |
| elements |
| IntegerLiteral |
| literal: 1 @24 |
| staticType: int |
| rightBracket: ] @25 |
| staticType: List<int> |
| accessors |
| synthetic static get x @-1 |
| returnType: Object |
| '''); |
| } |
| |
| test_const_list_spread() async { |
| var library = await checkLibrary(''' |
| const Object x = const <int>[...<int>[1]]; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const x @13 |
| type: Object |
| constantInitializer |
| ListLiteral |
| constKeyword: const @17 |
| typeArguments: TypeArgumentList |
| leftBracket: < @23 |
| arguments |
| NamedType |
| name: SimpleIdentifier |
| token: int @24 |
| staticElement: dart:core::@class::int |
| staticType: null |
| type: int |
| rightBracket: > @27 |
| leftBracket: [ @28 |
| elements |
| SpreadElement |
| spreadOperator: ... @29 |
| expression: ListLiteral |
| typeArguments: TypeArgumentList |
| leftBracket: < @32 |
| arguments |
| NamedType |
| name: SimpleIdentifier |
| token: int @33 |
| staticElement: dart:core::@class::int |
| staticType: null |
| type: int |
| rightBracket: > @36 |
| leftBracket: [ @37 |
| elements |
| IntegerLiteral |
| literal: 1 @38 |
| staticType: int |
| rightBracket: ] @39 |
| staticType: List<int> |
| rightBracket: ] @40 |
| staticType: List<int> |
| accessors |
| synthetic static get x @-1 |
| returnType: Object |
| '''); |
| } |
| |
| test_const_list_spread_null_aware() async { |
| var library = await checkLibrary(''' |
| const Object x = const <int>[...?<int>[1]]; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const x @13 |
| type: Object |
| constantInitializer |
| ListLiteral |
| constKeyword: const @17 |
| typeArguments: TypeArgumentList |
| leftBracket: < @23 |
| arguments |
| NamedType |
| name: SimpleIdentifier |
| token: int @24 |
| staticElement: dart:core::@class::int |
| staticType: null |
| type: int |
| rightBracket: > @27 |
| leftBracket: [ @28 |
| elements |
| SpreadElement |
| spreadOperator: ...? @29 |
| expression: ListLiteral |
| typeArguments: TypeArgumentList |
| leftBracket: < @33 |
| arguments |
| NamedType |
| name: SimpleIdentifier |
| token: int @34 |
| staticElement: dart:core::@class::int |
| staticType: null |
| type: int |
| rightBracket: > @37 |
| leftBracket: [ @38 |
| elements |
| IntegerLiteral |
| literal: 1 @39 |
| staticType: int |
| rightBracket: ] @40 |
| staticType: List<int> |
| rightBracket: ] @41 |
| staticType: List<int> |
| accessors |
| synthetic static get x @-1 |
| returnType: Object |
| '''); |
| } |
| |
| test_const_map_if() async { |
| var library = await checkLibrary(''' |
| const Object x = const <int, int>{if (true) 1: 2}; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const x @13 |
| type: Object |
| constantInitializer |
| SetOrMapLiteral |
| constKeyword: const @17 |
| typeArguments: TypeArgumentList |
| leftBracket: < @23 |
| arguments |
| NamedType |
| name: SimpleIdentifier |
| token: int @24 |
| staticElement: dart:core::@class::int |
| staticType: null |
| type: int |
| NamedType |
| name: SimpleIdentifier |
| token: int @29 |
| staticElement: dart:core::@class::int |
| staticType: null |
| type: int |
| rightBracket: > @32 |
| leftBracket: { @33 |
| elements |
| IfElement |
| ifKeyword: if @34 |
| leftParenthesis: ( @37 |
| condition: BooleanLiteral |
| literal: true @38 |
| staticType: bool |
| rightParenthesis: ) @42 |
| thenElement: SetOrMapLiteral |
| key: IntegerLiteral |
| literal: 1 @44 |
| staticType: int |
| separator: : @45 |
| value: IntegerLiteral |
| literal: 2 @47 |
| staticType: int |
| rightBracket: } @48 |
| isMap: true |
| staticType: Map<int, int> |
| accessors |
| synthetic static get x @-1 |
| returnType: Object |
| '''); |
| } |
| |
| test_const_map_inferredType() async { |
| // The summary needs to contain enough information so that when the constant |
| // is resynthesized, the constant value can get the type that was computed |
| // by type inference. |
| var library = await checkLibrary(''' |
| const Object x = const {1: 1.0}; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const x @13 |
| type: Object |
| constantInitializer |
| SetOrMapLiteral |
| constKeyword: const @17 |
| leftBracket: { @23 |
| elements |
| SetOrMapLiteral |
| key: IntegerLiteral |
| literal: 1 @24 |
| staticType: int |
| separator: : @25 |
| value: DoubleLiteral |
| literal: 1.0 @27 |
| staticType: double |
| rightBracket: } @30 |
| isMap: true |
| staticType: Map<int, double> |
| accessors |
| synthetic static get x @-1 |
| returnType: Object |
| '''); |
| } |
| |
| test_const_map_spread() async { |
| var library = await checkLibrary(''' |
| const Object x = const <int, int>{...<int, int>{1: 2}}; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const x @13 |
| type: Object |
| constantInitializer |
| SetOrMapLiteral |
| constKeyword: const @17 |
| typeArguments: TypeArgumentList |
| leftBracket: < @23 |
| arguments |
| NamedType |
| name: SimpleIdentifier |
| token: int @24 |
| staticElement: dart:core::@class::int |
| staticType: null |
| type: int |
| NamedType |
| name: SimpleIdentifier |
| token: int @29 |
| staticElement: dart:core::@class::int |
| staticType: null |
| type: int |
| rightBracket: > @32 |
| leftBracket: { @33 |
| elements |
| SpreadElement |
| spreadOperator: ... @34 |
| expression: SetOrMapLiteral |
| typeArguments: TypeArgumentList |
| leftBracket: < @37 |
| arguments |
| NamedType |
| name: SimpleIdentifier |
| token: int @38 |
| staticElement: dart:core::@class::int |
| staticType: null |
| type: int |
| NamedType |
| name: SimpleIdentifier |
| token: int @43 |
| staticElement: dart:core::@class::int |
| staticType: null |
| type: int |
| rightBracket: > @46 |
| leftBracket: { @47 |
| elements |
| SetOrMapLiteral |
| key: IntegerLiteral |
| literal: 1 @48 |
| staticType: int |
| separator: : @49 |
| value: IntegerLiteral |
| literal: 2 @51 |
| staticType: int |
| rightBracket: } @52 |
| isMap: true |
| staticType: Map<int, int> |
| rightBracket: } @53 |
| isMap: true |
| staticType: Map<int, int> |
| accessors |
| synthetic static get x @-1 |
| returnType: Object |
| '''); |
| } |
| |
| test_const_map_spread_null_aware() async { |
| var library = await checkLibrary(''' |
| const Object x = const <int, int>{...?<int, int>{1: 2}}; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const x @13 |
| type: Object |
| constantInitializer |
| SetOrMapLiteral |
| constKeyword: const @17 |
| typeArguments: TypeArgumentList |
| leftBracket: < @23 |
| arguments |
| NamedType |
| name: SimpleIdentifier |
| token: int @24 |
| staticElement: dart:core::@class::int |
| staticType: null |
| type: int |
| NamedType |
| name: SimpleIdentifier |
| token: int @29 |
| staticElement: dart:core::@class::int |
| staticType: null |
| type: int |
| rightBracket: > @32 |
| leftBracket: { @33 |
| elements |
| SpreadElement |
| spreadOperator: ...? @34 |
| expression: SetOrMapLiteral |
| typeArguments: TypeArgumentList |
| leftBracket: < @38 |
| arguments |
| NamedType |
| name: SimpleIdentifier |
| token: int @39 |
| staticElement: dart:core::@class::int |
| staticType: null |
| type: int |
| NamedType |
| name: SimpleIdentifier |
| token: int @44 |
| staticElement: dart:core::@class::int |
| staticType: null |
| type: int |
| rightBracket: > @47 |
| leftBracket: { @48 |
| elements |
| SetOrMapLiteral |
| key: IntegerLiteral |
| literal: 1 @49 |
| staticType: int |
| separator: : @50 |
| value: IntegerLiteral |
| literal: 2 @52 |
| staticType: int |
| rightBracket: } @53 |
| isMap: true |
| staticType: Map<int, int> |
| rightBracket: } @54 |
| isMap: true |
| staticType: Map<int, int> |
| accessors |
| synthetic static get x @-1 |
| returnType: Object |
| '''); |
| } |
| |
| test_const_methodInvocation() async { |
| var library = await checkLibrary(r''' |
| T f<T>(T a) => a; |
| const b = f<int>(0); |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const b @24 |
| type: int |
| constantInitializer |
| MethodInvocation |
| methodName: SimpleIdentifier |
| token: f @28 |
| staticElement: self::@function::f |
| staticType: T Function<T>(T) |
| argumentList: ArgumentList |
| leftParenthesis: ( @34 |
| arguments |
| IntegerLiteral |
| literal: 0 @35 |
| staticType: int |
| rightParenthesis: ) @36 |
| staticInvokeType: int Function(int) |
| staticType: int |
| typeArgumentTypes |
| int |
| accessors |
| synthetic static get b @-1 |
| returnType: int |
| functions |
| f @2 |
| typeParameters |
| covariant T @4 |
| parameters |
| requiredPositional a @9 |
| type: T |
| returnType: T |
| '''); |
| } |
| |
| test_const_parameterDefaultValue_initializingFormal_functionTyped() async { |
| var library = await checkLibrary(r''' |
| class C { |
| final x; |
| const C({this.x: foo}); |
| } |
| int foo() => 42; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| final x @18 |
| type: dynamic |
| constructors |
| const @29 |
| parameters |
| optionalNamed final this.x @37 |
| type: dynamic |
| constantInitializer |
| SimpleIdentifier |
| token: foo @40 |
| staticElement: self::@function::foo |
| staticType: int Function() |
| field: self::@class::C::@field::x |
| accessors |
| synthetic get x @-1 |
| returnType: dynamic |
| functions |
| foo @53 |
| returnType: int |
| '''); |
| } |
| |
| test_const_parameterDefaultValue_initializingFormal_named() async { |
| var library = await checkLibrary(r''' |
| class C { |
| final x; |
| const C({this.x: 1 + 2}); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| final x @18 |
| type: dynamic |
| constructors |
| const @29 |
| parameters |
| optionalNamed final this.x @37 |
| type: dynamic |
| constantInitializer |
| BinaryExpression |
| leftOperand: IntegerLiteral |
| literal: 1 @40 |
| staticType: int |
| operator: + @42 |
| rightOperand: IntegerLiteral |
| literal: 2 @44 |
| staticType: int |
| staticElement: dart:core::@class::num::@method::+ |
| staticInvokeType: num Function(num) |
| staticType: int |
| field: self::@class::C::@field::x |
| accessors |
| synthetic get x @-1 |
| returnType: dynamic |
| '''); |
| } |
| |
| test_const_parameterDefaultValue_initializingFormal_positional() async { |
| var library = await checkLibrary(r''' |
| class C { |
| final x; |
| const C([this.x = 1 + 2]); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| final x @18 |
| type: dynamic |
| constructors |
| const @29 |
| parameters |
| optionalPositional final this.x @37 |
| type: dynamic |
| constantInitializer |
| BinaryExpression |
| leftOperand: IntegerLiteral |
| literal: 1 @41 |
| staticType: int |
| operator: + @43 |
| rightOperand: IntegerLiteral |
| literal: 2 @45 |
| staticType: int |
| staticElement: dart:core::@class::num::@method::+ |
| staticInvokeType: num Function(num) |
| staticType: int |
| field: self::@class::C::@field::x |
| accessors |
| synthetic get x @-1 |
| returnType: dynamic |
| '''); |
| } |
| |
| test_const_parameterDefaultValue_normal() async { |
| var library = await checkLibrary(r''' |
| class C { |
| const C.positional([p = 1 + 2]); |
| const C.named({p: 1 + 2}); |
| void methodPositional([p = 1 + 2]) {} |
| void methodPositionalWithoutDefault([p]) {} |
| void methodNamed({p: 1 + 2}) {} |
| void methodNamedWithoutDefault({p}) {} |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| const positional @20 |
| periodOffset: 19 |
| nameEnd: 30 |
| parameters |
| optionalPositional p @32 |
| type: dynamic |
| constantInitializer |
| BinaryExpression |
| leftOperand: IntegerLiteral |
| literal: 1 @36 |
| staticType: int |
| operator: + @38 |
| rightOperand: IntegerLiteral |
| literal: 2 @40 |
| staticType: int |
| staticElement: dart:core::@class::num::@method::+ |
| staticInvokeType: num Function(num) |
| staticType: int |
| const named @55 |
| periodOffset: 54 |
| nameEnd: 60 |
| parameters |
| optionalNamed p @62 |
| type: dynamic |
| constantInitializer |
| BinaryExpression |
| leftOperand: IntegerLiteral |
| literal: 1 @65 |
| staticType: int |
| operator: + @67 |
| rightOperand: IntegerLiteral |
| literal: 2 @69 |
| staticType: int |
| staticElement: dart:core::@class::num::@method::+ |
| staticInvokeType: num Function(num) |
| staticType: int |
| methods |
| methodPositional @81 |
| parameters |
| optionalPositional p @99 |
| type: dynamic |
| constantInitializer |
| BinaryExpression |
| leftOperand: IntegerLiteral |
| literal: 1 @103 |
| staticType: int |
| operator: + @105 |
| rightOperand: IntegerLiteral |
| literal: 2 @107 |
| staticType: int |
| staticElement: dart:core::@class::num::@method::+ |
| staticInvokeType: num Function(num) |
| staticType: int |
| returnType: void |
| methodPositionalWithoutDefault @121 |
| parameters |
| optionalPositional p @153 |
| type: dynamic |
| returnType: void |
| methodNamed @167 |
| parameters |
| optionalNamed p @180 |
| type: dynamic |
| constantInitializer |
| BinaryExpression |
| leftOperand: IntegerLiteral |
| literal: 1 @183 |
| staticType: int |
| operator: + @185 |
| rightOperand: IntegerLiteral |
| literal: 2 @187 |
| staticType: int |
| staticElement: dart:core::@class::num::@method::+ |
| staticInvokeType: num Function(num) |
| staticType: int |
| returnType: void |
| methodNamedWithoutDefault @201 |
| parameters |
| optionalNamed p @228 |
| type: dynamic |
| returnType: void |
| '''); |
| } |
| |
| test_const_postfixExpression_increment() async { |
| var library = await checkLibrary(r''' |
| const a = 0; |
| const b = a++; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const a @6 |
| type: int |
| constantInitializer |
| IntegerLiteral |
| literal: 0 @10 |
| staticType: int |
| static const b @19 |
| type: int |
| constantInitializer |
| PostfixExpression |
| operand: SimpleIdentifier |
| token: a @23 |
| staticElement: <null> |
| staticType: null |
| operator: ++ @24 |
| readElement: self::@getter::a |
| readType: int |
| writeElement: self::@getter::a |
| writeType: dynamic |
| staticElement: dart:core::@class::num::@method::+ |
| staticType: int |
| accessors |
| synthetic static get a @-1 |
| returnType: int |
| synthetic static get b @-1 |
| returnType: int |
| '''); |
| } |
| |
| test_const_postfixExpression_nullCheck() async { |
| var library = await checkLibrary(r''' |
| const int? a = 0; |
| const b = a!; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const a @11 |
| type: int? |
| constantInitializer |
| IntegerLiteral |
| literal: 0 @15 |
| staticType: int |
| static const b @24 |
| type: int |
| constantInitializer |
| PostfixExpression |
| operand: SimpleIdentifier |
| token: a @28 |
| staticElement: self::@getter::a |
| staticType: int? |
| operator: ! @29 |
| staticElement: <null> |
| staticType: int |
| accessors |
| synthetic static get a @-1 |
| returnType: int? |
| synthetic static get b @-1 |
| returnType: int |
| '''); |
| } |
| |
| test_const_prefixExpression_class_unaryMinus() async { |
| var library = await checkLibrary(r''' |
| const a = 0; |
| const b = -a; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const a @6 |
| type: int |
| constantInitializer |
| IntegerLiteral |
| literal: 0 @10 |
| staticType: int |
| static const b @19 |
| type: int |
| constantInitializer |
| PrefixExpression |
| operator: - @23 |
| operand: SimpleIdentifier |
| token: a @24 |
| staticElement: self::@getter::a |
| staticType: int |
| staticElement: dart:core::@class::int::@method::unary- |
| staticType: int |
| accessors |
| synthetic static get a @-1 |
| returnType: int |
| synthetic static get b @-1 |
| returnType: int |
| '''); |
| } |
| |
| test_const_prefixExpression_extension_unaryMinus() async { |
| testFile = convertPath('/home/test/lib/test.dart'); |
| addLibrarySource('/home/test/lib/a.dart', r''' |
| extension E on Object { |
| int operator -() => 0; |
| } |
| const a = const Object(); |
| '''); |
| var library = await checkLibrary(''' |
| import 'a.dart'; |
| const b = -a; |
| '''); |
| checkElementText(library, r''' |
| library |
| imports |
| package:test/a.dart |
| definingUnit |
| topLevelVariables |
| static const b @23 |
| type: int |
| constantInitializer |
| PrefixExpression |
| operator: - @27 |
| operand: SimpleIdentifier |
| token: a @28 |
| staticElement: package:test/a.dart::@getter::a |
| staticType: Object |
| staticElement: package:test/a.dart::@extension::E::@method::unary- |
| staticType: int |
| accessors |
| synthetic static get b @-1 |
| returnType: int |
| '''); |
| } |
| |
| test_const_prefixExpression_increment() async { |
| var library = await checkLibrary(r''' |
| const a = 0; |
| const b = ++a; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const a @6 |
| type: int |
| constantInitializer |
| IntegerLiteral |
| literal: 0 @10 |
| staticType: int |
| static const b @19 |
| type: int |
| constantInitializer |
| PrefixExpression |
| operator: ++ @23 |
| operand: SimpleIdentifier |
| token: a @25 |
| staticElement: <null> |
| staticType: null |
| readElement: self::@getter::a |
| readType: int |
| writeElement: self::@getter::a |
| writeType: dynamic |
| staticElement: dart:core::@class::num::@method::+ |
| staticType: int |
| accessors |
| synthetic static get a @-1 |
| returnType: int |
| synthetic static get b @-1 |
| returnType: int |
| '''); |
| } |
| |
| test_const_reference_staticField() async { |
| var library = await checkLibrary(r''' |
| class C { |
| static const int F = 42; |
| } |
| const V = C.F; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| static const F @29 |
| type: int |
| constantInitializer |
| IntegerLiteral |
| literal: 42 @33 |
| staticType: int |
| constructors |
| synthetic @-1 |
| accessors |
| synthetic static get F @-1 |
| returnType: int |
| topLevelVariables |
| static const V @45 |
| type: int |
| constantInitializer |
| PrefixedIdentifier |
| prefix: SimpleIdentifier |
| token: C @49 |
| staticElement: self::@class::C |
| staticType: null |
| period: . @50 |
| identifier: SimpleIdentifier |
| token: F @51 |
| staticElement: self::@class::C::@getter::F |
| staticType: int |
| staticElement: self::@class::C::@getter::F |
| staticType: int |
| accessors |
| synthetic static get V @-1 |
| returnType: int |
| '''); |
| } |
| |
| test_const_reference_staticField_imported() async { |
| addLibrarySource('/a.dart', r''' |
| class C { |
| static const int F = 42; |
| } |
| '''); |
| var library = await checkLibrary(r''' |
| import 'a.dart'; |
| const V = C.F; |
| '''); |
| checkElementText(library, r''' |
| library |
| imports |
| a.dart |
| definingUnit |
| topLevelVariables |
| static const V @23 |
| type: int |
| constantInitializer |
| PrefixedIdentifier |
| prefix: SimpleIdentifier |
| token: C @27 |
| staticElement: a.dart::@class::C |
| staticType: null |
| period: . @28 |
| identifier: SimpleIdentifier |
| token: F @29 |
| staticElement: a.dart::@class::C::@getter::F |
| staticType: int |
| staticElement: a.dart::@class::C::@getter::F |
| staticType: int |
| accessors |
| synthetic static get V @-1 |
| returnType: int |
| '''); |
| } |
| |
| test_const_reference_staticField_imported_withPrefix() async { |
| addLibrarySource('/a.dart', r''' |
| class C { |
| static const int F = 42; |
| } |
| '''); |
| var library = await checkLibrary(r''' |
| import 'a.dart' as p; |
| const V = p.C.F; |
| '''); |
| checkElementText(library, r''' |
| library |
| imports |
| a.dart as p @19 |
| definingUnit |
| topLevelVariables |
| static const V @28 |
| type: int |
| constantInitializer |
| PropertyAccess |
| target: PrefixedIdentifier |
| prefix: SimpleIdentifier |
| token: p @32 |
| staticElement: self::@prefix::p |
| staticType: null |
| period: . @33 |
| identifier: SimpleIdentifier |
| token: C @34 |
| staticElement: a.dart::@class::C |
| staticType: null |
| staticElement: a.dart::@class::C |
| staticType: null |
| operator: . @35 |
| propertyName: SimpleIdentifier |
| token: F @36 |
| staticElement: a.dart::@class::C::@getter::F |
| staticType: int |
| staticType: int |
| accessors |
| synthetic static get V @-1 |
| returnType: int |
| '''); |
| } |
| |
| test_const_reference_staticMethod() async { |
| var library = await checkLibrary(r''' |
| class C { |
| static int m(int a, String b) => 42; |
| } |
| const V = C.m; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| synthetic @-1 |
| methods |
| static m @23 |
| parameters |
| requiredPositional a @29 |
| type: int |
| requiredPositional b @39 |
| type: String |
| returnType: int |
| topLevelVariables |
| static const V @57 |
| type: int Function(int, String) |
| constantInitializer |
| PrefixedIdentifier |
| prefix: SimpleIdentifier |
| token: C @61 |
| staticElement: self::@class::C |
| staticType: null |
| period: . @62 |
| identifier: SimpleIdentifier |
| token: m @63 |
| staticElement: self::@class::C::@method::m |
| staticType: int Function(int, String) |
| staticElement: self::@class::C::@method::m |
| staticType: int Function(int, String) |
| accessors |
| synthetic static get V @-1 |
| returnType: int Function(int, String) |
| '''); |
| } |
| |
| test_const_reference_staticMethod_imported() async { |
| addLibrarySource('/a.dart', r''' |
| class C { |
| static int m(int a, String b) => 42; |
| } |
| '''); |
| var library = await checkLibrary(r''' |
| import 'a.dart'; |
| const V = C.m; |
| '''); |
| checkElementText(library, r''' |
| library |
| imports |
| a.dart |
| definingUnit |
| topLevelVariables |
| static const V @23 |
| type: int Function(int, String) |
| constantInitializer |
| PrefixedIdentifier |
| prefix: SimpleIdentifier |
| token: C @27 |
| staticElement: a.dart::@class::C |
| staticType: null |
| period: . @28 |
| identifier: SimpleIdentifier |
| token: m @29 |
| staticElement: a.dart::@class::C::@method::m |
| staticType: int Function(int, String) |
| staticElement: a.dart::@class::C::@method::m |
| staticType: int Function(int, String) |
| accessors |
| synthetic static get V @-1 |
| returnType: int Function(int, String) |
| '''); |
| } |
| |
| test_const_reference_staticMethod_imported_withPrefix() async { |
| addLibrarySource('/a.dart', r''' |
| class C { |
| static int m(int a, String b) => 42; |
| } |
| '''); |
| var library = await checkLibrary(r''' |
| import 'a.dart' as p; |
| const V = p.C.m; |
| '''); |
| checkElementText(library, r''' |
| library |
| imports |
| a.dart as p @19 |
| definingUnit |
| topLevelVariables |
| static const V @28 |
| type: int Function(int, String) |
| constantInitializer |
| PropertyAccess |
| target: PrefixedIdentifier |
| prefix: SimpleIdentifier |
| token: p @32 |
| staticElement: self::@prefix::p |
| staticType: null |
| period: . @33 |
| identifier: SimpleIdentifier |
| token: C @34 |
| staticElement: a.dart::@class::C |
| staticType: null |
| staticElement: a.dart::@class::C |
| staticType: null |
| operator: . @35 |
| propertyName: SimpleIdentifier |
| token: m @36 |
| staticElement: a.dart::@class::C::@method::m |
| staticType: int Function(int, String) |
| staticType: int Function(int, String) |
| accessors |
| synthetic static get V @-1 |
| returnType: int Function(int, String) |
| '''); |
| } |
| |
| test_const_reference_staticMethod_ofExtension() async { |
| var library = await checkLibrary(''' |
| class A {} |
| extension E on A { |
| static void f() {} |
| } |
| const x = E.f; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class A @6 |
| constructors |
| synthetic @-1 |
| extensions |
| E @21 |
| extendedType: A |
| methods |
| static f @44 |
| returnType: void |
| topLevelVariables |
| static const x @59 |
| type: void Function() |
| constantInitializer |
| PrefixedIdentifier |
| prefix: SimpleIdentifier |
| token: E @63 |
| staticElement: self::@extension::E |
| staticType: null |
| period: . @64 |
| identifier: SimpleIdentifier |
| token: f @65 |
| staticElement: self::@extension::E::@method::f |
| staticType: void Function() |
| staticElement: self::@extension::E::@method::f |
| staticType: void Function() |
| accessors |
| synthetic static get x @-1 |
| returnType: void Function() |
| '''); |
| } |
| |
| test_const_reference_topLevelFunction() async { |
| var library = await checkLibrary(r''' |
| foo() {} |
| const V = foo; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const V @15 |
| type: dynamic Function() |
| constantInitializer |
| SimpleIdentifier |
| token: foo @19 |
| staticElement: self::@function::foo |
| staticType: dynamic Function() |
| accessors |
| synthetic static get V @-1 |
| returnType: dynamic Function() |
| functions |
| foo @0 |
| returnType: dynamic |
| '''); |
| } |
| |
| test_const_reference_topLevelFunction_generic() async { |
| var library = await checkLibrary(r''' |
| R foo<P, R>(P p) {} |
| const V = foo; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const V @26 |
| type: R Function<P, R>(P) |
| constantInitializer |
| SimpleIdentifier |
| token: foo @30 |
| staticElement: self::@function::foo |
| staticType: R Function<P, R>(P) |
| accessors |
| synthetic static get V @-1 |
| returnType: R Function<P, R>(P) |
| functions |
| foo @2 |
| typeParameters |
| covariant P @6 |
| covariant R @9 |
| parameters |
| requiredPositional p @14 |
| type: P |
| returnType: R |
| '''); |
| } |
| |
| test_const_reference_topLevelFunction_imported() async { |
| addLibrarySource('/a.dart', r''' |
| foo() {} |
| '''); |
| var library = await checkLibrary(r''' |
| import 'a.dart'; |
| const V = foo; |
| '''); |
| checkElementText(library, r''' |
| library |
| imports |
| a.dart |
| definingUnit |
| topLevelVariables |
| static const V @23 |
| type: dynamic Function() |
| constantInitializer |
| SimpleIdentifier |
| token: foo @27 |
| staticElement: a.dart::@function::foo |
| staticType: dynamic Function() |
| accessors |
| synthetic static get V @-1 |
| returnType: dynamic Function() |
| '''); |
| } |
| |
| test_const_reference_topLevelFunction_imported_withPrefix() async { |
| addLibrarySource('/a.dart', r''' |
| foo() {} |
| '''); |
| var library = await checkLibrary(r''' |
| import 'a.dart' as p; |
| const V = p.foo; |
| '''); |
| checkElementText(library, r''' |
| library |
| imports |
| a.dart as p @19 |
| definingUnit |
| topLevelVariables |
| static const V @28 |
| type: dynamic Function() |
| constantInitializer |
| PrefixedIdentifier |
| prefix: SimpleIdentifier |
| token: p @32 |
| staticElement: self::@prefix::p |
| staticType: null |
| period: . @33 |
| identifier: SimpleIdentifier |
| token: foo @34 |
| staticElement: a.dart::@function::foo |
| staticType: dynamic Function() |
| staticElement: a.dart::@function::foo |
| staticType: dynamic Function() |
| accessors |
| synthetic static get V @-1 |
| returnType: dynamic Function() |
| '''); |
| } |
| |
| test_const_reference_topLevelVariable() async { |
| var library = await checkLibrary(r''' |
| const A = 1; |
| const B = A + 2; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const A @6 |
| type: int |
| constantInitializer |
| IntegerLiteral |
| literal: 1 @10 |
| staticType: int |
| static const B @19 |
| type: int |
| constantInitializer |
| BinaryExpression |
| leftOperand: SimpleIdentifier |
| token: A @23 |
| staticElement: self::@getter::A |
| staticType: int |
| operator: + @25 |
| rightOperand: IntegerLiteral |
| literal: 2 @27 |
| staticType: int |
| staticElement: dart:core::@class::num::@method::+ |
| staticInvokeType: num Function(num) |
| staticType: int |
| accessors |
| synthetic static get A @-1 |
| returnType: int |
| synthetic static get B @-1 |
| returnType: int |
| '''); |
| } |
| |
| test_const_reference_topLevelVariable_imported() async { |
| addLibrarySource('/a.dart', r''' |
| const A = 1; |
| '''); |
| var library = await checkLibrary(r''' |
| import 'a.dart'; |
| const B = A + 2; |
| '''); |
| checkElementText(library, r''' |
| library |
| imports |
| a.dart |
| definingUnit |
| topLevelVariables |
| static const B @23 |
| type: int |
| constantInitializer |
| BinaryExpression |
| leftOperand: SimpleIdentifier |
| token: A @27 |
| staticElement: a.dart::@getter::A |
| staticType: int |
| operator: + @29 |
| rightOperand: IntegerLiteral |
| literal: 2 @31 |
| staticType: int |
| staticElement: dart:core::@class::num::@method::+ |
| staticInvokeType: num Function(num) |
| staticType: int |
| accessors |
| synthetic static get B @-1 |
| returnType: int |
| '''); |
| } |
| |
| test_const_reference_topLevelVariable_imported_withPrefix() async { |
| addLibrarySource('/a.dart', r''' |
| const A = 1; |
| '''); |
| var library = await checkLibrary(r''' |
| import 'a.dart' as p; |
| const B = p.A + 2; |
| '''); |
| checkElementText(library, r''' |
| library |
| imports |
| a.dart as p @19 |
| definingUnit |
| topLevelVariables |
| static const B @28 |
| type: int |
| constantInitializer |
| BinaryExpression |
| leftOperand: PrefixedIdentifier |
| prefix: SimpleIdentifier |
| token: p @32 |
| staticElement: self::@prefix::p |
| staticType: null |
| period: . @33 |
| identifier: SimpleIdentifier |
| token: A @34 |
| staticElement: a.dart::@getter::A |
| staticType: int |
| staticElement: a.dart::@getter::A |
| staticType: int |
| operator: + @36 |
| rightOperand: IntegerLiteral |
| literal: 2 @38 |
| staticType: int |
| staticElement: dart:core::@class::num::@method::+ |
| staticInvokeType: num Function(num) |
| staticType: int |
| accessors |
| synthetic static get B @-1 |
| returnType: int |
| '''); |
| } |
| |
| test_const_reference_type() async { |
| var library = await checkLibrary(r''' |
| class C {} |
| class D<T> {} |
| enum E {a, b, c} |
| typedef F(int a, String b); |
| const vDynamic = dynamic; |
| const vNull = Null; |
| const vObject = Object; |
| const vClass = C; |
| const vGenericClass = D; |
| const vEnum = E; |
| const vFunctionTypeAlias = F; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| synthetic @-1 |
| class D @17 |
| typeParameters |
| covariant T @19 |
| defaultType: dynamic |
| constructors |
| synthetic @-1 |
| enums |
| enum E @30 |
| supertype: Enum |
| fields |
| static const enumConstant a @33 |
| type: E |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: self::@enum::E::@constructor::• |
| staticType: null |
| staticElement: self::@enum::E::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| static const enumConstant b @36 |
| type: E |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: self::@enum::E::@constructor::• |
| staticType: null |
| staticElement: self::@enum::E::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| static const enumConstant c @39 |
| type: E |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: self::@enum::E::@constructor::• |
| staticType: null |
| staticElement: self::@enum::E::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: a @-1 |
| staticElement: self::@enum::E::@getter::a |
| staticType: E |
| SimpleIdentifier |
| token: b @-1 |
| staticElement: self::@enum::E::@getter::b |
| staticType: E |
| SimpleIdentifier |
| token: c @-1 |
| staticElement: self::@enum::E::@getter::c |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| constructors |
| synthetic const @-1 |
| accessors |
| synthetic static get a @-1 |
| returnType: E |
| synthetic static get b @-1 |
| returnType: E |
| synthetic static get c @-1 |
| returnType: E |
| synthetic static get values @-1 |
| returnType: List<E> |
| typeAliases |
| functionTypeAliasBased F @50 |
| aliasedType: dynamic Function(int, String) |
| aliasedElement: GenericFunctionTypeElement |
| parameters |
| requiredPositional a @56 |
| type: int |
| requiredPositional b @66 |
| type: String |
| returnType: dynamic |
| topLevelVariables |
| static const vDynamic @76 |
| type: Type |
| constantInitializer |
| SimpleIdentifier |
| token: dynamic @87 |
| staticElement: dynamic@-1 |
| staticType: Type |
| static const vNull @102 |
| type: Type |
| constantInitializer |
| SimpleIdentifier |
| token: Null @110 |
| staticElement: dart:core::@class::Null |
| staticType: Type |
| static const vObject @122 |
| type: Type |
| constantInitializer |
| SimpleIdentifier |
| token: Object @132 |
| staticElement: dart:core::@class::Object |
| staticType: Type |
| static const vClass @146 |
| type: Type |
| constantInitializer |
| SimpleIdentifier |
| token: C @155 |
| staticElement: self::@class::C |
| staticType: Type |
| static const vGenericClass @164 |
| type: Type |
| constantInitializer |
| SimpleIdentifier |
| token: D @180 |
| staticElement: self::@class::D |
| staticType: Type |
| static const vEnum @189 |
| type: Type |
| constantInitializer |
| SimpleIdentifier |
| token: E @197 |
| staticElement: self::@enum::E |
| staticType: Type |
| static const vFunctionTypeAlias @206 |
| type: Type |
| constantInitializer |
| SimpleIdentifier |
| token: F @227 |
| staticElement: self::@typeAlias::F |
| staticType: Type |
| accessors |
| synthetic static get vDynamic @-1 |
| returnType: Type |
| synthetic static get vNull @-1 |
| returnType: Type |
| synthetic static get vObject @-1 |
| returnType: Type |
| synthetic static get vClass @-1 |
| returnType: Type |
| synthetic static get vGenericClass @-1 |
| returnType: Type |
| synthetic static get vEnum @-1 |
| returnType: Type |
| synthetic static get vFunctionTypeAlias @-1 |
| returnType: Type |
| '''); |
| } |
| |
| test_const_reference_type_functionType() async { |
| var library = await checkLibrary(r''' |
| typedef F(); |
| class C { |
| final f = <F>[]; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @19 |
| fields |
| final f @31 |
| type: List<dynamic Function()> |
| constructors |
| synthetic @-1 |
| accessors |
| synthetic get f @-1 |
| returnType: List<dynamic Function()> |
| typeAliases |
| functionTypeAliasBased F @8 |
| aliasedType: dynamic Function() |
| aliasedElement: GenericFunctionTypeElement |
| returnType: dynamic |
| '''); |
| } |
| |
| test_const_reference_type_imported() async { |
| addLibrarySource('/a.dart', r''' |
| class C {} |
| enum E {a, b, c} |
| typedef F(int a, String b); |
| '''); |
| var library = await checkLibrary(r''' |
| import 'a.dart'; |
| const vClass = C; |
| const vEnum = E; |
| const vFunctionTypeAlias = F; |
| '''); |
| checkElementText(library, r''' |
| library |
| imports |
| a.dart |
| definingUnit |
| topLevelVariables |
| static const vClass @23 |
| type: Type |
| constantInitializer |
| SimpleIdentifier |
| token: C @32 |
| staticElement: a.dart::@class::C |
| staticType: Type |
| static const vEnum @41 |
| type: Type |
| constantInitializer |
| SimpleIdentifier |
| token: E @49 |
| staticElement: a.dart::@enum::E |
| staticType: Type |
| static const vFunctionTypeAlias @58 |
| type: Type |
| constantInitializer |
| SimpleIdentifier |
| token: F @79 |
| staticElement: a.dart::@typeAlias::F |
| staticType: Type |
| accessors |
| synthetic static get vClass @-1 |
| returnType: Type |
| synthetic static get vEnum @-1 |
| returnType: Type |
| synthetic static get vFunctionTypeAlias @-1 |
| returnType: Type |
| '''); |
| } |
| |
| test_const_reference_type_imported_withPrefix() async { |
| addLibrarySource('/a.dart', r''' |
| class C {} |
| enum E {a, b, c} |
| typedef F(int a, String b); |
| '''); |
| var library = await checkLibrary(r''' |
| import 'a.dart' as p; |
| const vClass = p.C; |
| const vEnum = p.E; |
| const vFunctionTypeAlias = p.F; |
| '''); |
| checkElementText(library, r''' |
| library |
| imports |
| a.dart as p @19 |
| definingUnit |
| topLevelVariables |
| static const vClass @28 |
| type: Type |
| constantInitializer |
| PrefixedIdentifier |
| prefix: SimpleIdentifier |
| token: p @37 |
| staticElement: self::@prefix::p |
| staticType: null |
| period: . @38 |
| identifier: SimpleIdentifier |
| token: C @39 |
| staticElement: a.dart::@class::C |
| staticType: Type |
| staticElement: a.dart::@class::C |
| staticType: Type |
| static const vEnum @48 |
| type: Type |
| constantInitializer |
| PrefixedIdentifier |
| prefix: SimpleIdentifier |
| token: p @56 |
| staticElement: self::@prefix::p |
| staticType: null |
| period: . @57 |
| identifier: SimpleIdentifier |
| token: E @58 |
| staticElement: a.dart::@enum::E |
| staticType: Type |
| staticElement: a.dart::@enum::E |
| staticType: Type |
| static const vFunctionTypeAlias @67 |
| type: Type |
| constantInitializer |
| PrefixedIdentifier |
| prefix: SimpleIdentifier |
| token: p @88 |
| staticElement: self::@prefix::p |
| staticType: null |
| period: . @89 |
| identifier: SimpleIdentifier |
| token: F @90 |
| staticElement: a.dart::@typeAlias::F |
| staticType: Type |
| staticElement: a.dart::@typeAlias::F |
| staticType: Type |
| accessors |
| synthetic static get vClass @-1 |
| returnType: Type |
| synthetic static get vEnum @-1 |
| returnType: Type |
| synthetic static get vFunctionTypeAlias @-1 |
| returnType: Type |
| '''); |
| } |
| |
| test_const_reference_type_typeParameter() async { |
| var library = await checkLibrary(r''' |
| class C<T> { |
| final f = <T>[]; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| typeParameters |
| covariant T @8 |
| defaultType: dynamic |
| fields |
| final f @21 |
| type: List<T> |
| constructors |
| synthetic @-1 |
| accessors |
| synthetic get f @-1 |
| returnType: List<T> |
| '''); |
| } |
| |
| test_const_reference_unresolved_prefix0() async { |
| var library = await checkLibrary(r''' |
| const V = foo; |
| ''', allowErrors: true); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const V @6 |
| type: dynamic |
| constantInitializer |
| SimpleIdentifier |
| token: foo @10 |
| staticElement: <null> |
| staticType: dynamic |
| accessors |
| synthetic static get V @-1 |
| returnType: dynamic |
| '''); |
| } |
| |
| test_const_reference_unresolved_prefix1() async { |
| var library = await checkLibrary(r''' |
| class C {} |
| const V = C.foo; |
| ''', allowErrors: true); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| constructors |
| synthetic @-1 |
| topLevelVariables |
| static const V @17 |
| type: dynamic |
| constantInitializer |
| PrefixedIdentifier |
| prefix: SimpleIdentifier |
| token: C @21 |
| staticElement: self::@class::C |
| staticType: null |
| period: . @22 |
| identifier: SimpleIdentifier |
| token: foo @23 |
| staticElement: <null> |
| staticType: dynamic |
| staticElement: <null> |
| staticType: dynamic |
| accessors |
| synthetic static get V @-1 |
| returnType: dynamic |
| '''); |
| } |
| |
| test_const_reference_unresolved_prefix2() async { |
| addLibrarySource('/foo.dart', ''' |
| class C {} |
| '''); |
| var library = await checkLibrary(r''' |
| import 'foo.dart' as p; |
| const V = p.C.foo; |
| ''', allowErrors: true); |
| checkElementText(library, r''' |
| library |
| imports |
| foo.dart as p @21 |
| definingUnit |
| topLevelVariables |
| static const V @30 |
| type: dynamic |
| constantInitializer |
| PropertyAccess |
| target: PrefixedIdentifier |
| prefix: SimpleIdentifier |
| token: p @34 |
| staticElement: self::@prefix::p |
| staticType: null |
| period: . @35 |
| identifier: SimpleIdentifier |
| token: C @36 |
| staticElement: foo.dart::@class::C |
| staticType: null |
| staticElement: foo.dart::@class::C |
| staticType: null |
| operator: . @37 |
| propertyName: SimpleIdentifier |
| token: foo @38 |
| staticElement: <null> |
| staticType: dynamic |
| staticType: dynamic |
| accessors |
| synthetic static get V @-1 |
| returnType: dynamic |
| '''); |
| } |
| |
| test_const_set_if() async { |
| var library = await checkLibrary(''' |
| const Object x = const <int>{if (true) 1}; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const x @13 |
| type: Object |
| constantInitializer |
| SetOrMapLiteral |
| constKeyword: const @17 |
| typeArguments: TypeArgumentList |
| leftBracket: < @23 |
| arguments |
| NamedType |
| name: SimpleIdentifier |
| token: int @24 |
| staticElement: dart:core::@class::int |
| staticType: null |
| type: int |
| rightBracket: > @27 |
| leftBracket: { @28 |
| elements |
| IfElement |
| ifKeyword: if @29 |
| leftParenthesis: ( @32 |
| condition: BooleanLiteral |
| literal: true @33 |
| staticType: bool |
| rightParenthesis: ) @37 |
| thenElement: IntegerLiteral |
| literal: 1 @39 |
| staticType: int |
| rightBracket: } @40 |
| isMap: false |
| staticType: Set<int> |
| accessors |
| synthetic static get x @-1 |
| returnType: Object |
| '''); |
| } |
| |
| test_const_set_inferredType() async { |
| // The summary needs to contain enough information so that when the constant |
| // is resynthesized, the constant value can get the type that was computed |
| // by type inference. |
| var library = await checkLibrary(''' |
| const Object x = const {1}; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const x @13 |
| type: Object |
| constantInitializer |
| SetOrMapLiteral |
| constKeyword: const @17 |
| leftBracket: { @23 |
| elements |
| IntegerLiteral |
| literal: 1 @24 |
| staticType: int |
| rightBracket: } @25 |
| isMap: false |
| staticType: Set<int> |
| accessors |
| synthetic static get x @-1 |
| returnType: Object |
| '''); |
| } |
| |
| test_const_set_spread() async { |
| var library = await checkLibrary(''' |
| const Object x = const <int>{...<int>{1}}; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const x @13 |
| type: Object |
| constantInitializer |
| SetOrMapLiteral |
| constKeyword: const @17 |
| typeArguments: TypeArgumentList |
| leftBracket: < @23 |
| arguments |
| NamedType |
| name: SimpleIdentifier |
| token: int @24 |
| staticElement: dart:core::@class::int |
| staticType: null |
| type: int |
| rightBracket: > @27 |
| leftBracket: { @28 |
| elements |
| SpreadElement |
| spreadOperator: ... @29 |
| expression: SetOrMapLiteral |
| typeArguments: TypeArgumentList |
| leftBracket: < @32 |
| arguments |
| NamedType |
| name: SimpleIdentifier |
| token: int @33 |
| staticElement: dart:core::@class::int |
| staticType: null |
| type: int |
| rightBracket: > @36 |
| leftBracket: { @37 |
| elements |
| IntegerLiteral |
| literal: 1 @38 |
| staticType: int |
| rightBracket: } @39 |
| isMap: false |
| staticType: Set<int> |
| rightBracket: } @40 |
| isMap: false |
| staticType: Set<int> |
| accessors |
| synthetic static get x @-1 |
| returnType: Object |
| '''); |
| } |
| |
| test_const_set_spread_null_aware() async { |
| var library = await checkLibrary(''' |
| const Object x = const <int>{...?<int>{1}}; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const x @13 |
| type: Object |
| constantInitializer |
| SetOrMapLiteral |
| constKeyword: const @17 |
| typeArguments: TypeArgumentList |
| leftBracket: < @23 |
| arguments |
| NamedType |
| name: SimpleIdentifier |
| token: int @24 |
| staticElement: dart:core::@class::int |
| staticType: null |
| type: int |
| rightBracket: > @27 |
| leftBracket: { @28 |
| elements |
| SpreadElement |
| spreadOperator: ...? @29 |
| expression: SetOrMapLiteral |
| typeArguments: TypeArgumentList |
| leftBracket: < @33 |
| arguments |
| NamedType |
| name: SimpleIdentifier |
| token: int @34 |
| staticElement: dart:core::@class::int |
| staticType: null |
| type: int |
| rightBracket: > @37 |
| leftBracket: { @38 |
| elements |
| IntegerLiteral |
| literal: 1 @39 |
| staticType: int |
| rightBracket: } @40 |
| isMap: false |
| staticType: Set<int> |
| rightBracket: } @41 |
| isMap: false |
| staticType: Set<int> |
| accessors |
| synthetic static get x @-1 |
| returnType: Object |
| '''); |
| } |
| |
| test_const_topLevel_binary() async { |
| var library = await checkLibrary(r''' |
| const vEqual = 1 == 2; |
| const vAnd = true && false; |
| const vOr = false || true; |
| const vBitXor = 1 ^ 2; |
| const vBitAnd = 1 & 2; |
| const vBitOr = 1 | 2; |
| const vBitShiftLeft = 1 << 2; |
| const vBitShiftRight = 1 >> 2; |
| const vAdd = 1 + 2; |
| const vSubtract = 1 - 2; |
| const vMiltiply = 1 * 2; |
| const vDivide = 1 / 2; |
| const vFloorDivide = 1 ~/ 2; |
| const vModulo = 1 % 2; |
| const vGreater = 1 > 2; |
| const vGreaterEqual = 1 >= 2; |
| const vLess = 1 < 2; |
| const vLessEqual = 1 <= 2; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const vEqual @6 |
| type: bool |
| constantInitializer |
| BinaryExpression |
| leftOperand: IntegerLiteral |
| literal: 1 @15 |
| staticType: int |
| operator: == @17 |
| rightOperand: IntegerLiteral |
| literal: 2 @20 |
| staticType: int |
| staticElement: dart:core::@class::num::@method::== |
| staticInvokeType: bool Function(Object) |
| staticType: bool |
| static const vAnd @29 |
| type: bool |
| constantInitializer |
| BinaryExpression |
| leftOperand: BooleanLiteral |
| literal: true @36 |
| staticType: bool |
| operator: && @41 |
| rightOperand: BooleanLiteral |
| literal: false @44 |
| staticType: bool |
| staticElement: <null> |
| staticInvokeType: null |
| staticType: bool |
| static const vOr @57 |
| type: bool |
| constantInitializer |
| BinaryExpression |
| leftOperand: BooleanLiteral |
| literal: false @63 |
| staticType: bool |
| operator: || @69 |
| rightOperand: BooleanLiteral |
| literal: true @72 |
| staticType: bool |
| staticElement: <null> |
| staticInvokeType: null |
| staticType: bool |
| static const vBitXor @84 |
| type: int |
| constantInitializer |
| BinaryExpression |
| leftOperand: IntegerLiteral |
| literal: 1 @94 |
| staticType: int |
| operator: ^ @96 |
| rightOperand: IntegerLiteral |
| literal: 2 @98 |
| staticType: int |
| staticElement: dart:core::@class::int::@method::^ |
| staticInvokeType: int Function(int) |
| staticType: int |
| static const vBitAnd @107 |
| type: int |
| constantInitializer |
| BinaryExpression |
| leftOperand: IntegerLiteral |
| literal: 1 @117 |
| staticType: int |
| operator: & @119 |
| rightOperand: IntegerLiteral |
| literal: 2 @121 |
| staticType: int |
| staticElement: dart:core::@class::int::@method::& |
| staticInvokeType: int Function(int) |
| staticType: int |
| static const vBitOr @130 |
| type: int |
| constantInitializer |
| BinaryExpression |
| leftOperand: IntegerLiteral |
| literal: 1 @139 |
| staticType: int |
| operator: | @141 |
| rightOperand: IntegerLiteral |
| literal: 2 @143 |
| staticType: int |
| staticElement: dart:core::@class::int::@method::| |
| staticInvokeType: int Function(int) |
| staticType: int |
| static const vBitShiftLeft @152 |
| type: int |
| constantInitializer |
| BinaryExpression |
| leftOperand: IntegerLiteral |
| literal: 1 @168 |
| staticType: int |
| operator: << @170 |
| rightOperand: IntegerLiteral |
| literal: 2 @173 |
| staticType: int |
| staticElement: dart:core::@class::int::@method::<< |
| staticInvokeType: int Function(int) |
| staticType: int |
| static const vBitShiftRight @182 |
| type: int |
| constantInitializer |
| BinaryExpression |
| leftOperand: IntegerLiteral |
| literal: 1 @199 |
| staticType: int |
| operator: >> @201 |
| rightOperand: IntegerLiteral |
| literal: 2 @204 |
| staticType: int |
| staticElement: dart:core::@class::int::@method::>> |
| staticInvokeType: int Function(int) |
| staticType: int |
| static const vAdd @213 |
| type: int |
| constantInitializer |
| BinaryExpression |
| leftOperand: IntegerLiteral |
| literal: 1 @220 |
| staticType: int |
| operator: + @222 |
| rightOperand: IntegerLiteral |
| literal: 2 @224 |
| staticType: int |
| staticElement: dart:core::@class::num::@method::+ |
| staticInvokeType: num Function(num) |
| staticType: int |
| static const vSubtract @233 |
| type: int |
| constantInitializer |
| BinaryExpression |
| leftOperand: IntegerLiteral |
| literal: 1 @245 |
| staticType: int |
| operator: - @247 |
| rightOperand: IntegerLiteral |
| literal: 2 @249 |
| staticType: int |
| staticElement: dart:core::@class::num::@method::- |
| staticInvokeType: num Function(num) |
| staticType: int |
| static const vMiltiply @258 |
| type: int |
| constantInitializer |
| BinaryExpression |
| leftOperand: IntegerLiteral |
| literal: 1 @270 |
| staticType: int |
| operator: * @272 |
| rightOperand: IntegerLiteral |
| literal: 2 @274 |
| staticType: int |
| staticElement: dart:core::@class::num::@method::* |
| staticInvokeType: num Function(num) |
| staticType: int |
| static const vDivide @283 |
| type: double |
| constantInitializer |
| BinaryExpression |
| leftOperand: IntegerLiteral |
| literal: 1 @293 |
| staticType: int |
| operator: / @295 |
| rightOperand: IntegerLiteral |
| literal: 2 @297 |
| staticType: int |
| staticElement: dart:core::@class::num::@method::/ |
| staticInvokeType: double Function(num) |
| staticType: double |
| static const vFloorDivide @306 |
| type: int |
| constantInitializer |
| BinaryExpression |
| leftOperand: IntegerLiteral |
| literal: 1 @321 |
| staticType: int |
| operator: ~/ @323 |
| rightOperand: IntegerLiteral |
| literal: 2 @326 |
| staticType: int |
| staticElement: dart:core::@class::num::@method::~/ |
| staticInvokeType: int Function(num) |
| staticType: int |
| static const vModulo @335 |
| type: int |
| constantInitializer |
| BinaryExpression |
| leftOperand: IntegerLiteral |
| literal: 1 @345 |
| staticType: int |
| operator: % @347 |
| rightOperand: IntegerLiteral |
| literal: 2 @349 |
| staticType: int |
| staticElement: dart:core::@class::num::@method::% |
| staticInvokeType: num Function(num) |
| staticType: int |
| static const vGreater @358 |
| type: bool |
| constantInitializer |
| BinaryExpression |
| leftOperand: IntegerLiteral |
| literal: 1 @369 |
| staticType: int |
| operator: > @371 |
| rightOperand: IntegerLiteral |
| literal: 2 @373 |
| staticType: int |
| staticElement: dart:core::@class::num::@method::> |
| staticInvokeType: bool Function(num) |
| staticType: bool |
| static const vGreaterEqual @382 |
| type: bool |
| constantInitializer |
| BinaryExpression |
| leftOperand: IntegerLiteral |
| literal: 1 @398 |
| staticType: int |
| operator: >= @400 |
| rightOperand: IntegerLiteral |
| literal: 2 @403 |
| staticType: int |
| staticElement: dart:core::@class::num::@method::>= |
| staticInvokeType: bool Function(num) |
| staticType: bool |
| static const vLess @412 |
| type: bool |
| constantInitializer |
| BinaryExpression |
| leftOperand: IntegerLiteral |
| literal: 1 @420 |
| staticType: int |
| operator: < @422 |
| rightOperand: IntegerLiteral |
| literal: 2 @424 |
| staticType: int |
| staticElement: dart:core::@class::num::@method::< |
| staticInvokeType: bool Function(num) |
| staticType: bool |
| static const vLessEqual @433 |
| type: bool |
| constantInitializer |
| BinaryExpression |
| leftOperand: IntegerLiteral |
| literal: 1 @446 |
| staticType: int |
| operator: <= @448 |
| rightOperand: IntegerLiteral |
| literal: 2 @451 |
| staticType: int |
| staticElement: dart:core::@class::num::@method::<= |
| staticInvokeType: bool Function(num) |
| staticType: bool |
| accessors |
| synthetic static get vEqual @-1 |
| returnType: bool |
| synthetic static get vAnd @-1 |
| returnType: bool |
| synthetic static get vOr @-1 |
| returnType: bool |
| synthetic static get vBitXor @-1 |
| returnType: int |
| synthetic static get vBitAnd @-1 |
| returnType: int |
| synthetic static get vBitOr @-1 |
| returnType: int |
| synthetic static get vBitShiftLeft @-1 |
| returnType: int |
| synthetic static get vBitShiftRight @-1 |
| returnType: int |
| synthetic static get vAdd @-1 |
| returnType: int |
| synthetic static get vSubtract @-1 |
| returnType: int |
| synthetic static get vMiltiply @-1 |
| returnType: int |
| synthetic static get vDivide @-1 |
| returnType: double |
| synthetic static get vFloorDivide @-1 |
| returnType: int |
| synthetic static get vModulo @-1 |
| returnType: int |
| synthetic static get vGreater @-1 |
| returnType: bool |
| synthetic static get vGreaterEqual @-1 |
| returnType: bool |
| synthetic static get vLess @-1 |
| returnType: bool |
| synthetic static get vLessEqual @-1 |
| returnType: bool |
| '''); |
| } |
| |
| test_const_topLevel_conditional() async { |
| var library = await checkLibrary(r''' |
| const vConditional = (1 == 2) ? 11 : 22; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const vConditional @6 |
| type: int |
| constantInitializer |
| ConditionalExpression |
| condition: ParenthesizedExpression |
| leftParenthesis: ( @21 |
| expression: BinaryExpression |
| leftOperand: IntegerLiteral |
| literal: 1 @22 |
| staticType: int |
| operator: == @24 |
| rightOperand: IntegerLiteral |
| literal: 2 @27 |
| staticType: int |
| staticElement: dart:core::@class::num::@method::== |
| staticInvokeType: bool Function(Object) |
| staticType: bool |
| rightParenthesis: ) @28 |
| staticType: bool |
| question: ? @30 |
| thenExpression: IntegerLiteral |
| literal: 11 @32 |
| staticType: int |
| colon: : @35 |
| elseExpression: IntegerLiteral |
| literal: 22 @37 |
| staticType: int |
| staticType: int |
| accessors |
| synthetic static get vConditional @-1 |
| returnType: int |
| '''); |
| } |
| |
| test_const_topLevel_identical() async { |
| var library = await checkLibrary(r''' |
| const vIdentical = (1 == 2) ? 11 : 22; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const vIdentical @6 |
| type: int |
| constantInitializer |
| ConditionalExpression |
| condition: ParenthesizedExpression |
| leftParenthesis: ( @19 |
| expression: BinaryExpression |
| leftOperand: IntegerLiteral |
| literal: 1 @20 |
| staticType: int |
| operator: == @22 |
| rightOperand: IntegerLiteral |
| literal: 2 @25 |
| staticType: int |
| staticElement: dart:core::@class::num::@method::== |
| staticInvokeType: bool Function(Object) |
| staticType: bool |
| rightParenthesis: ) @26 |
| staticType: bool |
| question: ? @28 |
| thenExpression: IntegerLiteral |
| literal: 11 @30 |
| staticType: int |
| colon: : @33 |
| elseExpression: IntegerLiteral |
| literal: 22 @35 |
| staticType: int |
| staticType: int |
| accessors |
| synthetic static get vIdentical @-1 |
| returnType: int |
| '''); |
| } |
| |
| test_const_topLevel_ifNull() async { |
| var library = await checkLibrary(r''' |
| const vIfNull = 1 ?? 2.0; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const vIfNull @6 |
| type: num |
| constantInitializer |
| BinaryExpression |
| leftOperand: IntegerLiteral |
| literal: 1 @16 |
| staticType: int |
| operator: ?? @18 |
| rightOperand: DoubleLiteral |
| literal: 2.0 @21 |
| staticType: double |
| staticElement: <null> |
| staticInvokeType: null |
| staticType: num |
| accessors |
| synthetic static get vIfNull @-1 |
| returnType: num |
| '''); |
| } |
| |
| test_const_topLevel_literal() async { |
| var library = await checkLibrary(r''' |
| const vNull = null; |
| const vBoolFalse = false; |
| const vBoolTrue = true; |
| const vIntPositive = 1; |
| const vIntNegative = -2; |
| const vIntLong1 = 0x7FFFFFFFFFFFFFFF; |
| const vIntLong2 = 0xFFFFFFFFFFFFFFFF; |
| const vIntLong3 = 0x8000000000000000; |
| const vDouble = 2.3; |
| const vString = 'abc'; |
| const vStringConcat = 'aaa' 'bbb'; |
| const vStringInterpolation = 'aaa ${true} ${42} bbb'; |
| const vSymbol = #aaa.bbb.ccc; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const vNull @6 |
| type: dynamic |
| constantInitializer |
| NullLiteral |
| literal: null @14 |
| staticType: Null |
| static const vBoolFalse @26 |
| type: bool |
| constantInitializer |
| BooleanLiteral |
| literal: false @39 |
| staticType: bool |
| static const vBoolTrue @52 |
| type: bool |
| constantInitializer |
| BooleanLiteral |
| literal: true @64 |
| staticType: bool |
| static const vIntPositive @76 |
| type: int |
| constantInitializer |
| IntegerLiteral |
| literal: 1 @91 |
| staticType: int |
| static const vIntNegative @100 |
| type: int |
| constantInitializer |
| PrefixExpression |
| operator: - @115 |
| operand: IntegerLiteral |
| literal: 2 @116 |
| staticType: int |
| staticElement: dart:core::@class::int::@method::unary- |
| staticType: int |
| static const vIntLong1 @125 |
| type: int |
| constantInitializer |
| IntegerLiteral |
| literal: 0x7FFFFFFFFFFFFFFF @137 |
| staticType: int |
| static const vIntLong2 @163 |
| type: int |
| constantInitializer |
| IntegerLiteral |
| literal: 0xFFFFFFFFFFFFFFFF @175 |
| staticType: int |
| static const vIntLong3 @201 |
| type: int |
| constantInitializer |
| IntegerLiteral |
| literal: 0x8000000000000000 @213 |
| staticType: int |
| static const vDouble @239 |
| type: double |
| constantInitializer |
| DoubleLiteral |
| literal: 2.3 @249 |
| staticType: double |
| static const vString @260 |
| type: String |
| constantInitializer |
| SimpleStringLiteral |
| literal: 'abc' @270 |
| static const vStringConcat @283 |
| type: String |
| constantInitializer |
| AdjacentStrings |
| strings |
| SimpleStringLiteral |
| literal: 'aaa' @299 |
| SimpleStringLiteral |
| literal: 'bbb' @305 |
| staticType: String |
| stringValue: aaabbb |
| static const vStringInterpolation @318 |
| type: String |
| constantInitializer |
| StringInterpolation |
| elements |
| InterpolationString |
| contents: 'aaa @341 |
| InterpolationExpression |
| leftBracket: ${ @346 |
| expression: BooleanLiteral |
| literal: true @348 |
| staticType: bool |
| rightBracket: } @352 |
| InterpolationString |
| contents: @353 |
| InterpolationExpression |
| leftBracket: ${ @354 |
| expression: IntegerLiteral |
| literal: 42 @356 |
| staticType: int |
| rightBracket: } @358 |
| InterpolationString |
| contents: bbb' @359 |
| staticType: String |
| stringValue: null |
| static const vSymbol @372 |
| type: Symbol |
| constantInitializer |
| SymbolLiteral |
| poundSign: # @382 |
| components |
| components: aaa |
| offset: 383 |
| components: bbb |
| offset: 387 |
| components: ccc |
| offset: 391 |
| accessors |
| synthetic static get vNull @-1 |
| returnType: dynamic |
| synthetic static get vBoolFalse @-1 |
| returnType: bool |
| synthetic static get vBoolTrue @-1 |
| returnType: bool |
| synthetic static get vIntPositive @-1 |
| returnType: int |
| synthetic static get vIntNegative @-1 |
| returnType: int |
| synthetic static get vIntLong1 @-1 |
| returnType: int |
| synthetic static get vIntLong2 @-1 |
| returnType: int |
| synthetic static get vIntLong3 @-1 |
| returnType: int |
| synthetic static get vDouble @-1 |
| returnType: double |
| synthetic static get vString @-1 |
| returnType: String |
| synthetic static get vStringConcat @-1 |
| returnType: String |
| synthetic static get vStringInterpolation @-1 |
| returnType: String |
| synthetic static get vSymbol @-1 |
| returnType: Symbol |
| '''); |
| } |
| |
| test_const_topLevel_methodInvocation_questionPeriod() async { |
| var library = await checkLibrary(r''' |
| const int? a = 0; |
| const b = a?.toString(); |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const a @11 |
| type: int? |
| constantInitializer |
| IntegerLiteral |
| literal: 0 @15 |
| staticType: int |
| static const b @24 |
| type: String? |
| constantInitializer |
| MethodInvocation |
| target: SimpleIdentifier |
| token: a @28 |
| staticElement: self::@getter::a |
| staticType: int? |
| operator: ?. @29 |
| methodName: SimpleIdentifier |
| token: toString @31 |
| staticElement: dart:core::@class::int::@method::toString |
| staticType: String Function() |
| argumentList: ArgumentList |
| leftParenthesis: ( @39 |
| rightParenthesis: ) @40 |
| staticInvokeType: String Function() |
| staticType: String? |
| accessors |
| synthetic static get a @-1 |
| returnType: int? |
| synthetic static get b @-1 |
| returnType: String? |
| '''); |
| } |
| |
| test_const_topLevel_methodInvocation_questionPeriodPeriod() async { |
| var library = await checkLibrary(r''' |
| const int? a = 0; |
| const b = a?..toString(); |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const a @11 |
| type: int? |
| constantInitializer |
| IntegerLiteral |
| literal: 0 @15 |
| staticType: int |
| static const b @24 |
| type: int? |
| constantInitializer |
| CascadeExpression |
| target: SimpleIdentifier |
| token: a @28 |
| staticElement: self::@getter::a |
| staticType: int? |
| cascadeSections |
| MethodInvocation |
| operator: ?.. @29 |
| methodName: SimpleIdentifier |
| token: toString @32 |
| staticElement: dart:core::@class::int::@method::toString |
| staticType: String Function() |
| argumentList: ArgumentList |
| leftParenthesis: ( @40 |
| rightParenthesis: ) @41 |
| staticInvokeType: String Function() |
| staticType: String |
| staticType: int? |
| accessors |
| synthetic static get a @-1 |
| returnType: int? |
| synthetic static get b @-1 |
| returnType: int? |
| '''); |
| } |
| |
| test_const_topLevel_nullSafe_nullAware_propertyAccess() async { |
| var library = await checkLibrary(r''' |
| const String? a = ''; |
| |
| const List<int?> b = [ |
| a?.length, |
| ]; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const a @14 |
| type: String? |
| constantInitializer |
| SimpleStringLiteral |
| literal: '' @18 |
| static const b @40 |
| type: List<int?> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @44 |
| elements |
| PropertyAccess |
| target: SimpleIdentifier |
| token: a @48 |
| staticElement: self::@getter::a |
| staticType: String? |
| operator: ?. @49 |
| propertyName: SimpleIdentifier |
| token: length @51 |
| staticElement: dart:core::@class::String::@getter::length |
| staticType: int |
| staticType: int? |
| rightBracket: ] @59 |
| staticType: List<int?> |
| accessors |
| synthetic static get a @-1 |
| returnType: String? |
| synthetic static get b @-1 |
| returnType: List<int?> |
| '''); |
| } |
| |
| test_const_topLevel_parenthesis() async { |
| var library = await checkLibrary(r''' |
| const int v1 = (1 + 2) * 3; |
| const int v2 = -(1 + 2); |
| const int v3 = ('aaa' + 'bbb').length; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const v1 @10 |
| type: int |
| constantInitializer |
| BinaryExpression |
| leftOperand: ParenthesizedExpression |
| leftParenthesis: ( @15 |
| expression: BinaryExpression |
| leftOperand: IntegerLiteral |
| literal: 1 @16 |
| staticType: int |
| operator: + @18 |
| rightOperand: IntegerLiteral |
| literal: 2 @20 |
| staticType: int |
| staticElement: dart:core::@class::num::@method::+ |
| staticInvokeType: num Function(num) |
| staticType: int |
| rightParenthesis: ) @21 |
| staticType: int |
| operator: * @23 |
| rightOperand: IntegerLiteral |
| literal: 3 @25 |
| staticType: int |
| staticElement: dart:core::@class::num::@method::* |
| staticInvokeType: num Function(num) |
| staticType: int |
| static const v2 @38 |
| type: int |
| constantInitializer |
| PrefixExpression |
| operator: - @43 |
| operand: ParenthesizedExpression |
| leftParenthesis: ( @44 |
| expression: BinaryExpression |
| leftOperand: IntegerLiteral |
| literal: 1 @45 |
| staticType: int |
| operator: + @47 |
| rightOperand: IntegerLiteral |
| literal: 2 @49 |
| staticType: int |
| staticElement: dart:core::@class::num::@method::+ |
| staticInvokeType: num Function(num) |
| staticType: int |
| rightParenthesis: ) @50 |
| staticType: int |
| staticElement: dart:core::@class::int::@method::unary- |
| staticType: int |
| static const v3 @63 |
| type: int |
| constantInitializer |
| PropertyAccess |
| target: ParenthesizedExpression |
| leftParenthesis: ( @68 |
| expression: BinaryExpression |
| leftOperand: SimpleStringLiteral |
| literal: 'aaa' @69 |
| operator: + @75 |
| rightOperand: SimpleStringLiteral |
| literal: 'bbb' @77 |
| staticElement: dart:core::@class::String::@method::+ |
| staticInvokeType: String Function(String) |
| staticType: String |
| rightParenthesis: ) @82 |
| staticType: String |
| operator: . @83 |
| propertyName: SimpleIdentifier |
| token: length @84 |
| staticElement: dart:core::@class::String::@getter::length |
| staticType: int |
| staticType: int |
| accessors |
| synthetic static get v1 @-1 |
| returnType: int |
| synthetic static get v2 @-1 |
| returnType: int |
| synthetic static get v3 @-1 |
| returnType: int |
| '''); |
| } |
| |
| test_const_topLevel_prefix() async { |
| var library = await checkLibrary(r''' |
| const vNotEqual = 1 != 2; |
| const vNot = !true; |
| const vNegate = -1; |
| const vComplement = ~1; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const vNotEqual @6 |
| type: bool |
| constantInitializer |
| BinaryExpression |
| leftOperand: IntegerLiteral |
| literal: 1 @18 |
| staticType: int |
| operator: != @20 |
| rightOperand: IntegerLiteral |
| literal: 2 @23 |
| staticType: int |
| staticElement: dart:core::@class::num::@method::== |
| staticInvokeType: bool Function(Object) |
| staticType: bool |
| static const vNot @32 |
| type: bool |
| constantInitializer |
| PrefixExpression |
| operator: ! @39 |
| operand: BooleanLiteral |
| literal: true @40 |
| staticType: bool |
| staticElement: <null> |
| staticType: bool |
| static const vNegate @52 |
| type: int |
| constantInitializer |
| PrefixExpression |
| operator: - @62 |
| operand: IntegerLiteral |
| literal: 1 @63 |
| staticType: int |
| staticElement: dart:core::@class::int::@method::unary- |
| staticType: int |
| static const vComplement @72 |
| type: int |
| constantInitializer |
| PrefixExpression |
| operator: ~ @86 |
| operand: IntegerLiteral |
| literal: 1 @87 |
| staticType: int |
| staticElement: dart:core::@class::int::@method::~ |
| staticType: int |
| accessors |
| synthetic static get vNotEqual @-1 |
| returnType: bool |
| synthetic static get vNot @-1 |
| returnType: bool |
| synthetic static get vNegate @-1 |
| returnType: int |
| synthetic static get vComplement @-1 |
| returnType: int |
| '''); |
| } |
| |
| test_const_topLevel_super() async { |
| var library = await checkLibrary(r''' |
| const vSuper = super; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const vSuper @6 |
| type: dynamic |
| constantInitializer |
| SuperExpression |
| superKeyword: super @15 |
| staticType: dynamic |
| accessors |
| synthetic static get vSuper @-1 |
| returnType: dynamic |
| '''); |
| } |
| |
| test_const_topLevel_this() async { |
| var library = await checkLibrary(r''' |
| const vThis = this; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const vThis @6 |
| type: dynamic |
| constantInitializer |
| ThisExpression |
| thisKeyword: this @14 |
| staticType: dynamic |
| accessors |
| synthetic static get vThis @-1 |
| returnType: dynamic |
| '''); |
| } |
| |
| test_const_topLevel_throw() async { |
| var library = await checkLibrary(r''' |
| const c = throw 42; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const c @6 |
| type: Never |
| constantInitializer |
| ThrowExpression |
| throwKeyword: throw @10 |
| expression: IntegerLiteral |
| literal: 42 @16 |
| staticType: int |
| staticType: Never |
| accessors |
| synthetic static get c @-1 |
| returnType: Never |
| '''); |
| } |
| |
| test_const_topLevel_throw_legacy() async { |
| featureSet = FeatureSets.language_2_9; |
| var library = await checkLibrary(r''' |
| const c = throw 42; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const c @6 |
| type: dynamic |
| constantInitializer |
| ThrowExpression |
| throwKeyword: throw @10 |
| expression: IntegerLiteral |
| literal: 42 @16 |
| staticType: int* |
| staticType: Never* |
| accessors |
| synthetic static get c @-1 |
| returnType: dynamic |
| '''); |
| } |
| |
| test_const_topLevel_typedList() async { |
| var library = await checkLibrary(r''' |
| const vNull = const <Null>[]; |
| const vDynamic = const <dynamic>[1, 2, 3]; |
| const vInterfaceNoTypeParameters = const <int>[1, 2, 3]; |
| const vInterfaceNoTypeArguments = const <List>[]; |
| const vInterfaceWithTypeArguments = const <List<String>>[]; |
| const vInterfaceWithTypeArguments2 = const <Map<int, List<String>>>[]; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const vNull @6 |
| type: List<Null> |
| constantInitializer |
| ListLiteral |
| constKeyword: const @14 |
| typeArguments: TypeArgumentList |
| leftBracket: < @20 |
| arguments |
| NamedType |
| name: SimpleIdentifier |
| token: Null @21 |
| staticElement: dart:core::@class::Null |
| staticType: null |
| type: Null |
| rightBracket: > @25 |
| leftBracket: [ @26 |
| rightBracket: ] @27 |
| staticType: List<Null> |
| static const vDynamic @36 |
| type: List<dynamic> |
| constantInitializer |
| ListLiteral |
| constKeyword: const @47 |
| typeArguments: TypeArgumentList |
| leftBracket: < @53 |
| arguments |
| NamedType |
| name: SimpleIdentifier |
| token: dynamic @54 |
| staticElement: dynamic@-1 |
| staticType: null |
| type: dynamic |
| rightBracket: > @61 |
| leftBracket: [ @62 |
| elements |
| IntegerLiteral |
| literal: 1 @63 |
| staticType: int |
| IntegerLiteral |
| literal: 2 @66 |
| staticType: int |
| IntegerLiteral |
| literal: 3 @69 |
| staticType: int |
| rightBracket: ] @70 |
| staticType: List<dynamic> |
| static const vInterfaceNoTypeParameters @79 |
| type: List<int> |
| constantInitializer |
| ListLiteral |
| constKeyword: const @108 |
| typeArguments: TypeArgumentList |
| leftBracket: < @114 |
| arguments |
| NamedType |
| name: SimpleIdentifier |
| token: int @115 |
| staticElement: dart:core::@class::int |
| staticType: null |
| type: int |
| rightBracket: > @118 |
| leftBracket: [ @119 |
| elements |
| IntegerLiteral |
| literal: 1 @120 |
| staticType: int |
| IntegerLiteral |
| literal: 2 @123 |
| staticType: int |
| IntegerLiteral |
| literal: 3 @126 |
| staticType: int |
| rightBracket: ] @127 |
| staticType: List<int> |
| static const vInterfaceNoTypeArguments @136 |
| type: List<List<dynamic>> |
| constantInitializer |
| ListLiteral |
| constKeyword: const @164 |
| typeArguments: TypeArgumentList |
| leftBracket: < @170 |
| arguments |
| NamedType |
| name: SimpleIdentifier |
| token: List @171 |
| staticElement: dart:core::@class::List |
| staticType: null |
| type: List<dynamic> |
| rightBracket: > @175 |
| leftBracket: [ @176 |
| rightBracket: ] @177 |
| staticType: List<List<dynamic>> |
| static const vInterfaceWithTypeArguments @186 |
| type: List<List<String>> |
| constantInitializer |
| ListLiteral |
| constKeyword: const @216 |
| typeArguments: TypeArgumentList |
| leftBracket: < @222 |
| arguments |
| NamedType |
| name: SimpleIdentifier |
| token: List @223 |
| staticElement: dart:core::@class::List |
| staticType: null |
| typeArguments: TypeArgumentList |
| leftBracket: < @227 |
| arguments |
| NamedType |
| name: SimpleIdentifier |
| token: String @228 |
| staticElement: dart:core::@class::String |
| staticType: null |
| type: String |
| rightBracket: > @234 |
| type: List<String> |
| rightBracket: > @235 |
| leftBracket: [ @236 |
| rightBracket: ] @237 |
| staticType: List<List<String>> |
| static const vInterfaceWithTypeArguments2 @246 |
| type: List<Map<int, List<String>>> |
| constantInitializer |
| ListLiteral |
| constKeyword: const @277 |
| typeArguments: TypeArgumentList |
| leftBracket: < @283 |
| arguments |
| NamedType |
| name: SimpleIdentifier |
| token: Map @284 |
| staticElement: dart:core::@class::Map |
| staticType: null |
| typeArguments: TypeArgumentList |
| leftBracket: < @287 |
| arguments |
| NamedType |
| name: SimpleIdentifier |
| token: int @288 |
| staticElement: dart:core::@class::int |
| staticType: null |
| type: int |
| NamedType |
| name: SimpleIdentifier |
| token: List @293 |
| staticElement: dart:core::@class::List |
| staticType: null |
| typeArguments: TypeArgumentList |
| leftBracket: < @297 |
| arguments |
| NamedType |
| name: SimpleIdentifier |
| token: String @298 |
| staticElement: dart:core::@class::String |
| staticType: null |
| type: String |
| rightBracket: > @304 |
| type: List<String> |
| rightBracket: > @305 |
| type: Map<int, List<String>> |
| rightBracket: > @306 |
| leftBracket: [ @307 |
| rightBracket: ] @308 |
| staticType: List<Map<int, List<String>>> |
| accessors |
| synthetic static get vNull @-1 |
| returnType: List<Null> |
| synthetic static get vDynamic @-1 |
| returnType: List<dynamic> |
| synthetic static get vInterfaceNoTypeParameters @-1 |
| returnType: List<int> |
| synthetic static get vInterfaceNoTypeArguments @-1 |
| returnType: List<List<dynamic>> |
| synthetic static get vInterfaceWithTypeArguments @-1 |
| returnType: List<List<String>> |
| synthetic static get vInterfaceWithTypeArguments2 @-1 |
| returnType: List<Map<int, List<String>>> |
| '''); |
| } |
| |
| test_const_topLevel_typedList_imported() async { |
| addLibrarySource('/a.dart', 'class C {}'); |
| var library = await checkLibrary(r''' |
| import 'a.dart'; |
| const v = const <C>[]; |
| '''); |
| checkElementText(library, r''' |
| library |
| imports |
| a.dart |
| definingUnit |
| topLevelVariables |
| static const v @23 |
| type: List<C> |
| constantInitializer |
| ListLiteral |
| constKeyword: const @27 |
| typeArguments: TypeArgumentList |
| leftBracket: < @33 |
| arguments |
| NamedType |
| name: SimpleIdentifier |
| token: C @34 |
| staticElement: a.dart::@class::C |
| staticType: null |
| type: C |
| rightBracket: > @35 |
| leftBracket: [ @36 |
| rightBracket: ] @37 |
| staticType: List<C> |
| accessors |
| synthetic static get v @-1 |
| returnType: List<C> |
| '''); |
| } |
| |
| test_const_topLevel_typedList_importedWithPrefix() async { |
| addLibrarySource('/a.dart', 'class C {}'); |
| var library = await checkLibrary(r''' |
| import 'a.dart' as p; |
| const v = const <p.C>[]; |
| '''); |
| checkElementText(library, r''' |
| library |
| imports |
| a.dart as p @19 |
| definingUnit |
| topLevelVariables |
| static const v @28 |
| type: List<C> |
| constantInitializer |
| ListLiteral |
| constKeyword: const @32 |
| typeArguments: TypeArgumentList |
| leftBracket: < @38 |
| arguments |
| NamedType |
| name: PrefixedIdentifier |
| prefix: SimpleIdentifier |
| token: p @39 |
| staticElement: self::@prefix::p |
| staticType: null |
| period: . @40 |
| identifier: SimpleIdentifier |
| token: C @41 |
| staticElement: a.dart::@class::C |
| staticType: null |
| staticElement: a.dart::@class::C |
| staticType: null |
| type: C |
| rightBracket: > @42 |
| leftBracket: [ @43 |
| rightBracket: ] @44 |
| staticType: List<C> |
| accessors |
| synthetic static get v @-1 |
| returnType: List<C> |
| '''); |
| } |
| |
| test_const_topLevel_typedList_typedefArgument() async { |
| var library = await checkLibrary(r''' |
| typedef int F(String id); |
| const v = const <F>[]; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| typeAliases |
| functionTypeAliasBased F @12 |
| aliasedType: int Function(String) |
| aliasedElement: GenericFunctionTypeElement |
| parameters |
| requiredPositional id @21 |
| type: String |
| returnType: int |
| topLevelVariables |
| static const v @32 |
| type: List<int Function(String)> |
| constantInitializer |
| ListLiteral |
| constKeyword: const @36 |
| typeArguments: TypeArgumentList |
| leftBracket: < @42 |
| arguments |
| NamedType |
| name: SimpleIdentifier |
| token: F @43 |
| staticElement: self::@typeAlias::F |
| staticType: null |
| type: int Function(String) |
| rightBracket: > @44 |
| leftBracket: [ @45 |
| rightBracket: ] @46 |
| staticType: List<int Function(String)> |
| accessors |
| synthetic static get v @-1 |
| returnType: List<int Function(String)> |
| '''); |
| } |
| |
| test_const_topLevel_typedMap() async { |
| var library = await checkLibrary(r''' |
| const vDynamic1 = const <dynamic, int>{}; |
| const vDynamic2 = const <int, dynamic>{}; |
| const vInterface = const <int, String>{}; |
| const vInterfaceWithTypeArguments = const <int, List<String>>{}; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const vDynamic1 @6 |
| type: Map<dynamic, int> |
| constantInitializer |
| SetOrMapLiteral |
| constKeyword: const @18 |
| typeArguments: TypeArgumentList |
| leftBracket: < @24 |
| arguments |
| NamedType |
| name: SimpleIdentifier |
| token: dynamic @25 |
| staticElement: dynamic@-1 |
| staticType: null |
| type: dynamic |
| NamedType |
| name: SimpleIdentifier |
| token: int @34 |
| staticElement: dart:core::@class::int |
| staticType: null |
| type: int |
| rightBracket: > @37 |
| leftBracket: { @38 |
| rightBracket: } @39 |
| isMap: true |
| staticType: Map<dynamic, int> |
| static const vDynamic2 @48 |
| type: Map<int, dynamic> |
| constantInitializer |
| SetOrMapLiteral |
| constKeyword: const @60 |
| typeArguments: TypeArgumentList |
| leftBracket: < @66 |
| arguments |
| NamedType |
| name: SimpleIdentifier |
| token: int @67 |
| staticElement: dart:core::@class::int |
| staticType: null |
| type: int |
| NamedType |
| name: SimpleIdentifier |
| token: dynamic @72 |
| staticElement: dynamic@-1 |
| staticType: null |
| type: dynamic |
| rightBracket: > @79 |
| leftBracket: { @80 |
| rightBracket: } @81 |
| isMap: true |
| staticType: Map<int, dynamic> |
| static const vInterface @90 |
| type: Map<int, String> |
| constantInitializer |
| SetOrMapLiteral |
| constKeyword: const @103 |
| typeArguments: TypeArgumentList |
| leftBracket: < @109 |
| arguments |
| NamedType |
| name: SimpleIdentifier |
| token: int @110 |
| staticElement: dart:core::@class::int |
| staticType: null |
| type: int |
| NamedType |
| name: SimpleIdentifier |
| token: String @115 |
| staticElement: dart:core::@class::String |
| staticType: null |
| type: String |
| rightBracket: > @121 |
| leftBracket: { @122 |
| rightBracket: } @123 |
| isMap: true |
| staticType: Map<int, String> |
| static const vInterfaceWithTypeArguments @132 |
| type: Map<int, List<String>> |
| constantInitializer |
| SetOrMapLiteral |
| constKeyword: const @162 |
| typeArguments: TypeArgumentList |
| leftBracket: < @168 |
| arguments |
| NamedType |
| name: SimpleIdentifier |
| token: int @169 |
| staticElement: dart:core::@class::int |
| staticType: null |
| type: int |
| NamedType |
| name: SimpleIdentifier |
| token: List @174 |
| staticElement: dart:core::@class::List |
| staticType: null |
| typeArguments: TypeArgumentList |
| leftBracket: < @178 |
| arguments |
| NamedType |
| name: SimpleIdentifier |
| token: String @179 |
| staticElement: dart:core::@class::String |
| staticType: null |
| type: String |
| rightBracket: > @185 |
| type: List<String> |
| rightBracket: > @186 |
| leftBracket: { @187 |
| rightBracket: } @188 |
| isMap: true |
| staticType: Map<int, List<String>> |
| accessors |
| synthetic static get vDynamic1 @-1 |
| returnType: Map<dynamic, int> |
| synthetic static get vDynamic2 @-1 |
| returnType: Map<int, dynamic> |
| synthetic static get vInterface @-1 |
| returnType: Map<int, String> |
| synthetic static get vInterfaceWithTypeArguments @-1 |
| returnType: Map<int, List<String>> |
| '''); |
| } |
| |
| test_const_topLevel_typedSet() async { |
| var library = await checkLibrary(r''' |
| const vDynamic1 = const <dynamic>{}; |
| const vInterface = const <int>{}; |
| const vInterfaceWithTypeArguments = const <List<String>>{}; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const vDynamic1 @6 |
| type: Set<dynamic> |
| constantInitializer |
| SetOrMapLiteral |
| constKeyword: const @18 |
| typeArguments: TypeArgumentList |
| leftBracket: < @24 |
| arguments |
| NamedType |
| name: SimpleIdentifier |
| token: dynamic @25 |
| staticElement: dynamic@-1 |
| staticType: null |
| type: dynamic |
| rightBracket: > @32 |
| leftBracket: { @33 |
| rightBracket: } @34 |
| isMap: false |
| staticType: Set<dynamic> |
| static const vInterface @43 |
| type: Set<int> |
| constantInitializer |
| SetOrMapLiteral |
| constKeyword: const @56 |
| typeArguments: TypeArgumentList |
| leftBracket: < @62 |
| arguments |
| NamedType |
| name: SimpleIdentifier |
| token: int @63 |
| staticElement: dart:core::@class::int |
| staticType: null |
| type: int |
| rightBracket: > @66 |
| leftBracket: { @67 |
| rightBracket: } @68 |
| isMap: false |
| staticType: Set<int> |
| static const vInterfaceWithTypeArguments @77 |
| type: Set<List<String>> |
| constantInitializer |
| SetOrMapLiteral |
| constKeyword: const @107 |
| typeArguments: TypeArgumentList |
| leftBracket: < @113 |
| arguments |
| NamedType |
| name: SimpleIdentifier |
| token: List @114 |
| staticElement: dart:core::@class::List |
| staticType: null |
| typeArguments: TypeArgumentList |
| leftBracket: < @118 |
| arguments |
| NamedType |
| name: SimpleIdentifier |
| token: String @119 |
| staticElement: dart:core::@class::String |
| staticType: null |
| type: String |
| rightBracket: > @125 |
| type: List<String> |
| rightBracket: > @126 |
| leftBracket: { @127 |
| rightBracket: } @128 |
| isMap: false |
| staticType: Set<List<String>> |
| accessors |
| synthetic static get vDynamic1 @-1 |
| returnType: Set<dynamic> |
| synthetic static get vInterface @-1 |
| returnType: Set<int> |
| synthetic static get vInterfaceWithTypeArguments @-1 |
| returnType: Set<List<String>> |
| '''); |
| } |
| |
| test_const_topLevel_untypedList() async { |
| var library = await checkLibrary(r''' |
| const v = const [1, 2, 3]; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const v @6 |
| type: List<int> |
| constantInitializer |
| ListLiteral |
| constKeyword: const @10 |
| leftBracket: [ @16 |
| elements |
| IntegerLiteral |
| literal: 1 @17 |
| staticType: int |
| IntegerLiteral |
| literal: 2 @20 |
| staticType: int |
| IntegerLiteral |
| literal: 3 @23 |
| staticType: int |
| rightBracket: ] @24 |
| staticType: List<int> |
| accessors |
| synthetic static get v @-1 |
| returnType: List<int> |
| '''); |
| } |
| |
| test_const_topLevel_untypedMap() async { |
| var library = await checkLibrary(r''' |
| const v = const {0: 'aaa', 1: 'bbb', 2: 'ccc'}; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const v @6 |
| type: Map<int, String> |
| constantInitializer |
| SetOrMapLiteral |
| constKeyword: const @10 |
| leftBracket: { @16 |
| elements |
| SetOrMapLiteral |
| key: IntegerLiteral |
| literal: 0 @17 |
| staticType: int |
| separator: : @18 |
| value: SimpleStringLiteral |
| literal: 'aaa' @20 |
| SetOrMapLiteral |
| key: IntegerLiteral |
| literal: 1 @27 |
| staticType: int |
| separator: : @28 |
| value: SimpleStringLiteral |
| literal: 'bbb' @30 |
| SetOrMapLiteral |
| key: IntegerLiteral |
| literal: 2 @37 |
| staticType: int |
| separator: : @38 |
| value: SimpleStringLiteral |
| literal: 'ccc' @40 |
| rightBracket: } @45 |
| isMap: true |
| staticType: Map<int, String> |
| accessors |
| synthetic static get v @-1 |
| returnType: Map<int, String> |
| '''); |
| } |
| |
| test_const_topLevel_untypedSet() async { |
| var library = await checkLibrary(r''' |
| const v = const {0, 1, 2}; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const v @6 |
| type: Set<int> |
| constantInitializer |
| SetOrMapLiteral |
| constKeyword: const @10 |
| leftBracket: { @16 |
| elements |
| IntegerLiteral |
| literal: 0 @17 |
| staticType: int |
| IntegerLiteral |
| literal: 1 @20 |
| staticType: int |
| IntegerLiteral |
| literal: 2 @23 |
| staticType: int |
| rightBracket: } @24 |
| isMap: false |
| staticType: Set<int> |
| accessors |
| synthetic static get v @-1 |
| returnType: Set<int> |
| '''); |
| } |
| |
| test_const_typeLiteral() async { |
| var library = await checkLibrary(r''' |
| const v = List<int>; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static const v @6 |
| type: Type |
| constantInitializer |
| TypeLiteral |
| type: NamedType |
| name: SimpleIdentifier |
| token: List @10 |
| staticElement: dart:core::@class::List |
| staticType: List<int> |
| typeArguments: TypeArgumentList |
| leftBracket: < @14 |
| arguments |
| NamedType |
| name: SimpleIdentifier |
| token: int @15 |
| staticElement: dart:core::@class::int |
| staticType: null |
| type: int |
| rightBracket: > @18 |
| type: List<int> |
| staticType: Type |
| accessors |
| synthetic static get v @-1 |
| returnType: Type |
| '''); |
| } |
| |
| test_constExpr_pushReference_enum_field() async { |
| var library = await checkLibrary(''' |
| enum E {a, b, c} |
| final vValue = E.a; |
| final vValues = E.values; |
| final vIndex = E.a.index; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| enums |
| enum E @5 |
| supertype: Enum |
| fields |
| static const enumConstant a @8 |
| type: E |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: self::@enum::E::@constructor::• |
| staticType: null |
| staticElement: self::@enum::E::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| static const enumConstant b @11 |
| type: E |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: self::@enum::E::@constructor::• |
| staticType: null |
| staticElement: self::@enum::E::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| static const enumConstant c @14 |
| type: E |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: self::@enum::E::@constructor::• |
| staticType: null |
| staticElement: self::@enum::E::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: a @-1 |
| staticElement: self::@enum::E::@getter::a |
| staticType: E |
| SimpleIdentifier |
| token: b @-1 |
| staticElement: self::@enum::E::@getter::b |
| staticType: E |
| SimpleIdentifier |
| token: c @-1 |
| staticElement: self::@enum::E::@getter::c |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| constructors |
| synthetic const @-1 |
| accessors |
| synthetic static get a @-1 |
| returnType: E |
| synthetic static get b @-1 |
| returnType: E |
| synthetic static get c @-1 |
| returnType: E |
| synthetic static get values @-1 |
| returnType: List<E> |
| topLevelVariables |
| static final vValue @23 |
| type: E |
| static final vValues @43 |
| type: List<E> |
| static final vIndex @69 |
| type: int |
| accessors |
| synthetic static get vValue @-1 |
| returnType: E |
| synthetic static get vValues @-1 |
| returnType: List<E> |
| synthetic static get vIndex @-1 |
| returnType: int |
| '''); |
| } |
| |
| test_constExpr_pushReference_enum_method() async { |
| var library = await checkLibrary(''' |
| enum E {a} |
| final vToString = E.a.toString(); |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| enums |
| enum E @5 |
| supertype: Enum |
| fields |
| static const enumConstant a @8 |
| type: E |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: self::@enum::E::@constructor::• |
| staticType: null |
| staticElement: self::@enum::E::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: a @-1 |
| staticElement: self::@enum::E::@getter::a |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| constructors |
| synthetic const @-1 |
| accessors |
| synthetic static get a @-1 |
| returnType: E |
| synthetic static get values @-1 |
| returnType: List<E> |
| topLevelVariables |
| static final vToString @17 |
| type: String |
| accessors |
| synthetic static get vToString @-1 |
| returnType: String |
| '''); |
| } |
| |
| test_constExpr_pushReference_field_simpleIdentifier() async { |
| var library = await checkLibrary(''' |
| class C { |
| static const a = b; |
| static const b = null; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| static const a @25 |
| type: dynamic |
| constantInitializer |
| SimpleIdentifier |
| token: b @29 |
| staticElement: self::@class::C::@getter::b |
| staticType: dynamic |
| static const b @47 |
| type: dynamic |
| constantInitializer |
| NullLiteral |
| literal: null @51 |
| staticType: Null |
| constructors |
| synthetic @-1 |
| accessors |
| synthetic static get a @-1 |
| returnType: dynamic |
| synthetic static get b @-1 |
| returnType: dynamic |
| '''); |
| } |
| |
| test_constExpr_pushReference_staticMethod_simpleIdentifier() async { |
| var library = await checkLibrary(''' |
| class C { |
| static const a = m; |
| static m() {} |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| fields |
| static const a @25 |
| type: dynamic Function() |
| constantInitializer |
| SimpleIdentifier |
| token: m @29 |
| staticElement: self::@class::C::@method::m |
| staticType: dynamic Function() |
| constructors |
| synthetic @-1 |
| accessors |
| synthetic static get a @-1 |
| returnType: dynamic Function() |
| methods |
| static m @41 |
| returnType: dynamic |
| '''); |
| } |
| |
| test_defaultValue_eliminateTypeParameters() async { |
| var library = await checkLibrary(''' |
| class A<T> { |
| const X({List<T> a = const []}); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class A @6 |
| typeParameters |
| covariant T @8 |
| defaultType: dynamic |
| constructors |
| synthetic @-1 |
| methods |
| abstract X @21 |
| parameters |
| optionalNamed a @32 |
| type: List<T> |
| constantInitializer |
| ListLiteral |
| constKeyword: const @36 |
| leftBracket: [ @42 |
| rightBracket: ] @43 |
| staticType: List<Never> |
| returnType: dynamic |
| '''); |
| } |
| |
| test_defaultValue_eliminateTypeParameters_legacy() async { |
| featureSet = FeatureSets.language_2_9; |
| var library = await checkLibrary(''' |
| class A<T> { |
| const X({List<T> a = const []}); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class A @6 |
| typeParameters |
| covariant T @8 |
| defaultType: dynamic |
| constructors |
| synthetic @-1 |
| methods |
| abstract X @21 |
| parameters |
| optionalNamed a @32 |
| type: List<T*>* |
| constantInitializer |
| ListLiteral |
| constKeyword: const @36 |
| leftBracket: [ @42 |
| rightBracket: ] @43 |
| staticType: List<Null*>* |
| returnType: dynamic |
| '''); |
| } |
| |
| test_defaultValue_genericFunction() async { |
| var library = await checkLibrary(''' |
| typedef void F<T>(T v); |
| |
| void defaultF<T>(T v) {} |
| |
| class X { |
| final F f; |
| const X({this.f: defaultF}); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class X @57 |
| fields |
| final f @71 |
| type: void Function(dynamic) |
| aliasElement: self::@typeAlias::F |
| aliasArguments |
| dynamic |
| constructors |
| const @82 |
| parameters |
| optionalNamed final this.f @90 |
| type: void Function(dynamic) |
| aliasElement: self::@typeAlias::F |
| aliasArguments |
| dynamic |
| constantInitializer |
| FunctionReference |
| function: SimpleIdentifier |
| token: defaultF @93 |
| staticElement: self::@function::defaultF |
| staticType: void Function<T>(T) |
| staticType: void Function(dynamic) |
| typeArgumentTypes |
| dynamic |
| field: self::@class::X::@field::f |
| accessors |
| synthetic get f @-1 |
| returnType: void Function(dynamic) |
| aliasElement: self::@typeAlias::F |
| aliasArguments |
| dynamic |
| typeAliases |
| functionTypeAliasBased F @13 |
| typeParameters |
| contravariant T @15 |
| defaultType: dynamic |
| aliasedType: void Function(T) |
| aliasedElement: GenericFunctionTypeElement |
| parameters |
| requiredPositional v @20 |
| type: T |
| returnType: void |
| functions |
| defaultF @30 |
| typeParameters |
| covariant T @39 |
| parameters |
| requiredPositional v @44 |
| type: T |
| returnType: void |
| '''); |
| } |
| |
| test_defaultValue_genericFunctionType() async { |
| var library = await checkLibrary(''' |
| class A<T> { |
| const A(); |
| } |
| class B { |
| void foo({a: const A<Function()>()}) {} |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class A @6 |
| typeParameters |
| covariant T @8 |
| defaultType: dynamic |
| constructors |
| const @21 |
| class B @34 |
| constructors |
| synthetic @-1 |
| methods |
| foo @45 |
| parameters |
| optionalNamed a @50 |
| type: dynamic |
| constantInitializer |
| InstanceCreationExpression |
| keyword: const @53 |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: A @59 |
| staticElement: self::@class::A |
| staticType: null |
| typeArguments: TypeArgumentList |
| leftBracket: < @60 |
| arguments |
| GenericFunctionType |
| functionKeyword: Function @61 |
| parameters: FormalParameterList |
| leftParenthesis: ( @69 |
| rightParenthesis: ) @70 |
| declaredElement: GenericFunctionTypeElement |
| parameters |
| returnType: dynamic |
| type: dynamic Function() |
| type: dynamic Function() |
| rightBracket: > @71 |
| type: A<dynamic Function()> |
| staticElement: ConstructorMember |
| base: self::@class::A::@constructor::• |
| substitution: {T: dynamic Function()} |
| argumentList: ArgumentList |
| leftParenthesis: ( @72 |
| rightParenthesis: ) @73 |
| staticType: A<dynamic Function()> |
| returnType: void |
| '''); |
| } |
| |
| test_defaultValue_inFunctionTypedFormalParameter() async { |
| var library = await checkLibrary(''' |
| void f( g({a: 0 is int}) ) {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| functions |
| f @5 |
| parameters |
| requiredPositional g @8 |
| type: dynamic Function({dynamic a}) |
| parameters |
| optionalNamed a @11 |
| type: dynamic |
| constantInitializer |
| IsExpression |
| expression: IntegerLiteral |
| literal: 0 @14 |
| staticType: int |
| isOperator: is @16 |
| type: NamedType |
| name: SimpleIdentifier |
| token: int @19 |
| staticElement: dart:core::@class::int |
| staticType: null |
| type: int |
| staticType: bool |
| returnType: void |
| '''); |
| } |
| |
| test_defaultValue_methodMember_legacy() async { |
| featureSet = FeatureSets.language_2_9; |
| var library = await checkLibrary(''' |
| void f([Comparator<T> compare = Comparable.compare]) {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| functions |
| f @5 |
| parameters |
| optionalPositional compare @22 |
| type: int* Function(dynamic, dynamic)* |
| aliasElement: dart:core::@typeAlias::Comparator |
| aliasArguments |
| dynamic |
| constantInitializer |
| PrefixedIdentifier |
| prefix: SimpleIdentifier |
| token: Comparable @32 |
| staticElement: dart:core::@class::Comparable |
| staticType: null |
| period: . @42 |
| identifier: SimpleIdentifier |
| token: compare @43 |
| staticElement: MethodMember |
| base: dart:core::@class::Comparable::@method::compare |
| substitution: {} |
| staticType: int* Function(Comparable<dynamic>*, Comparable<dynamic>*)* |
| staticElement: MethodMember |
| base: dart:core::@class::Comparable::@method::compare |
| substitution: {} |
| staticType: int* Function(Comparable<dynamic>*, Comparable<dynamic>*)* |
| returnType: void |
| '''); |
| } |
| |
| test_defaultValue_refersToExtension_method_inside() async { |
| var library = await checkLibrary(''' |
| class A {} |
| extension E on A { |
| static void f() {} |
| static void g([Object p = f]) {} |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class A @6 |
| constructors |
| synthetic @-1 |
| extensions |
| E @21 |
| extendedType: A |
| methods |
| static f @44 |
| returnType: void |
| static g @65 |
| parameters |
| optionalPositional p @75 |
| type: Object |
| constantInitializer |
| SimpleIdentifier |
| token: f @79 |
| staticElement: self::@extension::E::@method::f |
| staticType: void Function() |
| returnType: void |
| '''); |
| } |
| |
| test_defaultValue_refersToGenericClass() async { |
| var library = await checkLibrary(''' |
| class B<T1, T2> { |
| const B(); |
| } |
| class C { |
| void foo([B<int, double> b = const B()]) {} |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class B @6 |
| typeParameters |
| covariant T1 @8 |
| defaultType: dynamic |
| covariant T2 @12 |
| defaultType: dynamic |
| constructors |
| const @26 |
| class C @39 |
| constructors |
| synthetic @-1 |
| methods |
| foo @50 |
| parameters |
| optionalPositional b @70 |
| type: B<int, double> |
| constantInitializer |
| InstanceCreationExpression |
| keyword: const @74 |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: B @80 |
| staticElement: self::@class::B |
| staticType: null |
| type: B<int, double> |
| staticElement: ConstructorMember |
| base: self::@class::B::@constructor::• |
| substitution: {T1: int, T2: double} |
| argumentList: ArgumentList |
| leftParenthesis: ( @81 |
| rightParenthesis: ) @82 |
| staticType: B<int, double> |
| returnType: void |
| '''); |
| } |
| |
| test_defaultValue_refersToGenericClass_constructor() async { |
| var library = await checkLibrary(''' |
| class B<T> { |
| const B(); |
| } |
| class C<T> { |
| const C([B<T> b = const B()]); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class B @6 |
| typeParameters |
| covariant T @8 |
| defaultType: dynamic |
| constructors |
| const @21 |
| class C @34 |
| typeParameters |
| covariant T @36 |
| defaultType: dynamic |
| constructors |
| const @49 |
| parameters |
| optionalPositional b @57 |
| type: B<T> |
| constantInitializer |
| InstanceCreationExpression |
| keyword: const @61 |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: B @67 |
| staticElement: self::@class::B |
| staticType: null |
| type: B<Never> |
| staticElement: ConstructorMember |
| base: self::@class::B::@constructor::• |
| substitution: {T: Never} |
| argumentList: ArgumentList |
| leftParenthesis: ( @68 |
| rightParenthesis: ) @69 |
| staticType: B<Never> |
| '''); |
| } |
| |
| test_defaultValue_refersToGenericClass_constructor2() async { |
| var library = await checkLibrary(''' |
| abstract class A<T> {} |
| class B<T> implements A<T> { |
| const B(); |
| } |
| class C<T> implements A<Iterable<T>> { |
| const C([A<T> a = const B()]); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| abstract class A @15 |
| typeParameters |
| covariant T @17 |
| defaultType: dynamic |
| constructors |
| synthetic @-1 |
| class B @29 |
| typeParameters |
| covariant T @31 |
| defaultType: dynamic |
| interfaces |
| A<T> |
| constructors |
| const @60 |
| class C @73 |
| typeParameters |
| covariant T @75 |
| defaultType: dynamic |
| interfaces |
| A<Iterable<T>> |
| constructors |
| const @114 |
| parameters |
| optionalPositional a @122 |
| type: A<T> |
| constantInitializer |
| InstanceCreationExpression |
| keyword: const @126 |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: B @132 |
| staticElement: self::@class::B |
| staticType: null |
| type: B<Never> |
| staticElement: ConstructorMember |
| base: self::@class::B::@constructor::• |
| substitution: {T: Never} |
| argumentList: ArgumentList |
| leftParenthesis: ( @133 |
| rightParenthesis: ) @134 |
| staticType: B<Never> |
| '''); |
| } |
| |
| test_defaultValue_refersToGenericClass_constructor2_legacy() async { |
| featureSet = FeatureSets.language_2_9; |
| var library = await checkLibrary(''' |
| abstract class A<T> {} |
| class B<T> implements A<T> { |
| const B(); |
| } |
| class C<T> implements A<Iterable<T>> { |
| const C([A<T> a = const B()]); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| abstract class A @15 |
| typeParameters |
| covariant T @17 |
| defaultType: dynamic |
| constructors |
| synthetic @-1 |
| class B @29 |
| typeParameters |
| covariant T @31 |
| defaultType: dynamic |
| interfaces |
| A<T*>* |
| constructors |
| const @60 |
| class C @73 |
| typeParameters |
| covariant T @75 |
| defaultType: dynamic |
| interfaces |
| A<Iterable<T*>*>* |
| constructors |
| const @114 |
| parameters |
| optionalPositional a @122 |
| type: A<T*>* |
| constantInitializer |
| InstanceCreationExpression |
| keyword: const @126 |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: B @132 |
| staticElement: self::@class::B |
| staticType: null |
| type: B<Null*>* |
| staticElement: ConstructorMember |
| base: self::@class::B::@constructor::• |
| substitution: {T: Null*} |
| argumentList: ArgumentList |
| leftParenthesis: ( @133 |
| rightParenthesis: ) @134 |
| staticType: B<Null*>* |
| '''); |
| } |
| |
| test_defaultValue_refersToGenericClass_constructor_legacy() async { |
| featureSet = FeatureSets.language_2_9; |
| var library = await checkLibrary(''' |
| class B<T> { |
| const B(); |
| } |
| class C<T> { |
| const C([B<T> b = const B()]); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class B @6 |
| typeParameters |
| covariant T @8 |
| defaultType: dynamic |
| constructors |
| const @21 |
| class C @34 |
| typeParameters |
| covariant T @36 |
| defaultType: dynamic |
| constructors |
| const @49 |
| parameters |
| optionalPositional b @57 |
| type: B<T*>* |
| constantInitializer |
| InstanceCreationExpression |
| keyword: const @61 |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: B @67 |
| staticElement: self::@class::B |
| staticType: null |
| type: B<Null*>* |
| staticElement: ConstructorMember |
| base: self::@class::B::@constructor::• |
| substitution: {T: Null*} |
| argumentList: ArgumentList |
| leftParenthesis: ( @68 |
| rightParenthesis: ) @69 |
| staticType: B<Null*>* |
| '''); |
| } |
| |
| test_defaultValue_refersToGenericClass_functionG() async { |
| var library = await checkLibrary(''' |
| class B<T> { |
| const B(); |
| } |
| void foo<T>([B<T> b = const B()]) {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class B @6 |
| typeParameters |
| covariant T @8 |
| defaultType: dynamic |
| constructors |
| const @21 |
| functions |
| foo @33 |
| typeParameters |
| covariant T @37 |
| parameters |
| optionalPositional b @46 |
| type: B<T> |
| constantInitializer |
| InstanceCreationExpression |
| keyword: const @50 |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: B @56 |
| staticElement: self::@class::B |
| staticType: null |
| type: B<Never> |
| staticElement: ConstructorMember |
| base: self::@class::B::@constructor::• |
| substitution: {T: Never} |
| argumentList: ArgumentList |
| leftParenthesis: ( @57 |
| rightParenthesis: ) @58 |
| staticType: B<Never> |
| returnType: void |
| '''); |
| } |
| |
| test_defaultValue_refersToGenericClass_methodG() async { |
| var library = await checkLibrary(''' |
| class B<T> { |
| const B(); |
| } |
| class C { |
| void foo<T>([B<T> b = const B()]) {} |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class B @6 |
| typeParameters |
| covariant T @8 |
| defaultType: dynamic |
| constructors |
| const @21 |
| class C @34 |
| constructors |
| synthetic @-1 |
| methods |
| foo @45 |
| typeParameters |
| covariant T @49 |
| parameters |
| optionalPositional b @58 |
| type: B<T> |
| constantInitializer |
| InstanceCreationExpression |
| keyword: const @62 |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: B @68 |
| staticElement: self::@class::B |
| staticType: null |
| type: B<Never> |
| staticElement: ConstructorMember |
| base: self::@class::B::@constructor::• |
| substitution: {T: Never} |
| argumentList: ArgumentList |
| leftParenthesis: ( @69 |
| rightParenthesis: ) @70 |
| staticType: B<Never> |
| returnType: void |
| '''); |
| } |
| |
| test_defaultValue_refersToGenericClass_methodG_classG() async { |
| var library = await checkLibrary(''' |
| class B<T1, T2> { |
| const B(); |
| } |
| class C<E1> { |
| void foo<E2>([B<E1, E2> b = const B()]) {} |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class B @6 |
| typeParameters |
| covariant T1 @8 |
| defaultType: dynamic |
| covariant T2 @12 |
| defaultType: dynamic |
| constructors |
| const @26 |
| class C @39 |
| typeParameters |
| covariant E1 @41 |
| defaultType: dynamic |
| constructors |
| synthetic @-1 |
| methods |
| foo @54 |
| typeParameters |
| covariant E2 @58 |
| parameters |
| optionalPositional b @73 |
| type: B<E1, E2> |
| constantInitializer |
| InstanceCreationExpression |
| keyword: const @77 |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: B @83 |
| staticElement: self::@class::B |
| staticType: null |
| type: B<Never, Never> |
| staticElement: ConstructorMember |
| base: self::@class::B::@constructor::• |
| substitution: {T1: Never, T2: Never} |
| argumentList: ArgumentList |
| leftParenthesis: ( @84 |
| rightParenthesis: ) @85 |
| staticType: B<Never, Never> |
| returnType: void |
| '''); |
| } |
| |
| test_defaultValue_refersToGenericClass_methodNG() async { |
| var library = await checkLibrary(''' |
| class B<T> { |
| const B(); |
| } |
| class C<T> { |
| void foo([B<T> b = const B()]) {} |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class B @6 |
| typeParameters |
| covariant T @8 |
| defaultType: dynamic |
| constructors |
| const @21 |
| class C @34 |
| typeParameters |
| covariant T @36 |
| defaultType: dynamic |
| constructors |
| synthetic @-1 |
| methods |
| foo @48 |
| parameters |
| optionalPositional b @58 |
| type: B<T> |
| constantInitializer |
| InstanceCreationExpression |
| keyword: const @62 |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: B @68 |
| staticElement: self::@class::B |
| staticType: null |
| type: B<Never> |
| staticElement: ConstructorMember |
| base: self::@class::B::@constructor::• |
| substitution: {T: Never} |
| argumentList: ArgumentList |
| leftParenthesis: ( @69 |
| rightParenthesis: ) @70 |
| staticType: B<Never> |
| returnType: void |
| '''); |
| } |
| |
| test_duplicateDeclaration_class() async { |
| var library = await checkLibrary(r''' |
| class A {} |
| class A { |
| var x; |
| } |
| class A { |
| var y = 0; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class A @6 |
| constructors |
| synthetic @-1 |
| class A @17 |
| fields |
| x @27 |
| type: dynamic |
| constructors |
| synthetic @-1 |
| accessors |
| synthetic get x @-1 |
| returnType: dynamic |
| synthetic set x @-1 |
| parameters |
| requiredPositional _x @-1 |
| type: dynamic |
| returnType: void |
| class A @38 |
| fields |
| y @48 |
| type: int |
| constructors |
| synthetic @-1 |
| accessors |
| synthetic get y @-1 |
| returnType: int |
| synthetic set y @-1 |
| parameters |
| requiredPositional _y @-1 |
| type: int |
| returnType: void |
| '''); |
| } |
| |
| test_duplicateDeclaration_classTypeAlias() async { |
| var library = await checkLibrary(r''' |
| class A {} |
| class B {} |
| class X = A with M; |
| class X = B with M; |
| mixin M {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class A @6 |
| constructors |
| synthetic @-1 |
| class B @17 |
| constructors |
| synthetic @-1 |
| class alias X @28 |
| supertype: A |
| mixins |
| M |
| constructors |
| synthetic @-1 |
| constantInitializers |
| SuperConstructorInvocation |
| superKeyword: super @0 |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticElement: self::@class::A::@constructor::• |
| superConstructor: self::@class::A::@constructor::• |
| class alias X @48 |
| supertype: B |
| mixins |
| M |
| constructors |
| synthetic @-1 |
| constantInitializers |
| SuperConstructorInvocation |
| superKeyword: super @0 |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticElement: self::@class::B::@constructor::• |
| superConstructor: self::@class::B::@constructor::• |
| mixins |
| mixin M @68 |
| superclassConstraints |
| Object |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_duplicateDeclaration_enum() async { |
| var library = await checkLibrary(r''' |
| enum E {a, b} |
| enum E {c, d, e} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| enums |
| enum E @5 |
| supertype: Enum |
| fields |
| static const enumConstant a @8 |
| type: E |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: self::@enum::E::@constructor::• |
| staticType: null |
| staticElement: self::@enum::E::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| static const enumConstant b @11 |
| type: E |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: self::@enum::E::@constructor::• |
| staticType: null |
| staticElement: self::@enum::E::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: a @-1 |
| staticElement: self::@enum::E::@getter::a |
| staticType: E |
| SimpleIdentifier |
| token: b @-1 |
| staticElement: self::@enum::E::@getter::b |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| constructors |
| synthetic const @-1 |
| accessors |
| synthetic static get a @-1 |
| returnType: E |
| synthetic static get b @-1 |
| returnType: E |
| synthetic static get values @-1 |
| returnType: List<E> |
| enum E @19 |
| supertype: Enum |
| fields |
| static const enumConstant c @22 |
| type: E |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: self::@enum::E::@constructor::• |
| staticType: null |
| staticElement: self::@enum::E::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| static const enumConstant d @25 |
| type: E |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: self::@enum::E::@constructor::• |
| staticType: null |
| staticElement: self::@enum::E::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| static const enumConstant e @28 |
| type: E |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: self::@enum::E::@constructor::• |
| staticType: null |
| staticElement: self::@enum::E::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: c @-1 |
| staticElement: self::@enum::E::@getter::c |
| staticType: E |
| SimpleIdentifier |
| token: d @-1 |
| staticElement: self::@enum::E::@getter::d |
| staticType: E |
| SimpleIdentifier |
| token: e @-1 |
| staticElement: self::@enum::E::@getter::e |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| constructors |
| synthetic const @-1 |
| accessors |
| synthetic static get c @-1 |
| returnType: E |
| synthetic static get d @-1 |
| returnType: E |
| synthetic static get e @-1 |
| returnType: E |
| synthetic static get values @-1 |
| returnType: List<E> |
| '''); |
| } |
| |
| test_duplicateDeclaration_extension() async { |
| var library = await checkLibrary(r''' |
| class A {} |
| extension E on A {} |
| extension E on A { |
| static var x; |
| } |
| extension E on A { |
| static var y = 0; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class A @6 |
| constructors |
| synthetic @-1 |
| extensions |
| E @21 |
| extendedType: A |
| E @41 |
| extendedType: A |
| fields |
| static x @63 |
| type: dynamic |
| accessors |
| synthetic static get x @-1 |
| returnType: dynamic |
| synthetic static set x @-1 |
| parameters |
| requiredPositional _x @-1 |
| type: dynamic |
| returnType: void |
| E @78 |
| extendedType: A |
| fields |
| static y @100 |
| type: int |
| accessors |
| synthetic static get y @-1 |
| returnType: int |
| synthetic static set y @-1 |
| parameters |
| requiredPositional _y @-1 |
| type: int |
| returnType: void |
| '''); |
| } |
| |
| test_duplicateDeclaration_function() async { |
| var library = await checkLibrary(r''' |
| void f() {} |
| void f(int a) {} |
| void f([int b, double c]) {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| functions |
| f @5 |
| returnType: void |
| f @17 |
| parameters |
| requiredPositional a @23 |
| type: int |
| returnType: void |
| f @34 |
| parameters |
| optionalPositional b @41 |
| type: int |
| optionalPositional c @51 |
| type: double |
| returnType: void |
| '''); |
| } |
| |
| test_duplicateDeclaration_functionTypeAlias() async { |
| var library = await checkLibrary(r''' |
| typedef void F(); |
| typedef void F(int a); |
| typedef void F([int b, double c]); |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| typeAliases |
| functionTypeAliasBased F @13 |
| aliasedType: void Function() |
| aliasedElement: GenericFunctionTypeElement |
| returnType: void |
| functionTypeAliasBased F @31 |
| aliasedType: void Function(int) |
| aliasedElement: GenericFunctionTypeElement |
| parameters |
| requiredPositional a @37 |
| type: int |
| returnType: void |
| functionTypeAliasBased F @54 |
| aliasedType: void Function([int, double]) |
| aliasedElement: GenericFunctionTypeElement |
| parameters |
| optionalPositional b @61 |
| type: int |
| optionalPositional c @71 |
| type: double |
| returnType: void |
| '''); |
| } |
| |
| test_duplicateDeclaration_mixin() async { |
| var library = await checkLibrary(r''' |
| mixin A {} |
| mixin A { |
| var x; |
| } |
| mixin A { |
| var y = 0; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| mixins |
| mixin A @6 |
| superclassConstraints |
| Object |
| constructors |
| synthetic @-1 |
| mixin A @17 |
| superclassConstraints |
| Object |
| fields |
| x @27 |
| type: dynamic |
| constructors |
| synthetic @-1 |
| accessors |
| synthetic get x @-1 |
| returnType: dynamic |
| synthetic set x @-1 |
| parameters |
| requiredPositional _x @-1 |
| type: dynamic |
| returnType: void |
| mixin A @38 |
| superclassConstraints |
| Object |
| fields |
| y @48 |
| type: int |
| constructors |
| synthetic @-1 |
| accessors |
| synthetic get y @-1 |
| returnType: int |
| synthetic set y @-1 |
| parameters |
| requiredPositional _y @-1 |
| type: int |
| returnType: void |
| '''); |
| } |
| |
| test_duplicateDeclaration_topLevelVariable() async { |
| var library = await checkLibrary(r''' |
| bool x; |
| var x; |
| var x = 1; |
| var x = 2.3; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| topLevelVariables |
| static x @5 |
| type: bool |
| static x @12 |
| type: dynamic |
| static x @19 |
| type: int |
| static x @30 |
| type: double |
| accessors |
| synthetic static get x @-1 |
| returnType: bool |
| synthetic static set x @-1 |
| parameters |
| requiredPositional _x @-1 |
| type: bool |
| returnType: void |
| synthetic static get x @-1 |
| returnType: dynamic |
| synthetic static set x @-1 |
| parameters |
| requiredPositional _x @-1 |
| type: dynamic |
| returnType: void |
| synthetic static get x @-1 |
| returnType: int |
| synthetic static set x @-1 |
| parameters |
| requiredPositional _x @-1 |
| type: int |
| returnType: void |
| synthetic static get x @-1 |
| returnType: double |
| synthetic static set x @-1 |
| parameters |
| requiredPositional _x @-1 |
| type: double |
| returnType: void |
| '''); |
| } |
| |
| test_enum_constant_inference() async { |
| var library = await checkLibrary(r''' |
| enum E<T> { |
| int(1), string('2'); |
| const E(T a); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| enums |
| enum E @5 |
| typeParameters |
| covariant T @7 |
| defaultType: dynamic |
| supertype: Enum |
| fields |
| static const enumConstant int @14 |
| type: E<int> |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E<int> |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: ConstructorMember |
| base: self::@enum::E::@constructor::• |
| substitution: {T: int} |
| staticType: null |
| staticElement: ConstructorMember |
| base: self::@enum::E::@constructor::• |
| substitution: {T: int} |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| arguments |
| IntegerLiteral |
| literal: 1 @18 |
| staticType: int |
| rightParenthesis: ) @0 |
| staticType: E<int> |
| static const enumConstant string @22 |
| type: E<String> |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E<String> |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: ConstructorMember |
| base: self::@enum::E::@constructor::• |
| substitution: {T: String} |
| staticType: null |
| staticElement: ConstructorMember |
| base: self::@enum::E::@constructor::• |
| substitution: {T: String} |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| arguments |
| SimpleStringLiteral |
| literal: '2' @29 |
| rightParenthesis: ) @0 |
| staticType: E<String> |
| synthetic static const values @-1 |
| type: List<E<dynamic>> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: int @-1 |
| staticElement: self::@enum::E::@getter::int |
| staticType: E<int> |
| SimpleIdentifier |
| token: string @-1 |
| staticElement: self::@enum::E::@getter::string |
| staticType: E<String> |
| rightBracket: ] @0 |
| staticType: List<E<dynamic>> |
| constructors |
| const @43 |
| parameters |
| requiredPositional a @47 |
| type: T |
| accessors |
| synthetic static get int @-1 |
| returnType: E<int> |
| synthetic static get string @-1 |
| returnType: E<String> |
| synthetic static get values @-1 |
| returnType: List<E<dynamic>> |
| '''); |
| } |
| |
| /// Test that a constant named `_name` renames the synthetic `name` field. |
| test_enum_constant_name() async { |
| var library = await checkLibrary(r''' |
| enum E { |
| _name; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| enums |
| enum E @5 |
| supertype: Enum |
| fields |
| static const enumConstant _name @11 |
| type: E |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: self::@enum::E::@constructor::• |
| staticType: null |
| staticElement: self::@enum::E::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: _name @-1 |
| staticElement: self::@enum::E::@getter::_name |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| constructors |
| synthetic const @-1 |
| accessors |
| synthetic static get _name @-1 |
| returnType: E |
| synthetic static get values @-1 |
| returnType: List<E> |
| '''); |
| } |
| |
| test_enum_constant_typeArguments() async { |
| var library = await checkLibrary(r''' |
| enum E<T> { |
| v<double>(42); |
| const E(T a); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| enums |
| enum E @5 |
| typeParameters |
| covariant T @7 |
| defaultType: dynamic |
| supertype: Enum |
| fields |
| static const enumConstant v @14 |
| type: E<double> |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| typeArguments: TypeArgumentList |
| leftBracket: < @15 |
| arguments |
| NamedType |
| name: SimpleIdentifier |
| token: double @16 |
| staticElement: dart:core::@class::double |
| staticType: null |
| type: double |
| rightBracket: > @22 |
| type: E<double> |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: ConstructorMember |
| base: self::@enum::E::@constructor::• |
| substitution: {T: double} |
| staticType: null |
| staticElement: ConstructorMember |
| base: self::@enum::E::@constructor::• |
| substitution: {T: double} |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| arguments |
| IntegerLiteral |
| literal: 42 @24 |
| staticType: double |
| rightParenthesis: ) @0 |
| staticType: E<double> |
| synthetic static const values @-1 |
| type: List<E<dynamic>> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: self::@enum::E::@getter::v |
| staticType: E<double> |
| rightBracket: ] @0 |
| staticType: List<E<dynamic>> |
| constructors |
| const @37 |
| parameters |
| requiredPositional a @41 |
| type: T |
| accessors |
| synthetic static get v @-1 |
| returnType: E<double> |
| synthetic static get values @-1 |
| returnType: List<E<dynamic>> |
| '''); |
| } |
| |
| test_enum_constant_underscore() async { |
| var library = await checkLibrary(''' |
| enum E { |
| _ |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| enums |
| enum E @5 |
| supertype: Enum |
| fields |
| static const enumConstant _ @11 |
| type: E |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: self::@enum::E::@constructor::• |
| staticType: null |
| staticElement: self::@enum::E::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: _ @-1 |
| staticElement: self::@enum::E::@getter::_ |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| constructors |
| synthetic const @-1 |
| accessors |
| synthetic static get _ @-1 |
| returnType: E |
| synthetic static get values @-1 |
| returnType: List<E> |
| '''); |
| } |
| |
| test_enum_constructor_factory_named() async { |
| var library = await checkLibrary(r''' |
| enum E { |
| v; |
| factory E.named() => v; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| enums |
| enum E @5 |
| supertype: Enum |
| fields |
| static const enumConstant v @11 |
| type: E |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: self::@enum::E::@constructor::• |
| staticType: null |
| staticElement: self::@enum::E::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: self::@enum::E::@getter::v |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| constructors |
| factory named @26 |
| periodOffset: 25 |
| nameEnd: 31 |
| synthetic const @-1 |
| accessors |
| synthetic static get v @-1 |
| returnType: E |
| synthetic static get values @-1 |
| returnType: List<E> |
| '''); |
| } |
| |
| test_enum_constructor_factory_unnamed() async { |
| var library = await checkLibrary(r''' |
| enum E { |
| v; |
| factory E() => v; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| enums |
| enum E @5 |
| supertype: Enum |
| fields |
| static const enumConstant v @11 |
| type: E |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: self::@enum::E::@constructor::• |
| staticType: null |
| staticElement: self::@enum::E::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: self::@enum::E::@getter::v |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| constructors |
| factory @24 |
| accessors |
| synthetic static get v @-1 |
| returnType: E |
| synthetic static get values @-1 |
| returnType: List<E> |
| '''); |
| } |
| |
| test_enum_constructor_fieldFormal_functionTyped_withReturnType() async { |
| var library = await checkLibrary(r''' |
| enum E { |
| v; |
| final x; |
| const E(int this.x(double a)); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| enums |
| enum E @5 |
| supertype: Enum |
| fields |
| static const enumConstant v @11 |
| type: E |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: self::@enum::E::@constructor::• |
| staticType: null |
| staticElement: self::@enum::E::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: self::@enum::E::@getter::v |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| final x @22 |
| type: dynamic |
| constructors |
| const @33 |
| parameters |
| requiredPositional final this.x @44 |
| type: int Function(double) |
| parameters |
| requiredPositional a @53 |
| type: double |
| field: self::@enum::E::@field::x |
| accessors |
| synthetic static get v @-1 |
| returnType: E |
| synthetic static get values @-1 |
| returnType: List<E> |
| synthetic get x @-1 |
| returnType: dynamic |
| '''); |
| } |
| |
| test_enum_constructor_fieldFormal_multiple_matching_fields() async { |
| var library = await checkLibrary(''' |
| enum E { |
| v; |
| final int x; |
| final String x; |
| const E(this.x); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| enums |
| enum E @5 |
| supertype: Enum |
| fields |
| static const enumConstant v @11 |
| type: E |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: self::@enum::E::@constructor::• |
| staticType: null |
| staticElement: self::@enum::E::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: self::@enum::E::@getter::v |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| final x @26 |
| type: int |
| final x @44 |
| type: String |
| constructors |
| const @55 |
| parameters |
| requiredPositional final this.x @62 |
| type: int |
| field: self::@enum::E::@field::x |
| accessors |
| synthetic static get v @-1 |
| returnType: E |
| synthetic static get values @-1 |
| returnType: List<E> |
| synthetic get x @-1 |
| returnType: int |
| synthetic get x @-1 |
| returnType: String |
| '''); |
| } |
| |
| test_enum_constructor_fieldFormal_no_matching_field() async { |
| var library = await checkLibrary(''' |
| enum E { |
| v; |
| const E(this.x); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| enums |
| enum E @5 |
| supertype: Enum |
| fields |
| static const enumConstant v @11 |
| type: E |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: self::@enum::E::@constructor::• |
| staticType: null |
| staticElement: self::@enum::E::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: self::@enum::E::@getter::v |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| constructors |
| const @22 |
| parameters |
| requiredPositional final this.x @29 |
| type: dynamic |
| field: <null> |
| accessors |
| synthetic static get v @-1 |
| returnType: E |
| synthetic static get values @-1 |
| returnType: List<E> |
| '''); |
| } |
| |
| test_enum_constructor_fieldFormal_typed_typed() async { |
| var library = await checkLibrary(''' |
| enum E { |
| v; |
| final num x; |
| const E(int this.x); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| enums |
| enum E @5 |
| supertype: Enum |
| fields |
| static const enumConstant v @11 |
| type: E |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: self::@enum::E::@constructor::• |
| staticType: null |
| staticElement: self::@enum::E::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: self::@enum::E::@getter::v |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| final x @26 |
| type: num |
| constructors |
| const @37 |
| parameters |
| requiredPositional final this.x @48 |
| type: int |
| field: self::@enum::E::@field::x |
| accessors |
| synthetic static get v @-1 |
| returnType: E |
| synthetic static get values @-1 |
| returnType: List<E> |
| synthetic get x @-1 |
| returnType: num |
| '''); |
| } |
| |
| test_enum_constructor_fieldFormal_untyped_typed() async { |
| var library = await checkLibrary(r''' |
| enum E { |
| v; |
| final x; |
| E(int this.x); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| enums |
| enum E @5 |
| supertype: Enum |
| fields |
| static const enumConstant v @11 |
| type: E |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: self::@enum::E::@constructor::• |
| staticType: null |
| staticElement: self::@enum::E::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: self::@enum::E::@getter::v |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| final x @22 |
| type: dynamic |
| constructors |
| @27 |
| parameters |
| requiredPositional final this.x @38 |
| type: int |
| field: self::@enum::E::@field::x |
| accessors |
| synthetic static get v @-1 |
| returnType: E |
| synthetic static get values @-1 |
| returnType: List<E> |
| synthetic get x @-1 |
| returnType: dynamic |
| '''); |
| } |
| |
| test_enum_constructor_fieldFormal_untyped_untyped() async { |
| var library = await checkLibrary(r''' |
| enum E { |
| v; |
| final x; |
| E(this.x); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| enums |
| enum E @5 |
| supertype: Enum |
| fields |
| static const enumConstant v @11 |
| type: E |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: self::@enum::E::@constructor::• |
| staticType: null |
| staticElement: self::@enum::E::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: self::@enum::E::@getter::v |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| final x @22 |
| type: dynamic |
| constructors |
| @27 |
| parameters |
| requiredPositional final this.x @34 |
| type: dynamic |
| field: self::@enum::E::@field::x |
| accessors |
| synthetic static get v @-1 |
| returnType: E |
| synthetic static get values @-1 |
| returnType: List<E> |
| synthetic get x @-1 |
| returnType: dynamic |
| '''); |
| } |
| |
| test_enum_constructor_generative_named() async { |
| var library = await checkLibrary(r''' |
| enum E { |
| v.named(42); |
| const E.named(int a); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| enums |
| enum E @5 |
| supertype: Enum |
| fields |
| static const enumConstant v @11 |
| type: E |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E |
| period: . @0 |
| name: SimpleIdentifier |
| token: named @-1 |
| staticElement: self::@enum::E::@constructor::named |
| staticType: null |
| staticElement: self::@enum::E::@constructor::named |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| arguments |
| IntegerLiteral |
| literal: 42 @19 |
| staticType: int |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: self::@enum::E::@getter::v |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| constructors |
| const named @34 |
| periodOffset: 33 |
| nameEnd: 39 |
| parameters |
| requiredPositional a @44 |
| type: int |
| accessors |
| synthetic static get v @-1 |
| returnType: E |
| synthetic static get values @-1 |
| returnType: List<E> |
| '''); |
| } |
| |
| test_enum_constructor_generative_unnamed() async { |
| var library = await checkLibrary(r''' |
| enum E { |
| v(42); |
| const E(int a); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| enums |
| enum E @5 |
| supertype: Enum |
| fields |
| static const enumConstant v @11 |
| type: E |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: self::@enum::E::@constructor::• |
| staticType: null |
| staticElement: self::@enum::E::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| arguments |
| IntegerLiteral |
| literal: 42 @13 |
| staticType: int |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: self::@enum::E::@getter::v |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| constructors |
| const @26 |
| parameters |
| requiredPositional a @32 |
| type: int |
| accessors |
| synthetic static get v @-1 |
| returnType: E |
| synthetic static get values @-1 |
| returnType: List<E> |
| '''); |
| } |
| |
| test_enum_documented() async { |
| var library = await checkLibrary(''' |
| // Extra comment so doc comment offset != 0 |
| /** |
| * Docs |
| */ |
| enum E { v }'''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| enums |
| enum E @65 |
| documentationComment: /**\n * Docs\n */ |
| supertype: Enum |
| fields |
| static const enumConstant v @69 |
| type: E |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: self::@enum::E::@constructor::• |
| staticType: null |
| staticElement: self::@enum::E::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: self::@enum::E::@getter::v |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| constructors |
| synthetic const @-1 |
| accessors |
| synthetic static get v @-1 |
| returnType: E |
| synthetic static get values @-1 |
| returnType: List<E> |
| '''); |
| } |
| |
| test_enum_field() async { |
| var library = await checkLibrary(r''' |
| enum E { |
| v; |
| final foo = 42; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| enums |
| enum E @5 |
| supertype: Enum |
| fields |
| static const enumConstant v @11 |
| type: E |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: self::@enum::E::@constructor::• |
| staticType: null |
| staticElement: self::@enum::E::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: self::@enum::E::@getter::v |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| final foo @22 |
| type: int |
| constantInitializer |
| IntegerLiteral |
| literal: 42 @28 |
| staticType: int |
| constructors |
| synthetic const @-1 |
| accessors |
| synthetic static get v @-1 |
| returnType: E |
| synthetic static get values @-1 |
| returnType: List<E> |
| synthetic get foo @-1 |
| returnType: int |
| '''); |
| } |
| |
| test_enum_getter() async { |
| var library = await checkLibrary(r''' |
| enum E{ |
| v; |
| int get foo => 0; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| enums |
| enum E @5 |
| supertype: Enum |
| fields |
| static const enumConstant v @10 |
| type: E |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: self::@enum::E::@constructor::• |
| staticType: null |
| staticElement: self::@enum::E::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: self::@enum::E::@getter::v |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| synthetic foo @-1 |
| type: int |
| constructors |
| synthetic const @-1 |
| accessors |
| synthetic static get v @-1 |
| returnType: E |
| synthetic static get values @-1 |
| returnType: List<E> |
| get foo @23 |
| returnType: int |
| '''); |
| } |
| |
| test_enum_interfaces() async { |
| var library = await checkLibrary(r''' |
| class I {} |
| enum E implements I { |
| v; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class I @6 |
| constructors |
| synthetic @-1 |
| enums |
| enum E @16 |
| supertype: Enum |
| interfaces |
| I |
| fields |
| static const enumConstant v @35 |
| type: E |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: self::@enum::E::@constructor::• |
| staticType: null |
| staticElement: self::@enum::E::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: self::@enum::E::@getter::v |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| constructors |
| synthetic const @-1 |
| accessors |
| synthetic static get v @-1 |
| returnType: E |
| synthetic static get values @-1 |
| returnType: List<E> |
| '''); |
| } |
| |
| test_enum_interfaces_generic() async { |
| var library = await checkLibrary(r''' |
| class I<T> {} |
| enum E<U> implements I<U> { |
| v; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class I @6 |
| typeParameters |
| covariant T @8 |
| defaultType: dynamic |
| constructors |
| synthetic @-1 |
| enums |
| enum E @19 |
| typeParameters |
| covariant U @21 |
| defaultType: dynamic |
| supertype: Enum |
| interfaces |
| I<U> |
| fields |
| static const enumConstant v @44 |
| type: E<dynamic> |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E<dynamic> |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: ConstructorMember |
| base: self::@enum::E::@constructor::• |
| substitution: {U: dynamic} |
| staticType: null |
| staticElement: ConstructorMember |
| base: self::@enum::E::@constructor::• |
| substitution: {U: dynamic} |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E<dynamic> |
| synthetic static const values @-1 |
| type: List<E<dynamic>> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: self::@enum::E::@getter::v |
| staticType: E<dynamic> |
| rightBracket: ] @0 |
| staticType: List<E<dynamic>> |
| constructors |
| synthetic const @-1 |
| accessors |
| synthetic static get v @-1 |
| returnType: E<dynamic> |
| synthetic static get values @-1 |
| returnType: List<E<dynamic>> |
| '''); |
| } |
| |
| test_enum_interfaces_unresolved() async { |
| var library = await checkLibrary(''' |
| class X {} |
| class Z {} |
| enum E implements X, Y, Z { |
| v |
| } |
| ''', allowErrors: true); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class X @6 |
| constructors |
| synthetic @-1 |
| class Z @17 |
| constructors |
| synthetic @-1 |
| enums |
| enum E @27 |
| supertype: Enum |
| interfaces |
| X |
| Z |
| fields |
| static const enumConstant v @52 |
| type: E |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: self::@enum::E::@constructor::• |
| staticType: null |
| staticElement: self::@enum::E::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: self::@enum::E::@getter::v |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| constructors |
| synthetic const @-1 |
| accessors |
| synthetic static get v @-1 |
| returnType: E |
| synthetic static get values @-1 |
| returnType: List<E> |
| '''); |
| } |
| |
| test_enum_method() async { |
| var library = await checkLibrary(r''' |
| enum E<T> { |
| v; |
| int foo<U>(T t, U u) => 0; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| enums |
| enum E @5 |
| typeParameters |
| covariant T @7 |
| defaultType: dynamic |
| supertype: Enum |
| fields |
| static const enumConstant v @14 |
| type: E<dynamic> |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E<dynamic> |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: ConstructorMember |
| base: self::@enum::E::@constructor::• |
| substitution: {T: dynamic} |
| staticType: null |
| staticElement: ConstructorMember |
| base: self::@enum::E::@constructor::• |
| substitution: {T: dynamic} |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E<dynamic> |
| synthetic static const values @-1 |
| type: List<E<dynamic>> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: self::@enum::E::@getter::v |
| staticType: E<dynamic> |
| rightBracket: ] @0 |
| staticType: List<E<dynamic>> |
| constructors |
| synthetic const @-1 |
| accessors |
| synthetic static get v @-1 |
| returnType: E<dynamic> |
| synthetic static get values @-1 |
| returnType: List<E<dynamic>> |
| methods |
| foo @23 |
| typeParameters |
| covariant U @27 |
| parameters |
| requiredPositional t @32 |
| type: T |
| requiredPositional u @37 |
| type: U |
| returnType: int |
| '''); |
| } |
| |
| test_enum_method_toString() async { |
| var library = await checkLibrary(r''' |
| enum E { |
| v; |
| String toString() => 'E'; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| enums |
| enum E @5 |
| supertype: Enum |
| fields |
| static const enumConstant v @11 |
| type: E |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: self::@enum::E::@constructor::• |
| staticType: null |
| staticElement: self::@enum::E::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: self::@enum::E::@getter::v |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| constructors |
| synthetic const @-1 |
| accessors |
| synthetic static get v @-1 |
| returnType: E |
| synthetic static get values @-1 |
| returnType: List<E> |
| methods |
| toString @23 |
| returnType: String |
| '''); |
| } |
| |
| test_enum_mixins() async { |
| var library = await checkLibrary(r''' |
| mixin M {} |
| enum E with M { |
| v; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| enums |
| enum E @16 |
| supertype: Enum |
| mixins |
| M |
| fields |
| static const enumConstant v @29 |
| type: E |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: self::@enum::E::@constructor::• |
| staticType: null |
| staticElement: self::@enum::E::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: self::@enum::E::@getter::v |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| constructors |
| synthetic const @-1 |
| accessors |
| synthetic static get v @-1 |
| returnType: E |
| synthetic static get values @-1 |
| returnType: List<E> |
| mixins |
| mixin M @6 |
| superclassConstraints |
| Object |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_enum_mixins_inference() async { |
| var library = await checkLibrary(r''' |
| mixin M1<T> {} |
| mixin M2<T> on M1<T> {} |
| enum E with M1<int>, M2 { |
| v; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| enums |
| enum E @44 |
| supertype: Enum |
| mixins |
| M1<int> |
| M2<int> |
| fields |
| static const enumConstant v @67 |
| type: E |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: self::@enum::E::@constructor::• |
| staticType: null |
| staticElement: self::@enum::E::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: self::@enum::E::@getter::v |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| constructors |
| synthetic const @-1 |
| accessors |
| synthetic static get v @-1 |
| returnType: E |
| synthetic static get values @-1 |
| returnType: List<E> |
| mixins |
| mixin M1 @6 |
| typeParameters |
| covariant T @9 |
| defaultType: dynamic |
| superclassConstraints |
| Object |
| constructors |
| synthetic @-1 |
| mixin M2 @21 |
| typeParameters |
| covariant T @24 |
| defaultType: dynamic |
| superclassConstraints |
| M1<T> |
| constructors |
| synthetic @-1 |
| '''); |
| } |
| |
| test_enum_setter() async { |
| var library = await checkLibrary(r''' |
| enum E{ |
| v; |
| set foo(int _) {} |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| enums |
| enum E @5 |
| supertype: Enum |
| fields |
| static const enumConstant v @10 |
| type: E |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: self::@enum::E::@constructor::• |
| staticType: null |
| staticElement: self::@enum::E::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: self::@enum::E::@getter::v |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| synthetic foo @-1 |
| type: int |
| constructors |
| synthetic const @-1 |
| accessors |
| synthetic static get v @-1 |
| returnType: E |
| synthetic static get values @-1 |
| returnType: List<E> |
| set foo @19 |
| parameters |
| requiredPositional _ @27 |
| type: int |
| returnType: void |
| '''); |
| } |
| |
| test_enum_typeParameters() async { |
| var library = await checkLibrary(''' |
| enum E<T> { |
| v |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| enums |
| enum E @5 |
| typeParameters |
| covariant T @7 |
| defaultType: dynamic |
| supertype: Enum |
| fields |
| static const enumConstant v @14 |
| type: E<dynamic> |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E<dynamic> |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: ConstructorMember |
| base: self::@enum::E::@constructor::• |
| substitution: {T: dynamic} |
| staticType: null |
| staticElement: ConstructorMember |
| base: self::@enum::E::@constructor::• |
| substitution: {T: dynamic} |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E<dynamic> |
| synthetic static const values @-1 |
| type: List<E<dynamic>> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: self::@enum::E::@getter::v |
| staticType: E<dynamic> |
| rightBracket: ] @0 |
| staticType: List<E<dynamic>> |
| constructors |
| synthetic const @-1 |
| accessors |
| synthetic static get v @-1 |
| returnType: E<dynamic> |
| synthetic static get values @-1 |
| returnType: List<E<dynamic>> |
| '''); |
| } |
| |
| test_enum_typeParameters_bound() async { |
| var library = await checkLibrary(''' |
| enum E<T extends num, U extends T> { |
| v |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| enums |
| notSimplyBounded enum E @5 |
| typeParameters |
| covariant T @7 |
| bound: num |
| defaultType: num |
| covariant U @22 |
| bound: T |
| defaultType: num |
| supertype: Enum |
| fields |
| static const enumConstant v @39 |
| type: E<num, num> |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E<num, num> |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: ConstructorMember |
| base: self::@enum::E::@constructor::• |
| substitution: {T: num, U: num} |
| staticType: null |
| staticElement: ConstructorMember |
| base: self::@enum::E::@constructor::• |
| substitution: {T: num, U: num} |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E<num, num> |
| synthetic static const values @-1 |
| type: List<E<num, num>> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v @-1 |
| staticElement: self::@enum::E::@getter::v |
| staticType: E<num, num> |
| rightBracket: ] @0 |
| staticType: List<E<num, num>> |
| constructors |
| synthetic const @-1 |
| accessors |
| synthetic static get v @-1 |
| returnType: E<num, num> |
| synthetic static get values @-1 |
| returnType: List<E<num, num>> |
| '''); |
| } |
| |
| test_enum_typeParameters_cycle_1of1() async { |
| var library = await checkLibrary(''' |
| enum E<T extends T> {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| enums |
| notSimplyBounded enum E @5 |
| typeParameters |
| covariant T @7 |
| bound: dynamic |
| defaultType: dynamic |
| supertype: Enum |
| fields |
| synthetic static const values @-1 |
| type: List<E<dynamic>> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| rightBracket: ] @0 |
| staticType: List<E<dynamic>> |
| constructors |
| synthetic const @-1 |
| accessors |
| synthetic static get values @-1 |
| returnType: List<E<dynamic>> |
| '''); |
| } |
| |
| test_enum_typeParameters_cycle_2of3() async { |
| var library = await checkLibrary(r''' |
| enum E<T extends V, U extends num, V extends T> {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| enums |
| notSimplyBounded enum E @5 |
| 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 |
| type: List<E<dynamic, num, dynamic>> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| rightBracket: ] @0 |
| staticType: List<E<dynamic, num, dynamic>> |
| constructors |
| synthetic const @-1 |
| accessors |
| synthetic static get values @-1 |
| returnType: List<E<dynamic, num, dynamic>> |
| '''); |
| } |
| |
| test_enum_typeParameters_defaultType_cycle_genericFunctionType() async { |
| var library = await checkLibrary(r''' |
| enum E<T extends void Function(E)> {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| enums |
| notSimplyBounded enum E @5 |
| typeParameters |
| covariant T @7 |
| bound: void Function(E<dynamic>) |
| defaultType: dynamic |
| supertype: Enum |
| fields |
| synthetic static const values @-1 |
| type: List<E<dynamic>> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| rightBracket: ] @0 |
| staticType: List<E<dynamic>> |
| constructors |
| synthetic const @-1 |
| accessors |
| synthetic static get values @-1 |
| returnType: List<E<dynamic>> |
| '''); |
| } |
| |
| test_enum_typeParameters_variance_contravariant() async { |
| var library = await checkLibrary(''' |
| enum E<in T> {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| enums |
| enum E @5 |
| typeParameters |
| contravariant T @10 |
| defaultType: dynamic |
| supertype: Enum |
| fields |
| synthetic static const values @-1 |
| type: List<E<dynamic>> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| rightBracket: ] @0 |
| staticType: List<E<dynamic>> |
| constructors |
| synthetic const @-1 |
| accessors |
| synthetic static get values @-1 |
| returnType: List<E<dynamic>> |
| '''); |
| } |
| |
| test_enum_typeParameters_variance_covariant() async { |
| var library = await checkLibrary(''' |
| enum E<out T> {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| enums |
| enum E @5 |
| typeParameters |
| covariant T @11 |
| defaultType: dynamic |
| supertype: Enum |
| fields |
| synthetic static const values @-1 |
| type: List<E<dynamic>> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| rightBracket: ] @0 |
| staticType: List<E<dynamic>> |
| constructors |
| synthetic const @-1 |
| accessors |
| synthetic static get values @-1 |
| returnType: List<E<dynamic>> |
| '''); |
| } |
| |
| test_enum_typeParameters_variance_invariant() async { |
| var library = await checkLibrary(''' |
| enum E<inout T> {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| enums |
| enum E @5 |
| typeParameters |
| invariant T @13 |
| defaultType: dynamic |
| supertype: Enum |
| fields |
| synthetic static const values @-1 |
| type: List<E<dynamic>> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| rightBracket: ] @0 |
| staticType: List<E<dynamic>> |
| constructors |
| synthetic const @-1 |
| accessors |
| synthetic static get values @-1 |
| returnType: List<E<dynamic>> |
| '''); |
| } |
| |
| test_enum_typeParameters_variance_multiple() async { |
| var library = await checkLibrary(''' |
| enum E<inout T, in U, out V> {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| enums |
| enum E @5 |
| typeParameters |
| invariant T @13 |
| defaultType: dynamic |
| contravariant U @19 |
| defaultType: dynamic |
| covariant V @26 |
| defaultType: dynamic |
| supertype: Enum |
| fields |
| synthetic static const values @-1 |
| type: List<E<dynamic, dynamic, dynamic>> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| rightBracket: ] @0 |
| staticType: List<E<dynamic, dynamic, dynamic>> |
| constructors |
| synthetic const @-1 |
| accessors |
| synthetic static get values @-1 |
| returnType: List<E<dynamic, dynamic, dynamic>> |
| '''); |
| } |
| |
| test_enum_value_documented() async { |
| var library = await checkLibrary(''' |
| enum E { |
| /** |
| * aaa |
| */ |
| a, |
| /// bbb |
| b |
| }'''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| enums |
| enum E @5 |
| supertype: Enum |
| fields |
| static const enumConstant a @32 |
| documentationComment: /**\n * aaa\n */ |
| type: E |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: self::@enum::E::@constructor::• |
| staticType: null |
| staticElement: self::@enum::E::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| static const enumConstant b @47 |
| documentationComment: /// bbb |
| type: E |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: self::@enum::E::@constructor::• |
| staticType: null |
| staticElement: self::@enum::E::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: a @-1 |
| staticElement: self::@enum::E::@getter::a |
| staticType: E |
| SimpleIdentifier |
| token: b @-1 |
| staticElement: self::@enum::E::@getter::b |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| constructors |
| synthetic const @-1 |
| accessors |
| synthetic static get a @-1 |
| returnType: E |
| synthetic static get b @-1 |
| returnType: E |
| synthetic static get values @-1 |
| returnType: List<E> |
| '''); |
| } |
| |
| test_enum_value_documented_withMetadata() async { |
| var library = await checkLibrary(''' |
| enum E { |
| /** |
| * aaa |
| */ |
| @annotation |
| a, |
| /// bbb |
| @annotation |
| b, |
| } |
| |
| const int annotation = 0; |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| enums |
| enum E @5 |
| supertype: Enum |
| fields |
| static const enumConstant a @46 |
| documentationComment: /**\n * aaa\n */ |
| metadata |
| Annotation |
| atSign: @ @32 |
| name: SimpleIdentifier |
| token: annotation @33 |
| staticElement: self::@getter::annotation |
| staticType: null |
| element: self::@getter::annotation |
| type: E |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: self::@enum::E::@constructor::• |
| staticType: null |
| staticElement: self::@enum::E::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| static const enumConstant b @75 |
| documentationComment: /// bbb |
| metadata |
| Annotation |
| atSign: @ @61 |
| name: SimpleIdentifier |
| token: annotation @62 |
| staticElement: self::@getter::annotation |
| staticType: null |
| element: self::@getter::annotation |
| type: E |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: self::@enum::E::@constructor::• |
| staticType: null |
| staticElement: self::@enum::E::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: a @-1 |
| staticElement: self::@enum::E::@getter::a |
| staticType: E |
| SimpleIdentifier |
| token: b @-1 |
| staticElement: self::@enum::E::@getter::b |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| constructors |
| synthetic const @-1 |
| accessors |
| synthetic static get a @-1 |
| returnType: E |
| synthetic static get b @-1 |
| returnType: E |
| synthetic static get values @-1 |
| returnType: List<E> |
| topLevelVariables |
| static const annotation @91 |
| type: int |
| constantInitializer |
| IntegerLiteral |
| literal: 0 @104 |
| staticType: int |
| accessors |
| synthetic static get annotation @-1 |
| returnType: int |
| '''); |
| } |
| |
| test_enum_values() async { |
| var library = await checkLibrary('enum E { v1, v2 }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| enums |
| enum E @5 |
| supertype: Enum |
| fields |
| static const enumConstant v1 @9 |
| type: E |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: self::@enum::E::@constructor::• |
| staticType: null |
| staticElement: self::@enum::E::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| static const enumConstant v2 @13 |
| type: E |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: self::@enum::E::@constructor::• |
| staticType: null |
| staticElement: self::@enum::E::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v1 @-1 |
| staticElement: self::@enum::E::@getter::v1 |
| staticType: E |
| SimpleIdentifier |
| token: v2 @-1 |
| staticElement: self::@enum::E::@getter::v2 |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| constructors |
| synthetic const @-1 |
| accessors |
| synthetic static get v1 @-1 |
| returnType: E |
| synthetic static get v2 @-1 |
| returnType: E |
| synthetic static get values @-1 |
| returnType: List<E> |
| '''); |
| } |
| |
| test_enums() async { |
| var library = await checkLibrary('enum E1 { v1 } enum E2 { v2 }'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| enums |
| enum E1 @5 |
| supertype: Enum |
| fields |
| static const enumConstant v1 @10 |
| type: E1 |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E1 @-1 |
| staticElement: self::@enum::E1 |
| staticType: null |
| type: E1 |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: self::@enum::E1::@constructor::• |
| staticType: null |
| staticElement: self::@enum::E1::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E1 |
| synthetic static const values @-1 |
| type: List<E1> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v1 @-1 |
| staticElement: self::@enum::E1::@getter::v1 |
| staticType: E1 |
| rightBracket: ] @0 |
| staticType: List<E1> |
| constructors |
| synthetic const @-1 |
| accessors |
| synthetic static get v1 @-1 |
| returnType: E1 |
| synthetic static get values @-1 |
| returnType: List<E1> |
| enum E2 @20 |
| supertype: Enum |
| fields |
| static const enumConstant v2 @25 |
| type: E2 |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E2 @-1 |
| staticElement: self::@enum::E2 |
| staticType: null |
| type: E2 |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: self::@enum::E2::@constructor::• |
| staticType: null |
| staticElement: self::@enum::E2::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E2 |
| synthetic static const values @-1 |
| type: List<E2> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: v2 @-1 |
| staticElement: self::@enum::E2::@getter::v2 |
| staticType: E2 |
| rightBracket: ] @0 |
| staticType: List<E2> |
| constructors |
| synthetic const @-1 |
| accessors |
| synthetic static get v2 @-1 |
| returnType: E2 |
| synthetic static get values @-1 |
| returnType: List<E2> |
| '''); |
| } |
| |
| test_error_extendsEnum() async { |
| var library = await checkLibrary(''' |
| 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 |
| definingUnit |
| classes |
| class M @24 |
| constructors |
| synthetic @-1 |
| class A @36 |
| constructors |
| synthetic @-1 |
| methods |
| foo @52 |
| returnType: dynamic |
| class B @70 |
| interfaces |
| M |
| constructors |
| synthetic @-1 |
| methods |
| foo @92 |
| returnType: dynamic |
| class C @110 |
| supertype: Object |
| mixins |
| M |
| constructors |
| synthetic @-1 |
| methods |
| foo @141 |
| returnType: dynamic |
| class alias D @159 |
| supertype: Object |
| mixins |
| M |
| constructors |
| synthetic const @-1 |
| constantInitializers |
| SuperConstructorInvocation |
| superKeyword: super @0 |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticElement: dart:core::@class::Object::@constructor::• |
| enums |
| enum E @5 |
| supertype: Enum |
| fields |
| static const enumConstant a @8 |
| type: E |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: self::@enum::E::@constructor::• |
| staticType: null |
| staticElement: self::@enum::E::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| static const enumConstant b @11 |
| type: E |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: self::@enum::E::@constructor::• |
| staticType: null |
| staticElement: self::@enum::E::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| static const enumConstant c @14 |
| type: E |
| constantInitializer |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: SimpleIdentifier |
| token: E @-1 |
| staticElement: self::@enum::E |
| staticType: null |
| type: E |
| period: . @0 |
| name: SimpleIdentifier |
| token: <empty> @-1 <synthetic> |
| staticElement: self::@enum::E::@constructor::• |
| staticType: null |
| staticElement: self::@enum::E::@constructor::• |
| argumentList: ArgumentList |
| leftParenthesis: ( @0 |
| rightParenthesis: ) @0 |
| staticType: E |
| synthetic static const values @-1 |
| type: List<E> |
| constantInitializer |
| ListLiteral |
| leftBracket: [ @0 |
| elements |
| SimpleIdentifier |
| token: a @-1 |
| staticElement: self::@enum::E::@getter::a |
| staticType: E |
| SimpleIdentifier |
| token: b @-1 |
| staticElement: self::@enum::E::@getter::b |
| staticType: E |
| SimpleIdentifier |
| token: c @-1 |
| staticElement: self::@enum::E::@getter::c |
| staticType: E |
| rightBracket: ] @0 |
| staticType: List<E> |
| constructors |
| synthetic const @-1 |
| accessors |
| synthetic static get a @-1 |
| returnType: E |
| synthetic static get b @-1 |
| returnType: E |
| synthetic static get c @-1 |
| returnType: E |
| synthetic static get values @-1 |
| returnType: List<E> |
| '''); |
| } |
| |
| test_executable_parameter_type_typedef() async { |
| var library = await checkLibrary(r''' |
| typedef F(int p); |
| main(F f) {} |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| typeAliases |
| functionTypeAliasBased F @8 |
| aliasedType: dynamic Function(int) |
| aliasedElement: GenericFunctionTypeElement |
| parameters |
| requiredPositional p @14 |
| type: int |
| returnType: dynamic |
| functions |
| main @18 |
| parameters |
| requiredPositional f @25 |
| type: dynamic Function(int) |
| aliasElement: self::@typeAlias::F |
| returnType: dynamic |
| '''); |
| } |
| |
| test_export_class() async { |
| addLibrarySource('/a.dart', 'class C {}'); |
| var library = await checkLibrary('export "a.dart";'); |
| checkElementText( |
| library, |
| r''' |
| library |
| exports |
| a.dart |
| definingUnit |
| exportScope |
| C: a.dart;C |
| ''', |
| withExportScope: true); |
| } |
| |
| test_export_class_type_alias() async { |
| addLibrarySource('/a.dart', r''' |
| class C = _D with _E; |
| class _D {} |
| class _E {} |
| '''); |
| var library = await checkLibrary('export "a.dart";'); |
| checkElementText( |
| library, |
| r''' |
| library |
| exports |
| a.dart |
| definingUnit |
| exportScope |
| C: a.dart;C |
| ''', |
| withExportScope: true); |
| } |
| |
| test_export_configurations_useDefault() async { |
| declaredVariables = DeclaredVariables.fromMap({ |
| 'dart.library.io': 'false', |
| }); |
| addLibrarySource('/foo.dart', 'class A {}'); |
| addLibrarySource('/foo_io.dart', 'class A {}'); |
| addLibrarySource('/foo_html.dart', 'class A {}'); |
| var library = await checkLibrary(r''' |
| export 'foo.dart' |
| if (dart.library.io) 'foo_io.dart' |
| if (dart.library.html) 'foo_html.dart'; |
| '''); |
| checkElementText( |
| library, |
| r''' |
| library |
| exports |
| foo.dart |
| definingUnit |
| exportScope |
| A: foo.dart;A |
| ''', |
| withExportScope: true); |
| expect(library.exports[0].exportedLibrary!.source.shortName, 'foo.dart'); |
| } |
| |
| test_export_configurations_useFirst() async { |
| declaredVariables = DeclaredVariables.fromMap({ |
| 'dart.library.io': 'true', |
| 'dart.library.html': 'true', |
| }); |
| addLibrarySource('/foo.dart', 'class A {}'); |
| addLibrarySource('/foo_io.dart', 'class A {}'); |
| addLibrarySource('/foo_html.dart', 'class A {}'); |
| var library = await checkLibrary(r''' |
| export 'foo.dart' |
| if (dart.library.io) 'foo_io.dart' |
| if (dart.library.html) 'foo_html.dart'; |
| '''); |
| checkElementText( |
| library, |
| r''' |
| library |
| exports |
| foo_io.dart |
| definingUnit |
| exportScope |
| A: foo_io.dart;A |
| ''', |
| withExportScope: true); |
| expect(library.exports[0].exportedLibrary!.source.shortName, 'foo_io.dart'); |
| } |
| |
| test_export_configurations_useSecond() async { |
| declaredVariables = DeclaredVariables.fromMap({ |
| 'dart.library.io': 'false', |
| 'dart.library.html': 'true', |
| }); |
| addLibrarySource('/foo.dart', 'class A {}'); |
| addLibrarySource('/foo_io.dart', 'class A {}'); |
| addLibrarySource('/foo_html.dart', 'class A {}'); |
| var library = await checkLibrary(r''' |
| export 'foo.dart' |
| if (dart.library.io) 'foo_io.dart' |
| if (dart.library.html) 'foo_html.dart'; |
| '''); |
| checkElementText( |
| library, |
| r''' |
| library |
| exports |
| foo_html.dart |
| definingUnit |
| exportScope |
| A: foo_html.dart;A |
| ''', |
| withExportScope: true); |
| ExportElement export = library.exports[0]; |
| expect(export.exportedLibrary!.source.shortName, 'foo_html.dart'); |
| } |
| |
| test_export_function() async { |
| addLibrarySource('/a.dart', 'f() {}'); |
| var library = await checkLibrary('export "a.dart";'); |
| checkElementText( |
| library, |
| r''' |
| library |
| exports |
| a.dart |
| definingUnit |
| exportScope |
| f: a.dart;f |
| ''', |
| withExportScope: true); |
| } |
| |
| test_export_getter() async { |
| addLibrarySource('/a.dart', 'get f() => null;'); |
| var library = await checkLibrary('export "a.dart";'); |
| checkElementText(library, r''' |
| library |
| exports |
| a.dart |
| definingUnit |
| '''); |
| } |
| |
| test_export_hide() async { |
| addLibrary('dart:async'); |
| var library = |
| await checkLibrary('export "dart:async" hide Stream, Future;'); |
| checkElementText( |
| library, |
| r''' |
| library |
| exports |
| dart:async |
| combinators |
| hide: Stream, Future |
| definingUnit |
| exportScope |
| Completer: dart:async;Completer |
| FutureOr: dart:async;FutureOr |
| StreamIterator: dart:async;dart:async/stream.dart;StreamIterator |
| StreamSubscription: dart:async;dart:async/stream.dart;StreamSubscription |
| StreamTransformer: dart:async;dart:async/stream.dart;StreamTransformer |
| Timer: dart:async;Timer |
| ''', |
| withExportScope: true); |
| } |
| |
| test_export_multiple_combinators() async { |
| addLibrary('dart:async'); |
| var library = |
| await checkLibrary('export "dart:async" hide Stream show Future;'); |
| checkElementText( |
| library, |
| r''' |
| library |
| exports |
| dart:async |
| combinators |
| hide: Stream |
| show: Future |
| definingUnit |
| exportScope |
| Future: dart:async;Future |
| ''', |
| withExportScope: true); |
| } |
| |
| test_export_setter() async { |
| addLibrarySource('/a.dart', 'void set f(value) {}'); |
| var library = await checkLibrary('export "a.dart";'); |
| checkElementText( |
| library, |
| r''' |
| library |
| exports |
| a.dart |
| definingUnit |
| exportScope |
| f=: a.dart;f= |
| ''', |
| withExportScope: true); |
| } |
| |
| test_export_show() async { |
| addLibrary('dart:async'); |
| var library = |
| await checkLibrary('export "dart:async" show Future, Stream;'); |
| checkElementText( |
| library, |
| r''' |
| library |
| exports |
| dart:async |
| combinators |
| show: Future, Stream |
| definingUnit |
| exportScope |
| Future: dart:async;Future |
| Stream: dart:async;dart:async/stream.dart;Stream |
| ''', |
| withExportScope: true); |
| } |
| |
| test_export_show_getter_setter() async { |
| addLibrarySource('/a.dart', ''' |
| get f => null; |
| void set f(value) {} |
| '''); |
| var library = await checkLibrary('export "a.dart" show f;'); |
| checkElementText( |
| library, |
| r''' |
| library |
| exports |
| a.dart |
| combinators |
| show: f |
| definingUnit |
| exportScope |
| f: a.dart;f? |
| f=: a.dart;f= |
| ''', |
| withExportScope: true); |
| } |
| |
| test_export_typedef() async { |
| addLibrarySource('/a.dart', 'typedef F();'); |
| var library = await checkLibrary('export "a.dart";'); |
| checkElementText( |
| library, |
| r''' |
| library |
| exports |
| a.dart |
| definingUnit |
| exportScope |
| F: a.dart;F |
| ''', |
| withExportScope: true); |
| } |
| |
| test_export_uri() async { |
| var library = await checkLibrary(''' |
| export 'foo.dart'; |
| '''); |
| expect(library.exports[0].uri, 'foo.dart'); |
| } |
| |
| test_export_variable() async { |
| addLibrarySource('/a.dart', 'var x;'); |
| var library = await checkLibrary('export "a.dart";'); |
| checkElementText( |
| library, |
| r''' |
| library |
| exports |
| a.dart |
| definingUnit |
| exportScope |
| x: a.dart;x? |
| x=: a.dart;x= |
| ''', |
| withExportScope: true); |
| } |
| |
| test_export_variable_const() async { |
| addLibrarySource('/a.dart', 'const x = 0;'); |
| var library = await checkLibrary('export "a.dart";'); |
| checkElementText( |
| library, |
| r''' |
| library |
| exports |
| a.dart |
| definingUnit |
| exportScope |
| x: a.dart;x? |
| ''', |
| withExportScope: true); |
| } |
| |
| test_export_variable_final() async { |
| addLibrarySource('/a.dart', 'final x = 0;'); |
| var library = await checkLibrary('export "a.dart";'); |
| checkElementText( |
| library, |
| r''' |
| library |
| exports |
| a.dart |
| definingUnit |
| exportScope |
| x: a.dart;x? |
| ''', |
| withExportScope: true); |
| } |
| |
| test_exportImport_configurations_useDefault() async { |
| declaredVariables = DeclaredVariables.fromMap({ |
| 'dart.library.io': 'false', |
| }); |
| addLibrarySource('/foo.dart', 'class A {}'); |
| addLibrarySource('/foo_io.dart', 'class A {}'); |
| addLibrarySource('/foo_html.dart', 'class A {}'); |
| addLibrarySource('/bar.dart', r''' |
| export 'foo.dart' |
| if (dart.library.io) 'foo_io.dart' |
| if (dart.library.html) 'foo_html.dart'; |
| '''); |
| var library = await checkLibrary(r''' |
| import 'bar.dart'; |
| class B extends A {} |
| '''); |
| checkElementText(library, r''' |
| library |
| imports |
| bar.dart |
| definingUnit |
| classes |
| class B @25 |
| supertype: A |
| constructors |
| synthetic @-1 |
| superConstructor: foo.dart::@class::A::@constructor::• |
| '''); |
| var typeA = library.definingCompilationUnit.getType('B')!.supertype!; |
| expect(typeA.element.source.shortName, 'foo.dart'); |
| } |
| |
| test_exportImport_configurations_useFirst() async { |
| declaredVariables = DeclaredVariables.fromMap({ |
| 'dart.library.io': 'true', |
| 'dart.library.html': 'false', |
| }); |
| addLibrarySource('/foo.dart', 'class A {}'); |
| addLibrarySource('/foo_io.dart', 'class A {}'); |
| addLibrarySource('/foo_html.dart', 'class A {}'); |
| addLibrarySource('/bar.dart', r''' |
| export 'foo.dart' |
| if (dart.library.io) 'foo_io.dart' |
| if (dart.library.html) 'foo_html.dart'; |
| '''); |
| var library = await checkLibrary(r''' |
| import 'bar.dart'; |
| class B extends A {} |
| '''); |
| checkElementText(library, r''' |
| library |
| imports |
| bar.dart |
| definingUnit |
| classes |
| class B @25 |
| supertype: A |
| constructors |
| synthetic @-1 |
| superConstructor: foo_io.dart::@class::A::@constructor::• |
| '''); |
| var typeA = library.definingCompilationUnit.getType('B')!.supertype!; |
| expect(typeA.element.source.shortName, 'foo_io.dart'); |
| } |
| |
| test_exportImport_configurations_useSecond() async { |
| declaredVariables = DeclaredVariables.fromMap({ |
| 'dart.library.io': 'false', |
| 'dart.library.html': 'true', |
| }); |
| addLibrarySource('/foo.dart', 'class A {}'); |
| addLibrarySource('/foo_io.dart', 'class A {}'); |
| addLibrarySource('/foo_html.dart', 'class A {}'); |
| addLibrarySource('/bar.dart', r''' |
| export 'foo.dart' |
| if (dart.library.io) 'foo_io.dart' |
| if (dart.library.html) 'foo_html.dart'; |
| '''); |
| var library = await checkLibrary(r''' |
| import 'bar.dart'; |
| class B extends A {} |
| '''); |
| checkElementText(library, r''' |
| library |
| imports |
| bar.dart |
| definingUnit |
| classes |
| class B @25 |
| supertype: A |
| constructors |
| synthetic @-1 |
| superConstructor: foo_html.dart::@class::A::@constructor::• |
| '''); |
| var typeA = library.definingCompilationUnit.getType('B')!.supertype!; |
| expect(typeA.element.source.shortName, 'foo_html.dart'); |
| } |
| |
| test_exports() async { |
| addLibrarySource('/a.dart', 'library a;'); |
| addLibrarySource('/b.dart', 'library b;'); |
| var library = await checkLibrary('export "a.dart"; export "b.dart";'); |
| checkElementText( |
| library, |
| r''' |
| library |
| exports |
| a.dart |
| b.dart |
| definingUnit |
| exportScope |
| ''', |
| withExportScope: true); |
| } |
| |
| test_expr_invalid_typeParameter_asPrefix() async { |
| var library = await checkLibrary(''' |
| class C<T> { |
| final f = T.k; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| classes |
| class C @6 |
| typeParameters |
| covariant T @8 |
| defaultType: dynamic |
| fields |
| final f @21 |
| type: dynamic |
| constructors |
| synthetic @-1 |
| accessors |
| synthetic get f @-1 |
| returnType: dynamic |
| '''); |
| } |
| |
| test_extension_documented_tripleSlash() async { |
| var library = await checkLibrary(''' |
| /// aaa |
| /// bbbb |
| /// cc |
| extension E on int {}'''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| extensions |
| E @34 |
| documentationComment: /// aaa\n/// bbbb\n/// cc |
| extendedType: int |
| '''); |
| } |
| |
| test_extension_field_inferredType_const() async { |
| var library = await checkLibrary(''' |
| extension E on int { |
| static const x = 0; |
| }'''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| extensions |
| E @10 |
| extendedType: int |
| fields |
| static const x @36 |
| type: int |
| constantInitializer |
| IntegerLiteral |
| literal: 0 @40 |
| staticType: int |
| accessors |
| synthetic static get x @-1 |
| returnType: int |
| '''); |
| } |
| |
| test_function_async() async { |
| var library = await checkLibrary(r''' |
| import 'dart:async'; |
| Future f() async {} |
| '''); |
| checkElementText(library, r''' |
| library |
| imports |
| dart:async |
| definingUnit |
| functions |
| f @28 async |
| returnType: Future<dynamic> |
| '''); |
| } |
| |
| test_function_asyncStar() async { |
| var library = await checkLibrary(r''' |
| import 'dart:async'; |
| Stream f() async* {} |
| '''); |
| checkElementText(library, r''' |
| library |
| imports |
| dart:async |
| definingUnit |
| functions |
| f @28 async* |
| returnType: Stream<dynamic> |
| '''); |
| } |
| |
| test_function_documented() async { |
| var library = await checkLibrary(''' |
| // Extra comment so doc comment offset != 0 |
| /** |
| * Docs |
| */ |
| f() {}'''); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| functions |
| f @60 |
| documentationComment: /**\n * Docs\n */ |
| returnType: dynamic |
| '''); |
| } |
| |
| test_function_entry_point() async { |
| var library = await checkLibrary('main() {}'); |
| checkElementText(library, r''' |
| library |
| definingUnit |
| functions |
| main @0 |
| |