| // Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file |
| // for details. All rights reserved. Use of this source code is governed by a |
| // BSD-style license that can be found in the LICENSE file. |
| |
| import 'package:analyzer/dart/element/element.dart'; |
| import 'package:test/test.dart'; |
| import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| |
| import '../../dart/resolution/node_text_expectations.dart'; |
| import '../element_text.dart'; |
| import '../elements_base.dart'; |
| |
| main() { |
| defineReflectiveSuite(() { |
| defineReflectiveTests(ClassElementTest_keepLinking); |
| defineReflectiveTests(ClassElementTest_fromBytes); |
| defineReflectiveTests(ClassElementTest_augmentation_keepLinking); |
| defineReflectiveTests(ClassElementTest_augmentation_fromBytes); |
| defineReflectiveTests(UpdateNodeTextExpectations); |
| }); |
| } |
| |
| abstract class ClassElementTest extends ElementsBaseTest { |
| test_class_abstract() async { |
| var library = await buildLibrary('abstract class C {}'); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| abstract class C @15 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| constructors |
| synthetic @-1 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| '''); |
| } |
| |
| test_class_base() async { |
| var library = await buildLibrary('base class C {}'); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| base class C @11 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| constructors |
| synthetic @-1 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| '''); |
| } |
| |
| test_class_constructor_const() async { |
| var library = await buildLibrary('class C { const C(); }'); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| constructors |
| const @16 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| '''); |
| } |
| |
| test_class_constructor_const_external() async { |
| var library = await buildLibrary('class C { external const C(); }'); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| constructors |
| external const @25 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| '''); |
| } |
| |
| test_class_constructor_documented() async { |
| var library = await buildLibrary(''' |
| class C { |
| /** |
| * Docs |
| */ |
| C(); |
| }'''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| constructors |
| @34 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| documentationComment: /**\n * Docs\n */ |
| '''); |
| } |
| |
| test_class_constructor_explicit_named() async { |
| var library = await buildLibrary('class C { C.foo(); }'); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| constructors |
| foo @12 |
| reference: <testLibraryFragment>::@class::C::@constructor::foo |
| enclosingElement: <testLibraryFragment>::@class::C |
| periodOffset: 11 |
| nameEnd: 15 |
| '''); |
| } |
| |
| test_class_constructor_explicit_type_params() async { |
| var library = await buildLibrary('class C<T, U> { C(); }'); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| typeParameters |
| covariant T @8 |
| defaultType: dynamic |
| covariant U @11 |
| defaultType: dynamic |
| constructors |
| @16 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| '''); |
| } |
| |
| test_class_constructor_explicit_unnamed() async { |
| var library = await buildLibrary('class C { C(); }'); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| constructors |
| @10 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| '''); |
| } |
| |
| test_class_constructor_external() async { |
| var library = await buildLibrary('class C { external C(); }'); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| constructors |
| external @19 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| '''); |
| } |
| |
| test_class_constructor_factory() async { |
| var library = await buildLibrary('class C { factory C() => throw 0; }'); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| constructors |
| factory @18 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| '''); |
| } |
| |
| test_class_constructor_field_formal_dynamic_dynamic() async { |
| var library = |
| await buildLibrary('class C { dynamic x; C(dynamic this.x); }'); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| fields |
| x @18 |
| reference: <testLibraryFragment>::@class::C::@field::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| type: dynamic |
| constructors |
| @21 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| parameters |
| requiredPositional final this.x @36 |
| type: dynamic |
| field: <testLibraryFragment>::@class::C::@field::x |
| accessors |
| synthetic get x @-1 |
| reference: <testLibraryFragment>::@class::C::@getter::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| returnType: dynamic |
| synthetic set x= @-1 |
| reference: <testLibraryFragment>::@class::C::@setter::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| parameters |
| requiredPositional _x @-1 |
| type: dynamic |
| returnType: void |
| '''); |
| } |
| |
| test_class_constructor_field_formal_dynamic_typed() async { |
| var library = await buildLibrary('class C { dynamic x; C(int this.x); }'); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| fields |
| x @18 |
| reference: <testLibraryFragment>::@class::C::@field::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| type: dynamic |
| constructors |
| @21 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| parameters |
| requiredPositional final this.x @32 |
| type: int |
| field: <testLibraryFragment>::@class::C::@field::x |
| accessors |
| synthetic get x @-1 |
| reference: <testLibraryFragment>::@class::C::@getter::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| returnType: dynamic |
| synthetic set x= @-1 |
| reference: <testLibraryFragment>::@class::C::@setter::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| parameters |
| requiredPositional _x @-1 |
| type: dynamic |
| returnType: void |
| '''); |
| } |
| |
| test_class_constructor_field_formal_dynamic_untyped() async { |
| var library = await buildLibrary('class C { dynamic x; C(this.x); }'); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| fields |
| x @18 |
| reference: <testLibraryFragment>::@class::C::@field::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| type: dynamic |
| constructors |
| @21 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| parameters |
| requiredPositional final this.x @28 |
| type: dynamic |
| field: <testLibraryFragment>::@class::C::@field::x |
| accessors |
| synthetic get x @-1 |
| reference: <testLibraryFragment>::@class::C::@getter::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| returnType: dynamic |
| synthetic set x= @-1 |
| reference: <testLibraryFragment>::@class::C::@setter::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| parameters |
| requiredPositional _x @-1 |
| type: dynamic |
| returnType: void |
| '''); |
| } |
| |
| test_class_constructor_field_formal_functionTyped_noReturnType() async { |
| var library = await buildLibrary(r''' |
| class C { |
| var x; |
| C(this.x(double b)); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| fields |
| x @16 |
| reference: <testLibraryFragment>::@class::C::@field::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| type: dynamic |
| constructors |
| @21 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| parameters |
| requiredPositional final this.x @28 |
| type: dynamic Function(double) |
| parameters |
| requiredPositional b @37 |
| type: double |
| field: <testLibraryFragment>::@class::C::@field::x |
| accessors |
| synthetic get x @-1 |
| reference: <testLibraryFragment>::@class::C::@getter::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| returnType: dynamic |
| synthetic set x= @-1 |
| reference: <testLibraryFragment>::@class::C::@setter::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| parameters |
| requiredPositional _x @-1 |
| type: dynamic |
| returnType: void |
| '''); |
| } |
| |
| test_class_constructor_field_formal_functionTyped_withReturnType() async { |
| var library = await buildLibrary(r''' |
| class C { |
| var x; |
| C(int this.x(double b)); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| fields |
| x @16 |
| reference: <testLibraryFragment>::@class::C::@field::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| type: dynamic |
| constructors |
| @21 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| parameters |
| requiredPositional final this.x @32 |
| type: int Function(double) |
| parameters |
| requiredPositional b @41 |
| type: double |
| field: <testLibraryFragment>::@class::C::@field::x |
| accessors |
| synthetic get x @-1 |
| reference: <testLibraryFragment>::@class::C::@getter::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| returnType: dynamic |
| synthetic set x= @-1 |
| reference: <testLibraryFragment>::@class::C::@setter::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| parameters |
| requiredPositional _x @-1 |
| type: dynamic |
| returnType: void |
| '''); |
| } |
| |
| test_class_constructor_field_formal_functionTyped_withReturnType_generic() async { |
| var library = await buildLibrary(r''' |
| class C { |
| Function() f; |
| C(List<U> this.f<T, U>(T t)); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| fields |
| f @23 |
| reference: <testLibraryFragment>::@class::C::@field::f |
| enclosingElement: <testLibraryFragment>::@class::C |
| type: dynamic Function() |
| constructors |
| @28 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| 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: <testLibraryFragment>::@class::C::@field::f |
| accessors |
| synthetic get f @-1 |
| reference: <testLibraryFragment>::@class::C::@getter::f |
| enclosingElement: <testLibraryFragment>::@class::C |
| returnType: dynamic Function() |
| synthetic set f= @-1 |
| reference: <testLibraryFragment>::@class::C::@setter::f |
| enclosingElement: <testLibraryFragment>::@class::C |
| 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 buildLibrary('class C { C(this.x); int x; String x; }'); |
| |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| fields |
| x @25 |
| reference: <testLibraryFragment>::@class::C::@field::x::@def::0 |
| enclosingElement: <testLibraryFragment>::@class::C |
| type: int |
| x @35 |
| reference: <testLibraryFragment>::@class::C::@field::x::@def::1 |
| enclosingElement: <testLibraryFragment>::@class::C |
| type: String |
| constructors |
| @10 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| parameters |
| requiredPositional final this.x @17 |
| type: int |
| field: <testLibraryFragment>::@class::C::@field::x::@def::0 |
| accessors |
| synthetic get x @-1 |
| reference: <testLibraryFragment>::@class::C::@getter::x::@def::0 |
| enclosingElement: <testLibraryFragment>::@class::C |
| returnType: int |
| synthetic set x= @-1 |
| reference: <testLibraryFragment>::@class::C::@setter::x::@def::0 |
| enclosingElement: <testLibraryFragment>::@class::C |
| parameters |
| requiredPositional _x @-1 |
| type: int |
| returnType: void |
| synthetic get x @-1 |
| reference: <testLibraryFragment>::@class::C::@getter::x::@def::1 |
| enclosingElement: <testLibraryFragment>::@class::C |
| returnType: String |
| synthetic set x= @-1 |
| reference: <testLibraryFragment>::@class::C::@setter::x::@def::1 |
| enclosingElement: <testLibraryFragment>::@class::C |
| 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 buildLibrary('class C { C(this.x); }'); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| constructors |
| @10 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| parameters |
| requiredPositional final this.x @17 |
| type: dynamic |
| field: <null> |
| '''); |
| } |
| |
| test_class_constructor_field_formal_typed_dynamic() async { |
| var library = await buildLibrary('class C { num x; C(dynamic this.x); }'); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| fields |
| x @14 |
| reference: <testLibraryFragment>::@class::C::@field::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| type: num |
| constructors |
| @17 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| parameters |
| requiredPositional final this.x @32 |
| type: dynamic |
| field: <testLibraryFragment>::@class::C::@field::x |
| accessors |
| synthetic get x @-1 |
| reference: <testLibraryFragment>::@class::C::@getter::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| returnType: num |
| synthetic set x= @-1 |
| reference: <testLibraryFragment>::@class::C::@setter::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| parameters |
| requiredPositional _x @-1 |
| type: num |
| returnType: void |
| '''); |
| } |
| |
| test_class_constructor_field_formal_typed_typed() async { |
| var library = await buildLibrary('class C { num x; C(int this.x); }'); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| fields |
| x @14 |
| reference: <testLibraryFragment>::@class::C::@field::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| type: num |
| constructors |
| @17 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| parameters |
| requiredPositional final this.x @28 |
| type: int |
| field: <testLibraryFragment>::@class::C::@field::x |
| accessors |
| synthetic get x @-1 |
| reference: <testLibraryFragment>::@class::C::@getter::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| returnType: num |
| synthetic set x= @-1 |
| reference: <testLibraryFragment>::@class::C::@setter::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| parameters |
| requiredPositional _x @-1 |
| type: num |
| returnType: void |
| '''); |
| } |
| |
| test_class_constructor_field_formal_typed_untyped() async { |
| var library = await buildLibrary('class C { num x; C(this.x); }'); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| fields |
| x @14 |
| reference: <testLibraryFragment>::@class::C::@field::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| type: num |
| constructors |
| @17 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| parameters |
| requiredPositional final this.x @24 |
| type: num |
| field: <testLibraryFragment>::@class::C::@field::x |
| accessors |
| synthetic get x @-1 |
| reference: <testLibraryFragment>::@class::C::@getter::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| returnType: num |
| synthetic set x= @-1 |
| reference: <testLibraryFragment>::@class::C::@setter::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| parameters |
| requiredPositional _x @-1 |
| type: num |
| returnType: void |
| '''); |
| } |
| |
| test_class_constructor_field_formal_untyped_dynamic() async { |
| var library = await buildLibrary('class C { var x; C(dynamic this.x); }'); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| fields |
| x @14 |
| reference: <testLibraryFragment>::@class::C::@field::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| type: dynamic |
| constructors |
| @17 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| parameters |
| requiredPositional final this.x @32 |
| type: dynamic |
| field: <testLibraryFragment>::@class::C::@field::x |
| accessors |
| synthetic get x @-1 |
| reference: <testLibraryFragment>::@class::C::@getter::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| returnType: dynamic |
| synthetic set x= @-1 |
| reference: <testLibraryFragment>::@class::C::@setter::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| parameters |
| requiredPositional _x @-1 |
| type: dynamic |
| returnType: void |
| '''); |
| } |
| |
| test_class_constructor_field_formal_untyped_typed() async { |
| var library = await buildLibrary('class C { var x; C(int this.x); }'); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| fields |
| x @14 |
| reference: <testLibraryFragment>::@class::C::@field::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| type: dynamic |
| constructors |
| @17 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| parameters |
| requiredPositional final this.x @28 |
| type: int |
| field: <testLibraryFragment>::@class::C::@field::x |
| accessors |
| synthetic get x @-1 |
| reference: <testLibraryFragment>::@class::C::@getter::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| returnType: dynamic |
| synthetic set x= @-1 |
| reference: <testLibraryFragment>::@class::C::@setter::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| parameters |
| requiredPositional _x @-1 |
| type: dynamic |
| returnType: void |
| '''); |
| } |
| |
| test_class_constructor_field_formal_untyped_untyped() async { |
| var library = await buildLibrary('class C { var x; C(this.x); }'); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| fields |
| x @14 |
| reference: <testLibraryFragment>::@class::C::@field::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| type: dynamic |
| constructors |
| @17 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| parameters |
| requiredPositional final this.x @24 |
| type: dynamic |
| field: <testLibraryFragment>::@class::C::@field::x |
| accessors |
| synthetic get x @-1 |
| reference: <testLibraryFragment>::@class::C::@getter::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| returnType: dynamic |
| synthetic set x= @-1 |
| reference: <testLibraryFragment>::@class::C::@setter::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| parameters |
| requiredPositional _x @-1 |
| type: dynamic |
| returnType: void |
| '''); |
| } |
| |
| test_class_constructor_fieldFormal_named_noDefault() async { |
| var library = await buildLibrary('class C { int x; C({this.x}); }'); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| fields |
| x @14 |
| reference: <testLibraryFragment>::@class::C::@field::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| type: int |
| constructors |
| @17 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| parameters |
| optionalNamed default final this.x @25 |
| reference: <testLibraryFragment>::@class::C::@constructor::new::@parameter::x |
| type: int |
| field: <testLibraryFragment>::@class::C::@field::x |
| accessors |
| synthetic get x @-1 |
| reference: <testLibraryFragment>::@class::C::@getter::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| returnType: int |
| synthetic set x= @-1 |
| reference: <testLibraryFragment>::@class::C::@setter::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| parameters |
| requiredPositional _x @-1 |
| type: int |
| returnType: void |
| '''); |
| } |
| |
| test_class_constructor_fieldFormal_named_withDefault() async { |
| var library = await buildLibrary('class C { int x; C({this.x: 42}); }'); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| fields |
| x @14 |
| reference: <testLibraryFragment>::@class::C::@field::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| type: int |
| constructors |
| @17 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| parameters |
| optionalNamed default final this.x @25 |
| reference: <testLibraryFragment>::@class::C::@constructor::new::@parameter::x |
| type: int |
| constantInitializer |
| IntegerLiteral |
| literal: 42 @28 |
| staticType: int |
| field: <testLibraryFragment>::@class::C::@field::x |
| accessors |
| synthetic get x @-1 |
| reference: <testLibraryFragment>::@class::C::@getter::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| returnType: int |
| synthetic set x= @-1 |
| reference: <testLibraryFragment>::@class::C::@setter::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| parameters |
| requiredPositional _x @-1 |
| type: int |
| returnType: void |
| '''); |
| } |
| |
| test_class_constructor_fieldFormal_optional_noDefault() async { |
| var library = await buildLibrary('class C { int x; C([this.x]); }'); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| fields |
| x @14 |
| reference: <testLibraryFragment>::@class::C::@field::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| type: int |
| constructors |
| @17 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| parameters |
| optionalPositional default final this.x @25 |
| type: int |
| field: <testLibraryFragment>::@class::C::@field::x |
| accessors |
| synthetic get x @-1 |
| reference: <testLibraryFragment>::@class::C::@getter::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| returnType: int |
| synthetic set x= @-1 |
| reference: <testLibraryFragment>::@class::C::@setter::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| parameters |
| requiredPositional _x @-1 |
| type: int |
| returnType: void |
| '''); |
| } |
| |
| test_class_constructor_fieldFormal_optional_withDefault() async { |
| var library = await buildLibrary('class C { int x; C([this.x = 42]); }'); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| fields |
| x @14 |
| reference: <testLibraryFragment>::@class::C::@field::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| type: int |
| constructors |
| @17 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| parameters |
| optionalPositional default final this.x @25 |
| type: int |
| constantInitializer |
| IntegerLiteral |
| literal: 42 @29 |
| staticType: int |
| field: <testLibraryFragment>::@class::C::@field::x |
| accessors |
| synthetic get x @-1 |
| reference: <testLibraryFragment>::@class::C::@getter::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| returnType: int |
| synthetic set x= @-1 |
| reference: <testLibraryFragment>::@class::C::@setter::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| parameters |
| requiredPositional _x @-1 |
| type: int |
| returnType: void |
| '''); |
| } |
| |
| test_class_constructor_implicit_type_params() async { |
| var library = await buildLibrary('class C<T, U> {}'); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| typeParameters |
| covariant T @8 |
| defaultType: dynamic |
| covariant U @11 |
| defaultType: dynamic |
| constructors |
| synthetic @-1 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| '''); |
| } |
| |
| test_class_constructor_initializers_assertInvocation() async { |
| var library = await buildLibrary(''' |
| class C { |
| const C(int x) : assert(x >= 42); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| constructors |
| const @18 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| parameters |
| requiredPositional x @24 |
| type: int |
| constantInitializers |
| AssertInitializer |
| assertKeyword: assert @29 |
| leftParenthesis: ( @35 |
| condition: BinaryExpression |
| leftOperand: SimpleIdentifier |
| token: x @36 |
| staticElement: <testLibraryFragment>::@class::C::@constructor::new::@parameter::x |
| staticType: int |
| operator: >= @38 |
| rightOperand: IntegerLiteral |
| literal: 42 @41 |
| staticType: int |
| staticElement: dart:core::<fragment>::@class::num::@method::>= |
| staticInvokeType: bool Function(num) |
| staticType: bool |
| rightParenthesis: ) @43 |
| '''); |
| } |
| |
| test_class_constructor_initializers_assertInvocation_message() async { |
| var library = await buildLibrary(''' |
| class C { |
| const C(int x) : assert(x >= 42, 'foo'); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| constructors |
| const @18 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| parameters |
| requiredPositional x @24 |
| type: int |
| constantInitializers |
| AssertInitializer |
| assertKeyword: assert @29 |
| leftParenthesis: ( @35 |
| condition: BinaryExpression |
| leftOperand: SimpleIdentifier |
| token: x @36 |
| staticElement: <testLibraryFragment>::@class::C::@constructor::new::@parameter::x |
| staticType: int |
| operator: >= @38 |
| rightOperand: IntegerLiteral |
| literal: 42 @41 |
| staticType: int |
| staticElement: dart:core::<fragment>::@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 buildLibrary(''' |
| class C { |
| final x; |
| const C() : x = 42; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| fields |
| final x @18 |
| reference: <testLibraryFragment>::@class::C::@field::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| type: dynamic |
| constructors |
| const @29 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| constantInitializers |
| ConstructorFieldInitializer |
| fieldName: SimpleIdentifier |
| token: x @35 |
| staticElement: <testLibraryFragment>::@class::C::@field::x |
| staticType: null |
| equals: = @37 |
| expression: IntegerLiteral |
| literal: 42 @39 |
| staticType: int |
| accessors |
| synthetic get x @-1 |
| reference: <testLibraryFragment>::@class::C::@getter::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| returnType: dynamic |
| '''); |
| } |
| |
| test_class_constructor_initializers_field_notConst() async { |
| var library = await buildLibrary(''' |
| class C { |
| final x; |
| const C() : x = foo(); |
| } |
| int foo() => 42; |
| '''); |
| // It is OK to keep non-constant initializers. |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| fields |
| final x @18 |
| reference: <testLibraryFragment>::@class::C::@field::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| type: dynamic |
| constructors |
| const @29 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| constantInitializers |
| ConstructorFieldInitializer |
| fieldName: SimpleIdentifier |
| token: x @35 |
| staticElement: <testLibraryFragment>::@class::C::@field::x |
| staticType: null |
| equals: = @37 |
| expression: MethodInvocation |
| methodName: SimpleIdentifier |
| token: foo @39 |
| staticElement: <testLibraryFragment>::@function::foo |
| staticType: int Function() |
| argumentList: ArgumentList |
| leftParenthesis: ( @42 |
| rightParenthesis: ) @43 |
| staticInvokeType: int Function() |
| staticType: int |
| accessors |
| synthetic get x @-1 |
| reference: <testLibraryFragment>::@class::C::@getter::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| returnType: dynamic |
| functions |
| foo @52 |
| reference: <testLibraryFragment>::@function::foo |
| enclosingElement: <testLibraryFragment> |
| returnType: int |
| '''); |
| } |
| |
| test_class_constructor_initializers_field_optionalPositionalParameter() async { |
| var library = await buildLibrary(''' |
| class A { |
| final int _f; |
| const A([int f = 0]) : _f = f; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class A @6 |
| reference: <testLibraryFragment>::@class::A |
| enclosingElement: <testLibraryFragment> |
| fields |
| final promotable _f @22 |
| reference: <testLibraryFragment>::@class::A::@field::_f |
| enclosingElement: <testLibraryFragment>::@class::A |
| type: int |
| constructors |
| const @34 |
| reference: <testLibraryFragment>::@class::A::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::A |
| parameters |
| optionalPositional default f @41 |
| type: int |
| constantInitializer |
| IntegerLiteral |
| literal: 0 @45 |
| staticType: int |
| constantInitializers |
| ConstructorFieldInitializer |
| fieldName: SimpleIdentifier |
| token: _f @51 |
| staticElement: <testLibraryFragment>::@class::A::@field::_f |
| staticType: null |
| equals: = @54 |
| expression: SimpleIdentifier |
| token: f @56 |
| staticElement: <testLibraryFragment>::@class::A::@constructor::new::@parameter::f |
| staticType: int |
| accessors |
| synthetic get _f @-1 |
| reference: <testLibraryFragment>::@class::A::@getter::_f |
| enclosingElement: <testLibraryFragment>::@class::A |
| returnType: int |
| '''); |
| } |
| |
| test_class_constructor_initializers_field_recordLiteral() async { |
| var library = await buildLibrary(''' |
| class C { |
| final Object x; |
| const C(int a) : x = (0, a); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| fields |
| final x @25 |
| reference: <testLibraryFragment>::@class::C::@field::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| type: Object |
| constructors |
| const @36 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| parameters |
| requiredPositional a @42 |
| type: int |
| constantInitializers |
| ConstructorFieldInitializer |
| fieldName: SimpleIdentifier |
| token: x @47 |
| staticElement: <testLibraryFragment>::@class::C::@field::x |
| staticType: null |
| equals: = @49 |
| expression: RecordLiteral |
| leftParenthesis: ( @51 |
| fields |
| IntegerLiteral |
| literal: 0 @52 |
| staticType: int |
| SimpleIdentifier |
| token: a @55 |
| staticElement: <testLibraryFragment>::@class::C::@constructor::new::@parameter::a |
| staticType: int |
| rightParenthesis: ) @56 |
| staticType: (int, int) |
| accessors |
| synthetic get x @-1 |
| reference: <testLibraryFragment>::@class::C::@getter::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| returnType: Object |
| '''); |
| } |
| |
| test_class_constructor_initializers_field_withParameter() async { |
| var library = await buildLibrary(''' |
| class C { |
| final x; |
| const C(int p) : x = 1 + p; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| fields |
| final x @18 |
| reference: <testLibraryFragment>::@class::C::@field::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| type: dynamic |
| constructors |
| const @29 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| parameters |
| requiredPositional p @35 |
| type: int |
| constantInitializers |
| ConstructorFieldInitializer |
| fieldName: SimpleIdentifier |
| token: x @40 |
| staticElement: <testLibraryFragment>::@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: <testLibraryFragment>::@class::C::@constructor::new::@parameter::p |
| staticType: int |
| staticElement: dart:core::<fragment>::@class::num::@method::+ |
| staticInvokeType: num Function(num) |
| staticType: int |
| accessors |
| synthetic get x @-1 |
| reference: <testLibraryFragment>::@class::C::@getter::x |
| enclosingElement: <testLibraryFragment>::@class::C |
| returnType: dynamic |
| '''); |
| } |
| |
| test_class_constructor_initializers_genericFunctionType() async { |
| var library = await buildLibrary(''' |
| class A<T> { |
| const A(); |
| } |
| class B { |
| const B(dynamic x); |
| const B.f() |
| : this(A<Function()>()); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class A @6 |
| reference: <testLibraryFragment>::@class::A |
| enclosingElement: <testLibraryFragment> |
| typeParameters |
| covariant T @8 |
| defaultType: dynamic |
| constructors |
| const @21 |
| reference: <testLibraryFragment>::@class::A::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::A |
| class B @34 |
| reference: <testLibraryFragment>::@class::B |
| enclosingElement: <testLibraryFragment> |
| constructors |
| const @46 |
| reference: <testLibraryFragment>::@class::B::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::B |
| parameters |
| requiredPositional x @56 |
| type: dynamic |
| const f @70 |
| reference: <testLibraryFragment>::@class::B::@constructor::f |
| enclosingElement: <testLibraryFragment>::@class::B |
| periodOffset: 69 |
| nameEnd: 71 |
| constantInitializers |
| RedirectingConstructorInvocation |
| thisKeyword: this @79 |
| argumentList: ArgumentList |
| leftParenthesis: ( @83 |
| arguments |
| InstanceCreationExpression |
| constructorName: ConstructorName |
| type: NamedType |
| name: A @84 |
| 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 |
| element: <testLibraryFragment>::@class::A |
| type: A<dynamic Function()> |
| staticElement: ConstructorMember |
| base: <testLibraryFragment>::@class::A::@constructor::new |
| substitution: {T: dynamic Function()} |
| argumentList: ArgumentList |
| leftParenthesis: ( @97 |
| rightParenthesis: ) @98 |
| staticType: A<dynamic Function()> |
| rightParenthesis: ) @99 |
| staticElement: <testLibraryFragment>::@class::B::@constructor::new |
| redirectedConstructor: <testLibraryFragment>::@class::B::@constructor::new |
| '''); |
| } |
| |
| test_class_constructor_initializers_superInvocation_argumentContextType() async { |
| var library = await buildLibrary(''' |
| class A { |
| const A(List<String> values); |
| } |
| class B extends A { |
| const B() : super(const []); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class A @6 |
| reference: <testLibraryFragment>::@class::A |
| enclosingElement: <testLibraryFragment> |
| constructors |
| const @18 |
| reference: <testLibraryFragment>::@class::A::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::A |
| parameters |
| requiredPositional values @33 |
| type: List<String> |
| class B @50 |
| reference: <testLibraryFragment>::@class::B |
| enclosingElement: <testLibraryFragment> |
| supertype: A |
| constructors |
| const @72 |
| reference: <testLibraryFragment>::@class::B::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::B |
| constantInitializers |
| SuperConstructorInvocation |
| superKeyword: super @78 |
| argumentList: ArgumentList |
| leftParenthesis: ( @83 |
| arguments |
| ListLiteral |
| constKeyword: const @84 |
| leftBracket: [ @90 |
| rightBracket: ] @91 |
| staticType: List<String> |
| rightParenthesis: ) @92 |
| staticElement: <testLibraryFragment>::@class::A::@constructor::new |
| superConstructor: <testLibraryFragment>::@class::A::@constructor::new |
| '''); |
| } |
| |
| test_class_constructor_initializers_superInvocation_named() async { |
| var library = await buildLibrary(''' |
| class A { |
| const A.aaa(int p); |
| } |
| class C extends A { |
| const C() : super.aaa(42); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class A @6 |
| reference: <testLibraryFragment>::@class::A |
| enclosingElement: <testLibraryFragment> |
| constructors |
| const aaa @20 |
| reference: <testLibraryFragment>::@class::A::@constructor::aaa |
| enclosingElement: <testLibraryFragment>::@class::A |
| periodOffset: 19 |
| nameEnd: 23 |
| parameters |
| requiredPositional p @28 |
| type: int |
| class C @40 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| supertype: A |
| constructors |
| const @62 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| constantInitializers |
| SuperConstructorInvocation |
| superKeyword: super @68 |
| period: . @73 |
| constructorName: SimpleIdentifier |
| token: aaa @74 |
| staticElement: <testLibraryFragment>::@class::A::@constructor::aaa |
| staticType: null |
| argumentList: ArgumentList |
| leftParenthesis: ( @77 |
| arguments |
| IntegerLiteral |
| literal: 42 @78 |
| staticType: int |
| rightParenthesis: ) @80 |
| staticElement: <testLibraryFragment>::@class::A::@constructor::aaa |
| superConstructor: <testLibraryFragment>::@class::A::@constructor::aaa |
| '''); |
| } |
| |
| test_class_constructor_initializers_superInvocation_named_underscore() async { |
| var library = await buildLibrary(''' |
| class A { |
| const A._(); |
| } |
| class B extends A { |
| const B() : super._(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class A @6 |
| reference: <testLibraryFragment>::@class::A |
| enclosingElement: <testLibraryFragment> |
| constructors |
| const _ @20 |
| reference: <testLibraryFragment>::@class::A::@constructor::_ |
| enclosingElement: <testLibraryFragment>::@class::A |
| periodOffset: 19 |
| nameEnd: 21 |
| class B @33 |
| reference: <testLibraryFragment>::@class::B |
| enclosingElement: <testLibraryFragment> |
| supertype: A |
| constructors |
| const @55 |
| reference: <testLibraryFragment>::@class::B::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::B |
| constantInitializers |
| SuperConstructorInvocation |
| superKeyword: super @61 |
| period: . @66 |
| constructorName: SimpleIdentifier |
| token: _ @67 |
| staticElement: <testLibraryFragment>::@class::A::@constructor::_ |
| staticType: null |
| argumentList: ArgumentList |
| leftParenthesis: ( @68 |
| rightParenthesis: ) @69 |
| staticElement: <testLibraryFragment>::@class::A::@constructor::_ |
| superConstructor: <testLibraryFragment>::@class::A::@constructor::_ |
| '''); |
| } |
| |
| test_class_constructor_initializers_superInvocation_namedExpression() async { |
| var library = await buildLibrary(''' |
| class A { |
| const A.aaa(a, {int b}); |
| } |
| class C extends A { |
| const C() : super.aaa(1, b: 2); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class A @6 |
| reference: <testLibraryFragment>::@class::A |
| enclosingElement: <testLibraryFragment> |
| constructors |
| const aaa @20 |
| reference: <testLibraryFragment>::@class::A::@constructor::aaa |
| enclosingElement: <testLibraryFragment>::@class::A |
| periodOffset: 19 |
| nameEnd: 23 |
| parameters |
| requiredPositional a @24 |
| type: dynamic |
| optionalNamed default b @32 |
| reference: <testLibraryFragment>::@class::A::@constructor::aaa::@parameter::b |
| type: int |
| class C @45 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| supertype: A |
| constructors |
| const @67 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| constantInitializers |
| SuperConstructorInvocation |
| superKeyword: super @73 |
| period: . @78 |
| constructorName: SimpleIdentifier |
| token: aaa @79 |
| staticElement: <testLibraryFragment>::@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: <testLibraryFragment>::@class::A::@constructor::aaa::@parameter::b |
| staticType: null |
| colon: : @87 |
| expression: IntegerLiteral |
| literal: 2 @89 |
| staticType: int |
| rightParenthesis: ) @90 |
| staticElement: <testLibraryFragment>::@class::A::@constructor::aaa |
| superConstructor: <testLibraryFragment>::@class::A::@constructor::aaa |
| '''); |
| } |
| |
| test_class_constructor_initializers_superInvocation_unnamed() async { |
| var library = await buildLibrary(''' |
| class A { |
| const A(int p); |
| } |
| class C extends A { |
| const C.ccc() : super(42); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class A @6 |
| reference: <testLibraryFragment>::@class::A |
| enclosingElement: <testLibraryFragment> |
| constructors |
| const @18 |
| reference: <testLibraryFragment>::@class::A::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::A |
| parameters |
| requiredPositional p @24 |
| type: int |
| class C @36 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| supertype: A |
| constructors |
| const ccc @60 |
| reference: <testLibraryFragment>::@class::C::@constructor::ccc |
| enclosingElement: <testLibraryFragment>::@class::C |
| periodOffset: 59 |
| nameEnd: 63 |
| constantInitializers |
| SuperConstructorInvocation |
| superKeyword: super @68 |
| argumentList: ArgumentList |
| leftParenthesis: ( @73 |
| arguments |
| IntegerLiteral |
| literal: 42 @74 |
| staticType: int |
| rightParenthesis: ) @76 |
| staticElement: <testLibraryFragment>::@class::A::@constructor::new |
| superConstructor: <testLibraryFragment>::@class::A::@constructor::new |
| '''); |
| } |
| |
| test_class_constructor_initializers_thisInvocation_argumentContextType() async { |
| var library = await buildLibrary(''' |
| class A { |
| const A(List<String> values); |
| const A.empty() : this(const []); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class A @6 |
| reference: <testLibraryFragment>::@class::A |
| enclosingElement: <testLibraryFragment> |
| constructors |
| const @18 |
| reference: <testLibraryFragment>::@class::A::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::A |
| parameters |
| requiredPositional values @33 |
| type: List<String> |
| const empty @52 |
| reference: <testLibraryFragment>::@class::A::@constructor::empty |
| enclosingElement: <testLibraryFragment>::@class::A |
| 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: <testLibraryFragment>::@class::A::@constructor::new |
| redirectedConstructor: <testLibraryFragment>::@class::A::@constructor::new |
| '''); |
| } |
| |
| test_class_constructor_initializers_thisInvocation_named() async { |
| var library = await buildLibrary(''' |
| class C { |
| const C() : this.named(1, 'bbb'); |
| const C.named(int a, String b); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| constructors |
| const @18 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| constantInitializers |
| RedirectingConstructorInvocation |
| thisKeyword: this @24 |
| period: . @28 |
| constructorName: SimpleIdentifier |
| token: named @29 |
| staticElement: <testLibraryFragment>::@class::C::@constructor::named |
| staticType: null |
| argumentList: ArgumentList |
| leftParenthesis: ( @34 |
| arguments |
| IntegerLiteral |
| literal: 1 @35 |
| staticType: int |
| SimpleStringLiteral |
| literal: 'bbb' @38 |
| rightParenthesis: ) @43 |
| staticElement: <testLibraryFragment>::@class::C::@constructor::named |
| redirectedConstructor: <testLibraryFragment>::@class::C::@constructor::named |
| const named @56 |
| reference: <testLibraryFragment>::@class::C::@constructor::named |
| enclosingElement: <testLibraryFragment>::@class::C |
| 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 buildLibrary(''' |
| class C { |
| const C() : this.named(1, b: 2); |
| const C.named(a, {int b}); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| constructors |
| const @18 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| constantInitializers |
| RedirectingConstructorInvocation |
| thisKeyword: this @24 |
| period: . @28 |
| constructorName: SimpleIdentifier |
| token: named @29 |
| staticElement: <testLibraryFragment>::@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: <testLibraryFragment>::@class::C::@constructor::named::@parameter::b |
| staticType: null |
| colon: : @39 |
| expression: IntegerLiteral |
| literal: 2 @41 |
| staticType: int |
| rightParenthesis: ) @42 |
| staticElement: <testLibraryFragment>::@class::C::@constructor::named |
| redirectedConstructor: <testLibraryFragment>::@class::C::@constructor::named |
| const named @55 |
| reference: <testLibraryFragment>::@class::C::@constructor::named |
| enclosingElement: <testLibraryFragment>::@class::C |
| periodOffset: 54 |
| nameEnd: 60 |
| parameters |
| requiredPositional a @61 |
| type: dynamic |
| optionalNamed default b @69 |
| reference: <testLibraryFragment>::@class::C::@constructor::named::@parameter::b |
| type: int |
| '''); |
| } |
| |
| test_class_constructor_initializers_thisInvocation_unnamed() async { |
| var library = await buildLibrary(''' |
| class C { |
| const C.named() : this(1, 'bbb'); |
| const C(int a, String b); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| constructors |
| const named @20 |
| reference: <testLibraryFragment>::@class::C::@constructor::named |
| enclosingElement: <testLibraryFragment>::@class::C |
| 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: <testLibraryFragment>::@class::C::@constructor::new |
| redirectedConstructor: <testLibraryFragment>::@class::C::@constructor::new |
| const @54 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| parameters |
| requiredPositional a @60 |
| type: int |
| requiredPositional b @70 |
| type: String |
| '''); |
| } |
| |
| test_class_constructor_parameters_super_explicitType_function() async { |
| var library = await buildLibrary(''' |
| class A { |
| A(Object? a); |
| } |
| |
| class B extends A { |
| B(int super.a<T extends num>(T d)?); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class A @6 |
| reference: <testLibraryFragment>::@class::A |
| enclosingElement: <testLibraryFragment> |
| constructors |
| @12 |
| reference: <testLibraryFragment>::@class::A::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::A |
| parameters |
| requiredPositional a @22 |
| type: Object? |
| class B @35 |
| reference: <testLibraryFragment>::@class::B |
| enclosingElement: <testLibraryFragment> |
| supertype: A |
| constructors |
| @51 |
| reference: <testLibraryFragment>::@class::B::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::B |
| 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: <testLibraryFragment>::@class::A::@constructor::new::@parameter::a |
| superConstructor: <testLibraryFragment>::@class::A::@constructor::new |
| '''); |
| } |
| |
| test_class_constructor_parameters_super_explicitType_interface() async { |
| var library = await buildLibrary(''' |
| class A { |
| A(num a); |
| } |
| |
| class B extends A { |
| B(int super.a); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class A @6 |
| reference: <testLibraryFragment>::@class::A |
| enclosingElement: <testLibraryFragment> |
| constructors |
| @12 |
| reference: <testLibraryFragment>::@class::A::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::A |
| parameters |
| requiredPositional a @18 |
| type: num |
| class B @31 |
| reference: <testLibraryFragment>::@class::B |
| enclosingElement: <testLibraryFragment> |
| supertype: A |
| constructors |
| @47 |
| reference: <testLibraryFragment>::@class::B::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::B |
| parameters |
| requiredPositional final super.a @59 |
| type: int |
| superConstructorParameter: <testLibraryFragment>::@class::A::@constructor::new::@parameter::a |
| superConstructor: <testLibraryFragment>::@class::A::@constructor::new |
| '''); |
| } |
| |
| test_class_constructor_parameters_super_explicitType_interface_nullable() async { |
| var library = await buildLibrary(''' |
| class A { |
| A(num? a); |
| } |
| |
| class B extends A { |
| B(int? super.a); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class A @6 |
| reference: <testLibraryFragment>::@class::A |
| enclosingElement: <testLibraryFragment> |
| constructors |
| @12 |
| reference: <testLibraryFragment>::@class::A::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::A |
| parameters |
| requiredPositional a @19 |
| type: num? |
| class B @32 |
| reference: <testLibraryFragment>::@class::B |
| enclosingElement: <testLibraryFragment> |
| supertype: A |
| constructors |
| @48 |
| reference: <testLibraryFragment>::@class::B::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::B |
| parameters |
| requiredPositional final super.a @61 |
| type: int? |
| superConstructorParameter: <testLibraryFragment>::@class::A::@constructor::new::@parameter::a |
| superConstructor: <testLibraryFragment>::@class::A::@constructor::new |
| '''); |
| } |
| |
| test_class_constructor_parameters_super_invalid_topFunction() async { |
| var library = await buildLibrary(''' |
| void f(super.a) {} |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| functions |
| f @5 |
| reference: <testLibraryFragment>::@function::f |
| enclosingElement: <testLibraryFragment> |
| parameters |
| requiredPositional final super.a @13 |
| type: dynamic |
| superConstructorParameter: <null> |
| returnType: void |
| '''); |
| } |
| |
| test_class_constructor_parameters_super_optionalNamed() async { |
| var library = await buildLibrary(''' |
| 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 |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class A @6 |
| reference: <testLibraryFragment>::@class::A |
| enclosingElement: <testLibraryFragment> |
| constructors |
| @12 |
| reference: <testLibraryFragment>::@class::A::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::A |
| parameters |
| requiredNamed default a @28 |
| reference: <testLibraryFragment>::@class::A::@constructor::new::@parameter::a |
| type: int |
| requiredNamed default b @47 |
| reference: <testLibraryFragment>::@class::A::@constructor::new::@parameter::b |
| type: double |
| class B @61 |
| reference: <testLibraryFragment>::@class::B |
| enclosingElement: <testLibraryFragment> |
| supertype: A |
| constructors |
| @77 |
| reference: <testLibraryFragment>::@class::B::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::B |
| parameters |
| optionalNamed default o1 @87 |
| reference: <testLibraryFragment>::@class::B::@constructor::new::@parameter::o1 |
| type: String |
| optionalNamed default final super.a @97 |
| reference: <testLibraryFragment>::@class::B::@constructor::new::@parameter::a |
| type: int |
| superConstructorParameter: <testLibraryFragment>::@class::A::@constructor::new::@parameter::a |
| optionalNamed default o2 @107 |
| reference: <testLibraryFragment>::@class::B::@constructor::new::@parameter::o2 |
| type: String |
| optionalNamed default final super.b @117 |
| reference: <testLibraryFragment>::@class::B::@constructor::new::@parameter::b |
| type: double |
| superConstructorParameter: <testLibraryFragment>::@class::A::@constructor::new::@parameter::b |
| superConstructor: <testLibraryFragment>::@class::A::@constructor::new |
| '''); |
| } |
| |
| test_class_constructor_parameters_super_optionalNamed_defaultValue() async { |
| var library = await buildLibrary(''' |
| class A { |
| A({int a = 0}); |
| } |
| |
| class B extends A { |
| B({super.a}); |
| } |
| '''); |
| |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class A @6 |
| reference: <testLibraryFragment>::@class::A |
| enclosingElement: <testLibraryFragment> |
| constructors |
| @12 |
| reference: <testLibraryFragment>::@class::A::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::A |
| parameters |
| optionalNamed default a @19 |
| reference: <testLibraryFragment>::@class::A::@constructor::new::@parameter::a |
| type: int |
| constantInitializer |
| IntegerLiteral |
| literal: 0 @23 |
| staticType: int |
| class B @37 |
| reference: <testLibraryFragment>::@class::B |
| enclosingElement: <testLibraryFragment> |
| supertype: A |
| constructors |
| @53 |
| reference: <testLibraryFragment>::@class::B::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::B |
| parameters |
| optionalNamed default final hasDefaultValue super.a @62 |
| reference: <testLibraryFragment>::@class::B::@constructor::new::@parameter::a |
| type: int |
| superConstructorParameter: <testLibraryFragment>::@class::A::@constructor::new::@parameter::a |
| superConstructor: <testLibraryFragment>::@class::A::@constructor::new |
| '''); |
| } |
| |
| test_class_constructor_parameters_super_optionalNamed_unresolved() async { |
| var library = await buildLibrary(''' |
| class A { |
| A({required int a}); |
| } |
| |
| class B extends A { |
| B({super.b}); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class A @6 |
| reference: <testLibraryFragment>::@class::A |
| enclosingElement: <testLibraryFragment> |
| constructors |
| @12 |
| reference: <testLibraryFragment>::@class::A::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::A |
| parameters |
| requiredNamed default a @28 |
| reference: <testLibraryFragment>::@class::A::@constructor::new::@parameter::a |
| type: int |
| class B @42 |
| reference: <testLibraryFragment>::@class::B |
| enclosingElement: <testLibraryFragment> |
| supertype: A |
| constructors |
| @58 |
| reference: <testLibraryFragment>::@class::B::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::B |
| parameters |
| optionalNamed default final super.b @67 |
| reference: <testLibraryFragment>::@class::B::@constructor::new::@parameter::b |
| type: dynamic |
| superConstructorParameter: <null> |
| superConstructor: <testLibraryFragment>::@class::A::@constructor::new |
| '''); |
| } |
| |
| test_class_constructor_parameters_super_optionalNamed_unresolved2() async { |
| var library = await buildLibrary(''' |
| class A { |
| A(int a); |
| } |
| |
| class B extends A { |
| B({super.a}); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class A @6 |
| reference: <testLibraryFragment>::@class::A |
| enclosingElement: <testLibraryFragment> |
| constructors |
| @12 |
| reference: <testLibraryFragment>::@class::A::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::A |
| parameters |
| requiredPositional a @18 |
| type: int |
| class B @31 |
| reference: <testLibraryFragment>::@class::B |
| enclosingElement: <testLibraryFragment> |
| supertype: A |
| constructors |
| @47 |
| reference: <testLibraryFragment>::@class::B::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::B |
| parameters |
| optionalNamed default final super.a @56 |
| reference: <testLibraryFragment>::@class::B::@constructor::new::@parameter::a |
| type: dynamic |
| superConstructorParameter: <null> |
| superConstructor: <testLibraryFragment>::@class::A::@constructor::new |
| '''); |
| } |
| |
| test_class_constructor_parameters_super_optionalPositional() async { |
| var library = await buildLibrary(''' |
| 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 |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class A @6 |
| reference: <testLibraryFragment>::@class::A |
| enclosingElement: <testLibraryFragment> |
| constructors |
| @12 |
| reference: <testLibraryFragment>::@class::A::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::A |
| parameters |
| requiredPositional a @18 |
| type: int |
| requiredPositional b @28 |
| type: double |
| class B @41 |
| reference: <testLibraryFragment>::@class::B |
| enclosingElement: <testLibraryFragment> |
| supertype: A |
| constructors |
| @57 |
| reference: <testLibraryFragment>::@class::B::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::B |
| parameters |
| optionalPositional default o1 @67 |
| type: String |
| optionalPositional default final super.a @77 |
| type: int |
| superConstructorParameter: <testLibraryFragment>::@class::A::@constructor::new::@parameter::a |
| optionalPositional default o2 @87 |
| type: String |
| optionalPositional default final super.b @97 |
| type: double |
| superConstructorParameter: <testLibraryFragment>::@class::A::@constructor::new::@parameter::b |
| superConstructor: <testLibraryFragment>::@class::A::@constructor::new |
| '''); |
| } |
| |
| test_class_constructor_parameters_super_requiredNamed() async { |
| var library = await buildLibrary(''' |
| 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 |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class A @6 |
| reference: <testLibraryFragment>::@class::A |
| enclosingElement: <testLibraryFragment> |
| constructors |
| @12 |
| reference: <testLibraryFragment>::@class::A::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::A |
| parameters |
| requiredNamed default a @28 |
| reference: <testLibraryFragment>::@class::A::@constructor::new::@parameter::a |
| type: int |
| requiredNamed default b @47 |
| reference: <testLibraryFragment>::@class::A::@constructor::new::@parameter::b |
| type: double |
| class B @61 |
| reference: <testLibraryFragment>::@class::B |
| enclosingElement: <testLibraryFragment> |
| supertype: A |
| constructors |
| @77 |
| reference: <testLibraryFragment>::@class::B::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::B |
| parameters |
| requiredNamed default o1 @101 |
| reference: <testLibraryFragment>::@class::B::@constructor::new::@parameter::o1 |
| type: String |
| requiredNamed default final super.a @124 |
| reference: <testLibraryFragment>::@class::B::@constructor::new::@parameter::a |
| type: int |
| superConstructorParameter: <testLibraryFragment>::@class::A::@constructor::new::@parameter::a |
| requiredNamed default o2 @147 |
| reference: <testLibraryFragment>::@class::B::@constructor::new::@parameter::o2 |
| type: String |
| requiredNamed default final super.b @170 |
| reference: <testLibraryFragment>::@class::B::@constructor::new::@parameter::b |
| type: double |
| superConstructorParameter: <testLibraryFragment>::@class::A::@constructor::new::@parameter::b |
| superConstructor: <testLibraryFragment>::@class::A::@constructor::new |
| '''); |
| } |
| |
| test_class_constructor_parameters_super_requiredNamed_defaultValue() async { |
| var library = await buildLibrary(''' |
| class A { |
| A({int a = 0}); |
| } |
| |
| class B extends A { |
| B({required super.a}); |
| } |
| '''); |
| |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class A @6 |
| reference: <testLibraryFragment>::@class::A |
| enclosingElement: <testLibraryFragment> |
| constructors |
| @12 |
| reference: <testLibraryFragment>::@class::A::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::A |
| parameters |
| optionalNamed default a @19 |
| reference: <testLibraryFragment>::@class::A::@constructor::new::@parameter::a |
| type: int |
| constantInitializer |
| IntegerLiteral |
| literal: 0 @23 |
| staticType: int |
| class B @37 |
| reference: <testLibraryFragment>::@class::B |
| enclosingElement: <testLibraryFragment> |
| supertype: A |
| constructors |
| @53 |
| reference: <testLibraryFragment>::@class::B::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::B |
| parameters |
| requiredNamed default final super.a @71 |
| reference: <testLibraryFragment>::@class::B::@constructor::new::@parameter::a |
| type: int |
| superConstructorParameter: <testLibraryFragment>::@class::A::@constructor::new::@parameter::a |
| superConstructor: <testLibraryFragment>::@class::A::@constructor::new |
| '''); |
| } |
| |
| test_class_constructor_parameters_super_requiredPositional() async { |
| var library = await buildLibrary(''' |
| 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 |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class A @6 |
| reference: <testLibraryFragment>::@class::A |
| enclosingElement: <testLibraryFragment> |
| constructors |
| @12 |
| reference: <testLibraryFragment>::@class::A::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::A |
| parameters |
| requiredPositional a @18 |
| type: int |
| requiredPositional b @28 |
| type: double |
| class B @41 |
| reference: <testLibraryFragment>::@class::B |
| enclosingElement: <testLibraryFragment> |
| supertype: A |
| constructors |
| @57 |
| reference: <testLibraryFragment>::@class::B::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::B |
| parameters |
| requiredPositional o1 @66 |
| type: String |
| requiredPositional final super.a @76 |
| type: int |
| superConstructorParameter: <testLibraryFragment>::@class::A::@constructor::new::@parameter::a |
| requiredPositional o2 @86 |
| type: String |
| requiredPositional final super.b @96 |
| type: double |
| superConstructorParameter: <testLibraryFragment>::@class::A::@constructor::new::@parameter::b |
| superConstructor: <testLibraryFragment>::@class::A::@constructor::new |
| '''); |
| } |
| |
| test_class_constructor_parameters_super_requiredPositional_inferenceOrder() async { |
| // It is important that `B` is declared after `C`, so that we check that |
| // inference happens in order - first `B`, then `C`. |
| var library = await buildLibrary(''' |
| abstract class A { |
| A(int a); |
| } |
| |
| class C extends B { |
| C(super.a); |
| } |
| |
| class B extends A { |
| B(super.a); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| abstract class A @15 |
| reference: <testLibraryFragment>::@class::A |
| enclosingElement: <testLibraryFragment> |
| constructors |
| @21 |
| reference: <testLibraryFragment>::@class::A::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::A |
| parameters |
| requiredPositional a @27 |
| type: int |
| class C @40 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| supertype: B |
| constructors |
| @56 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| parameters |
| requiredPositional final super.a @64 |
| type: int |
| superConstructorParameter: <testLibraryFragment>::@class::B::@constructor::new::@parameter::a |
| superConstructor: <testLibraryFragment>::@class::B::@constructor::new |
| class B @77 |
| reference: <testLibraryFragment>::@class::B |
| enclosingElement: <testLibraryFragment> |
| supertype: A |
| constructors |
| @93 |
| reference: <testLibraryFragment>::@class::B::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::B |
| parameters |
| requiredPositional final super.a @101 |
| type: int |
| superConstructorParameter: <testLibraryFragment>::@class::A::@constructor::new::@parameter::a |
| superConstructor: <testLibraryFragment>::@class::A::@constructor::new |
| '''); |
| } |
| |
| test_class_constructor_parameters_super_requiredPositional_inferenceOrder_generic() async { |
| // It is important that `C` is declared before `B`, so that we check that |
| // inference happens in order - first `B`, then `C`. |
| var library = await buildLibrary(''' |
| class A { |
| A(int a); |
| } |
| |
| class C extends B<String> { |
| C(super.a); |
| } |
| |
| class B<T> extends A { |
| B(super.a); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class A @6 |
| reference: <testLibraryFragment>::@class::A |
| enclosingElement: <testLibraryFragment> |
| constructors |
| @12 |
| reference: <testLibraryFragment>::@class::A::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::A |
| parameters |
| requiredPositional a @18 |
| type: int |
| class C @31 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| supertype: B<String> |
| constructors |
| @55 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| parameters |
| requiredPositional final super.a @63 |
| type: int |
| superConstructorParameter: SuperFormalParameterMember |
| base: <testLibraryFragment>::@class::B::@constructor::new::@parameter::a |
| substitution: {T: String} |
| superConstructor: ConstructorMember |
| base: <testLibraryFragment>::@class::B::@constructor::new |
| substitution: {T: String} |
| class B @76 |
| reference: <testLibraryFragment>::@class::B |
| enclosingElement: <testLibraryFragment> |
| typeParameters |
| covariant T @78 |
| defaultType: dynamic |
| supertype: A |
| constructors |
| @95 |
| reference: <testLibraryFragment>::@class::B::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::B |
| parameters |
| requiredPositional final super.a @103 |
| type: int |
| superConstructorParameter: <testLibraryFragment>::@class::A::@constructor::new::@parameter::a |
| superConstructor: <testLibraryFragment>::@class::A::@constructor::new |
| '''); |
| } |
| |
| test_class_constructor_parameters_super_requiredPositional_unresolved() async { |
| var library = await buildLibrary(''' |
| class A {} |
| |
| class B extends A { |
| B(super.a); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class A @6 |
| reference: <testLibraryFragment>::@class::A |
| enclosingElement: <testLibraryFragment> |
| constructors |
| synthetic @-1 |
| reference: <testLibraryFragment>::@class::A::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::A |
| class B @18 |
| reference: <testLibraryFragment>::@class::B |
| enclosingElement: <testLibraryFragment> |
| supertype: A |
| constructors |
| @34 |
| reference: <testLibraryFragment>::@class::B::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::B |
| parameters |
| requiredPositional final super.a @42 |
| type: dynamic |
| superConstructorParameter: <null> |
| superConstructor: <testLibraryFragment>::@class::A::@constructor::new |
| '''); |
| } |
| |
| test_class_constructor_parameters_super_requiredPositional_unresolved2() async { |
| var library = await buildLibrary(''' |
| class A { |
| A({required int a}) |
| } |
| |
| class B extends A { |
| B(super.a); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class A @6 |
| reference: <testLibraryFragment>::@class::A |
| enclosingElement: <testLibraryFragment> |
| constructors |
| @12 |
| reference: <testLibraryFragment>::@class::A::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::A |
| parameters |
| requiredNamed default a @28 |
| reference: <testLibraryFragment>::@class::A::@constructor::new::@parameter::a |
| type: int |
| class B @41 |
| reference: <testLibraryFragment>::@class::B |
| enclosingElement: <testLibraryFragment> |
| supertype: A |
| constructors |
| @57 |
| reference: <testLibraryFragment>::@class::B::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::B |
| parameters |
| requiredPositional final super.a @65 |
| type: dynamic |
| superConstructorParameter: <null> |
| superConstructor: <testLibraryFragment>::@class::A::@constructor::new |
| '''); |
| } |
| |
| test_class_constructor_params() async { |
| var library = await buildLibrary('class C { C(x, int y); }'); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| constructors |
| @10 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| parameters |
| requiredPositional x @12 |
| type: dynamic |
| requiredPositional y @19 |
| type: int |
| '''); |
| } |
| |
| test_class_constructor_redirected_factory_named() async { |
| var library = await buildLibrary(''' |
| class C { |
| factory C() = D.named; |
| C._(); |
| } |
| class D extends C { |
| D.named() : super._(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| constructors |
| factory @20 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| redirectedConstructor: <testLibraryFragment>::@class::D::@constructor::named |
| _ @39 |
| reference: <testLibraryFragment>::@class::C::@constructor::_ |
| enclosingElement: <testLibraryFragment>::@class::C |
| periodOffset: 38 |
| nameEnd: 40 |
| class D @52 |
| reference: <testLibraryFragment>::@class::D |
| enclosingElement: <testLibraryFragment> |
| supertype: C |
| constructors |
| named @70 |
| reference: <testLibraryFragment>::@class::D::@constructor::named |
| enclosingElement: <testLibraryFragment>::@class::D |
| periodOffset: 69 |
| nameEnd: 75 |
| superConstructor: <testLibraryFragment>::@class::C::@constructor::_ |
| '''); |
| } |
| |
| test_class_constructor_redirected_factory_named_generic() async { |
| var library = await buildLibrary(''' |
| 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 |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| typeParameters |
| covariant T @8 |
| defaultType: dynamic |
| covariant U @11 |
| defaultType: dynamic |
| constructors |
| factory @26 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| redirectedConstructor: ConstructorMember |
| base: <testLibraryFragment>::@class::D::@constructor::named |
| substitution: {T: U, U: T} |
| _ @51 |
| reference: <testLibraryFragment>::@class::C::@constructor::_ |
| enclosingElement: <testLibraryFragment>::@class::C |
| periodOffset: 50 |
| nameEnd: 52 |
| class D @64 |
| reference: <testLibraryFragment>::@class::D |
| enclosingElement: <testLibraryFragment> |
| typeParameters |
| covariant T @66 |
| defaultType: dynamic |
| covariant U @69 |
| defaultType: dynamic |
| supertype: C<U, T> |
| constructors |
| named @94 |
| reference: <testLibraryFragment>::@class::D::@constructor::named |
| enclosingElement: <testLibraryFragment>::@class::D |
| periodOffset: 93 |
| nameEnd: 99 |
| superConstructor: ConstructorMember |
| base: <testLibraryFragment>::@class::C::@constructor::_ |
| substitution: {T: U, U: T} |
| '''); |
| } |
| |
| test_class_constructor_redirected_factory_named_generic_viaTypeAlias() async { |
| var library = await buildLibrary(''' |
| 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 |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class B @33 |
| reference: <testLibraryFragment>::@class::B |
| enclosingElement: <testLibraryFragment> |
| typeParameters |
| covariant T @35 |
| defaultType: dynamic |
| covariant U @38 |
| defaultType: dynamic |
| constructors |
| factory @53 |
| reference: <testLibraryFragment>::@class::B::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::B |
| redirectedConstructor: ConstructorMember |
| base: <testLibraryFragment>::@class::C::@constructor::named |
| substitution: {T: U, U: T} |
| _ @78 |
| reference: <testLibraryFragment>::@class::B::@constructor::_ |
| enclosingElement: <testLibraryFragment>::@class::B |
| periodOffset: 77 |
| nameEnd: 79 |
| class C @91 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| typeParameters |
| covariant T @93 |
| defaultType: dynamic |
| covariant U @96 |
| defaultType: dynamic |
| supertype: C<U, T> |
| alias: <testLibraryFragment>::@typeAlias::A |
| typeArguments |
| U |
| T |
| constructors |
| named @121 |
| reference: <testLibraryFragment>::@class::C::@constructor::named |
| enclosingElement: <testLibraryFragment>::@class::C |
| periodOffset: 120 |
| nameEnd: 126 |
| typeAliases |
| A @8 |
| reference: <testLibraryFragment>::@typeAlias::A |
| typeParameters |
| covariant T @10 |
| defaultType: dynamic |
| covariant U @13 |
| defaultType: dynamic |
| aliasedType: C<T, U> |
| '''); |
| } |
| |
| test_class_constructor_redirected_factory_named_imported() async { |
| addSource('$testPackageLibPath/foo.dart', ''' |
| import 'test.dart'; |
| class D extends C { |
| D.named() : super._(); |
| } |
| '''); |
| var library = await buildLibrary(''' |
| import 'foo.dart'; |
| class C { |
| factory C() = D.named; |
| C._(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| libraryImports |
| package:test/foo.dart |
| enclosingElement: <testLibrary> |
| enclosingElement3: <testLibraryFragment> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| libraryImports |
| package:test/foo.dart |
| enclosingElement: <testLibrary> |
| enclosingElement3: <testLibraryFragment> |
| classes |
| class C @25 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| constructors |
| factory @39 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| redirectedConstructor: package:test/foo.dart::<fragment>::@class::D::@constructor::named |
| _ @58 |
| reference: <testLibraryFragment>::@class::C::@constructor::_ |
| enclosingElement: <testLibraryFragment>::@class::C |
| periodOffset: 57 |
| nameEnd: 59 |
| '''); |
| } |
| |
| test_class_constructor_redirected_factory_named_imported_generic() async { |
| addSource('$testPackageLibPath/foo.dart', ''' |
| import 'test.dart'; |
| class D<T, U> extends C<U, T> { |
| D.named() : super._(); |
| } |
| '''); |
| var library = await buildLibrary(''' |
| import 'foo.dart'; |
| class C<T, U> { |
| factory C() = D<U, T>.named; |
| C._(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| libraryImports |
| package:test/foo.dart |
| enclosingElement: <testLibrary> |
| enclosingElement3: <testLibraryFragment> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| libraryImports |
| package:test/foo.dart |
| enclosingElement: <testLibrary> |
| enclosingElement3: <testLibraryFragment> |
| classes |
| class C @25 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| typeParameters |
| covariant T @27 |
| defaultType: dynamic |
| covariant U @30 |
| defaultType: dynamic |
| constructors |
| factory @45 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| redirectedConstructor: ConstructorMember |
| base: package:test/foo.dart::<fragment>::@class::D::@constructor::named |
| substitution: {T: U, U: T} |
| _ @70 |
| reference: <testLibraryFragment>::@class::C::@constructor::_ |
| enclosingElement: <testLibraryFragment>::@class::C |
| periodOffset: 69 |
| nameEnd: 71 |
| '''); |
| } |
| |
| test_class_constructor_redirected_factory_named_prefixed() async { |
| addSource('$testPackageLibPath/foo.dart', ''' |
| import 'test.dart'; |
| class D extends C { |
| D.named() : super._(); |
| } |
| '''); |
| var library = await buildLibrary(''' |
| import 'foo.dart' as foo; |
| class C { |
| factory C() = foo.D.named; |
| C._(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| libraryImports |
| package:test/foo.dart as foo @21 |
| enclosingElement: <testLibrary> |
| enclosingElement3: <testLibraryFragment> |
| prefixes |
| foo @21 |
| reference: <testLibraryFragment>::@prefix::foo |
| enclosingElement: <testLibrary> |
| enclosingElement3: <testLibraryFragment> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| libraryImports |
| package:test/foo.dart as foo @21 |
| enclosingElement: <testLibrary> |
| enclosingElement3: <testLibraryFragment> |
| libraryImportPrefixes |
| foo @21 |
| reference: <testLibraryFragment>::@prefix::foo |
| enclosingElement: <testLibrary> |
| enclosingElement3: <testLibraryFragment> |
| classes |
| class C @32 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| constructors |
| factory @46 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| redirectedConstructor: package:test/foo.dart::<fragment>::@class::D::@constructor::named |
| _ @69 |
| reference: <testLibraryFragment>::@class::C::@constructor::_ |
| enclosingElement: <testLibraryFragment>::@class::C |
| periodOffset: 68 |
| nameEnd: 70 |
| '''); |
| } |
| |
| test_class_constructor_redirected_factory_named_prefixed_generic() async { |
| addSource('$testPackageLibPath/foo.dart', ''' |
| import 'test.dart'; |
| class D<T, U> extends C<U, T> { |
| D.named() : super._(); |
| } |
| '''); |
| var library = await buildLibrary(''' |
| import 'foo.dart' as foo; |
| class C<T, U> { |
| factory C() = foo.D<U, T>.named; |
| C._(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| libraryImports |
| package:test/foo.dart as foo @21 |
| enclosingElement: <testLibrary> |
| enclosingElement3: <testLibraryFragment> |
| prefixes |
| foo @21 |
| reference: <testLibraryFragment>::@prefix::foo |
| enclosingElement: <testLibrary> |
| enclosingElement3: <testLibraryFragment> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| libraryImports |
| package:test/foo.dart as foo @21 |
| enclosingElement: <testLibrary> |
| enclosingElement3: <testLibraryFragment> |
| libraryImportPrefixes |
| foo @21 |
| reference: <testLibraryFragment>::@prefix::foo |
| enclosingElement: <testLibrary> |
| enclosingElement3: <testLibraryFragment> |
| classes |
| class C @32 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| typeParameters |
| covariant T @34 |
| defaultType: dynamic |
| covariant U @37 |
| defaultType: dynamic |
| constructors |
| factory @52 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| redirectedConstructor: ConstructorMember |
| base: package:test/foo.dart::<fragment>::@class::D::@constructor::named |
| substitution: {T: U, U: T} |
| _ @81 |
| reference: <testLibraryFragment>::@class::C::@constructor::_ |
| enclosingElement: <testLibraryFragment>::@class::C |
| periodOffset: 80 |
| nameEnd: 82 |
| '''); |
| } |
| |
| test_class_constructor_redirected_factory_named_unresolved_class() async { |
| var library = await buildLibrary(''' |
| class C<E> { |
| factory C() = D.named<E>; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| typeParameters |
| covariant E @8 |
| defaultType: dynamic |
| constructors |
| factory @23 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| '''); |
| } |
| |
| test_class_constructor_redirected_factory_named_unresolved_constructor() async { |
| var library = await buildLibrary(''' |
| class D {} |
| class C<E> { |
| factory C() = D.named<E>; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class D @6 |
| reference: <testLibraryFragment>::@class::D |
| enclosingElement: <testLibraryFragment> |
| constructors |
| synthetic @-1 |
| reference: <testLibraryFragment>::@class::D::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::D |
| class C @17 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| typeParameters |
| covariant E @19 |
| defaultType: dynamic |
| constructors |
| factory @34 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| '''); |
| } |
| |
| test_class_constructor_redirected_factory_unnamed() async { |
| var library = await buildLibrary(''' |
| class C { |
| factory C() = D; |
| C._(); |
| } |
| class D extends C { |
| D() : super._(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| constructors |
| factory @20 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| redirectedConstructor: <testLibraryFragment>::@class::D::@constructor::new |
| _ @33 |
| reference: <testLibraryFragment>::@class::C::@constructor::_ |
| enclosingElement: <testLibraryFragment>::@class::C |
| periodOffset: 32 |
| nameEnd: 34 |
| class D @46 |
| reference: <testLibraryFragment>::@class::D |
| enclosingElement: <testLibraryFragment> |
| supertype: C |
| constructors |
| @62 |
| reference: <testLibraryFragment>::@class::D::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::D |
| superConstructor: <testLibraryFragment>::@class::C::@constructor::_ |
| '''); |
| } |
| |
| test_class_constructor_redirected_factory_unnamed_generic() async { |
| var library = await buildLibrary(''' |
| class C<T, U> { |
| factory C() = D<U, T>; |
| C._(); |
| } |
| class D<T, U> extends C<U, T> { |
| D() : super._(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| typeParameters |
| covariant T @8 |
| defaultType: dynamic |
| covariant U @11 |
| defaultType: dynamic |
| constructors |
| factory @26 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| redirectedConstructor: ConstructorMember |
| base: <testLibraryFragment>::@class::D::@constructor::new |
| substitution: {T: U, U: T} |
| _ @45 |
| reference: <testLibraryFragment>::@class::C::@constructor::_ |
| enclosingElement: <testLibraryFragment>::@class::C |
| periodOffset: 44 |
| nameEnd: 46 |
| class D @58 |
| reference: <testLibraryFragment>::@class::D |
| enclosingElement: <testLibraryFragment> |
| typeParameters |
| covariant T @60 |
| defaultType: dynamic |
| covariant U @63 |
| defaultType: dynamic |
| supertype: C<U, T> |
| constructors |
| @86 |
| reference: <testLibraryFragment>::@class::D::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::D |
| superConstructor: ConstructorMember |
| base: <testLibraryFragment>::@class::C::@constructor::_ |
| substitution: {T: U, U: T} |
| '''); |
| } |
| |
| test_class_constructor_redirected_factory_unnamed_generic_viaTypeAlias() async { |
| var library = await buildLibrary(''' |
| 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 |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class B @33 |
| reference: <testLibraryFragment>::@class::B |
| enclosingElement: <testLibraryFragment> |
| typeParameters |
| covariant T @35 |
| defaultType: dynamic |
| covariant U @38 |
| defaultType: dynamic |
| constructors |
| factory @53 |
| reference: <testLibraryFragment>::@class::B::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::B |
| redirectedConstructor: ConstructorMember |
| base: <testLibraryFragment>::@class::C::@constructor::new |
| substitution: {T: U, U: T} |
| methods |
| abstract B_ @70 |
| reference: <testLibraryFragment>::@class::B::@method::B_ |
| enclosingElement: <testLibraryFragment>::@class::B |
| returnType: dynamic |
| class C @84 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| typeParameters |
| covariant T @86 |
| defaultType: dynamic |
| covariant U @89 |
| defaultType: dynamic |
| supertype: B<U, T> |
| constructors |
| @112 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| typeAliases |
| A @8 |
| reference: <testLibraryFragment>::@typeAlias::A |
| typeParameters |
| covariant T @10 |
| defaultType: dynamic |
| covariant U @13 |
| defaultType: dynamic |
| aliasedType: C<T, U> |
| '''); |
| } |
| |
| test_class_constructor_redirected_factory_unnamed_imported() async { |
| addSource('$testPackageLibPath/foo.dart', ''' |
| import 'test.dart'; |
| class D extends C { |
| D() : super._(); |
| } |
| '''); |
| var library = await buildLibrary(''' |
| import 'foo.dart'; |
| class C { |
| factory C() = D; |
| C._(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| libraryImports |
| package:test/foo.dart |
| enclosingElement: <testLibrary> |
| enclosingElement3: <testLibraryFragment> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| libraryImports |
| package:test/foo.dart |
| enclosingElement: <testLibrary> |
| enclosingElement3: <testLibraryFragment> |
| classes |
| class C @25 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| constructors |
| factory @39 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| redirectedConstructor: package:test/foo.dart::<fragment>::@class::D::@constructor::new |
| _ @52 |
| reference: <testLibraryFragment>::@class::C::@constructor::_ |
| enclosingElement: <testLibraryFragment>::@class::C |
| periodOffset: 51 |
| nameEnd: 53 |
| '''); |
| } |
| |
| test_class_constructor_redirected_factory_unnamed_imported_generic() async { |
| addSource('$testPackageLibPath/foo.dart', ''' |
| import 'test.dart'; |
| class D<T, U> extends C<U, T> { |
| D() : super._(); |
| } |
| '''); |
| var library = await buildLibrary(''' |
| import 'foo.dart'; |
| class C<T, U> { |
| factory C() = D<U, T>; |
| C._(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| libraryImports |
| package:test/foo.dart |
| enclosingElement: <testLibrary> |
| enclosingElement3: <testLibraryFragment> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| libraryImports |
| package:test/foo.dart |
| enclosingElement: <testLibrary> |
| enclosingElement3: <testLibraryFragment> |
| classes |
| class C @25 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| typeParameters |
| covariant T @27 |
| defaultType: dynamic |
| covariant U @30 |
| defaultType: dynamic |
| constructors |
| factory @45 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| redirectedConstructor: ConstructorMember |
| base: package:test/foo.dart::<fragment>::@class::D::@constructor::new |
| substitution: {T: U, U: T} |
| _ @64 |
| reference: <testLibraryFragment>::@class::C::@constructor::_ |
| enclosingElement: <testLibraryFragment>::@class::C |
| periodOffset: 63 |
| nameEnd: 65 |
| '''); |
| } |
| |
| test_class_constructor_redirected_factory_unnamed_imported_viaTypeAlias() async { |
| addSource('$testPackageLibPath/foo.dart', ''' |
| import 'test.dart'; |
| typedef A = B; |
| class B extends C { |
| B() : super._(); |
| } |
| '''); |
| var library = await buildLibrary(''' |
| import 'foo.dart'; |
| class C { |
| factory C() = A; |
| C._(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| libraryImports |
| package:test/foo.dart |
| enclosingElement: <testLibrary> |
| enclosingElement3: <testLibraryFragment> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| libraryImports |
| package:test/foo.dart |
| enclosingElement: <testLibrary> |
| enclosingElement3: <testLibraryFragment> |
| classes |
| class C @25 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| constructors |
| factory @39 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| redirectedConstructor: package:test/foo.dart::<fragment>::@class::B::@constructor::new |
| _ @52 |
| reference: <testLibraryFragment>::@class::C::@constructor::_ |
| enclosingElement: <testLibraryFragment>::@class::C |
| periodOffset: 51 |
| nameEnd: 53 |
| '''); |
| } |
| |
| test_class_constructor_redirected_factory_unnamed_prefixed() async { |
| addSource('$testPackageLibPath/foo.dart', ''' |
| import 'test.dart'; |
| class D extends C { |
| D() : super._(); |
| } |
| '''); |
| var library = await buildLibrary(''' |
| import 'foo.dart' as foo; |
| class C { |
| factory C() = foo.D; |
| C._(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| libraryImports |
| package:test/foo.dart as foo @21 |
| enclosingElement: <testLibrary> |
| enclosingElement3: <testLibraryFragment> |
| prefixes |
| foo @21 |
| reference: <testLibraryFragment>::@prefix::foo |
| enclosingElement: <testLibrary> |
| enclosingElement3: <testLibraryFragment> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| libraryImports |
| package:test/foo.dart as foo @21 |
| enclosingElement: <testLibrary> |
| enclosingElement3: <testLibraryFragment> |
| libraryImportPrefixes |
| foo @21 |
| reference: <testLibraryFragment>::@prefix::foo |
| enclosingElement: <testLibrary> |
| enclosingElement3: <testLibraryFragment> |
| classes |
| class C @32 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| constructors |
| factory @46 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| redirectedConstructor: package:test/foo.dart::<fragment>::@class::D::@constructor::new |
| _ @63 |
| reference: <testLibraryFragment>::@class::C::@constructor::_ |
| enclosingElement: <testLibraryFragment>::@class::C |
| periodOffset: 62 |
| nameEnd: 64 |
| '''); |
| } |
| |
| test_class_constructor_redirected_factory_unnamed_prefixed_generic() async { |
| addSource('$testPackageLibPath/foo.dart', ''' |
| import 'test.dart'; |
| class D<T, U> extends C<U, T> { |
| D() : super._(); |
| } |
| '''); |
| var library = await buildLibrary(''' |
| import 'foo.dart' as foo; |
| class C<T, U> { |
| factory C() = foo.D<U, T>; |
| C._(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| libraryImports |
| package:test/foo.dart as foo @21 |
| enclosingElement: <testLibrary> |
| enclosingElement3: <testLibraryFragment> |
| prefixes |
| foo @21 |
| reference: <testLibraryFragment>::@prefix::foo |
| enclosingElement: <testLibrary> |
| enclosingElement3: <testLibraryFragment> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| libraryImports |
| package:test/foo.dart as foo @21 |
| enclosingElement: <testLibrary> |
| enclosingElement3: <testLibraryFragment> |
| libraryImportPrefixes |
| foo @21 |
| reference: <testLibraryFragment>::@prefix::foo |
| enclosingElement: <testLibrary> |
| enclosingElement3: <testLibraryFragment> |
| classes |
| class C @32 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| typeParameters |
| covariant T @34 |
| defaultType: dynamic |
| covariant U @37 |
| defaultType: dynamic |
| constructors |
| factory @52 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| redirectedConstructor: ConstructorMember |
| base: package:test/foo.dart::<fragment>::@class::D::@constructor::new |
| substitution: {T: U, U: T} |
| _ @75 |
| reference: <testLibraryFragment>::@class::C::@constructor::_ |
| enclosingElement: <testLibraryFragment>::@class::C |
| periodOffset: 74 |
| nameEnd: 76 |
| '''); |
| } |
| |
| test_class_constructor_redirected_factory_unnamed_prefixed_viaTypeAlias() async { |
| addSource('$testPackageLibPath/foo.dart', ''' |
| import 'test.dart'; |
| typedef A = B; |
| class B extends C { |
| B() : super._(); |
| } |
| '''); |
| var library = await buildLibrary(''' |
| import 'foo.dart' as foo; |
| class C { |
| factory C() = foo.A; |
| C._(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| libraryImports |
| package:test/foo.dart as foo @21 |
| enclosingElement: <testLibrary> |
| enclosingElement3: <testLibraryFragment> |
| prefixes |
| foo @21 |
| reference: <testLibraryFragment>::@prefix::foo |
| enclosingElement: <testLibrary> |
| enclosingElement3: <testLibraryFragment> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| libraryImports |
| package:test/foo.dart as foo @21 |
| enclosingElement: <testLibrary> |
| enclosingElement3: <testLibraryFragment> |
| libraryImportPrefixes |
| foo @21 |
| reference: <testLibraryFragment>::@prefix::foo |
| enclosingElement: <testLibrary> |
| enclosingElement3: <testLibraryFragment> |
| classes |
| class C @32 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| constructors |
| factory @46 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| redirectedConstructor: package:test/foo.dart::<fragment>::@class::B::@constructor::new |
| _ @63 |
| reference: <testLibraryFragment>::@class::C::@constructor::_ |
| enclosingElement: <testLibraryFragment>::@class::C |
| periodOffset: 62 |
| nameEnd: 64 |
| '''); |
| } |
| |
| test_class_constructor_redirected_factory_unnamed_unresolved() async { |
| var library = await buildLibrary(''' |
| class C<E> { |
| factory C() = D<E>; |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| typeParameters |
| covariant E @8 |
| defaultType: dynamic |
| constructors |
| factory @23 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| '''); |
| } |
| |
| test_class_constructor_redirected_factory_unnamed_viaTypeAlias() async { |
| var library = await buildLibrary(''' |
| typedef A = C; |
| class B { |
| factory B() = A; |
| B._(); |
| } |
| class C extends B { |
| C() : super._(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class B @21 |
| reference: <testLibraryFragment>::@class::B |
| enclosingElement: <testLibraryFragment> |
| constructors |
| factory @35 |
| reference: <testLibraryFragment>::@class::B::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::B |
| redirectedConstructor: <testLibraryFragment>::@class::C::@constructor::new |
| _ @48 |
| reference: <testLibraryFragment>::@class::B::@constructor::_ |
| enclosingElement: <testLibraryFragment>::@class::B |
| periodOffset: 47 |
| nameEnd: 49 |
| class C @61 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| supertype: B |
| constructors |
| @77 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| superConstructor: <testLibraryFragment>::@class::B::@constructor::_ |
| typeAliases |
| A @8 |
| reference: <testLibraryFragment>::@typeAlias::A |
| aliasedType: C |
| '''); |
| } |
| |
| test_class_constructor_redirected_thisInvocation_named() async { |
| var library = await buildLibrary(''' |
| class C { |
| const C.named(); |
| const C() : this.named(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| constructors |
| const named @20 |
| reference: <testLibraryFragment>::@class::C::@constructor::named |
| enclosingElement: <testLibraryFragment>::@class::C |
| periodOffset: 19 |
| nameEnd: 25 |
| const @37 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| constantInitializers |
| RedirectingConstructorInvocation |
| thisKeyword: this @43 |
| period: . @47 |
| constructorName: SimpleIdentifier |
| token: named @48 |
| staticElement: <testLibraryFragment>::@class::C::@constructor::named |
| staticType: null |
| argumentList: ArgumentList |
| leftParenthesis: ( @53 |
| rightParenthesis: ) @54 |
| staticElement: <testLibraryFragment>::@class::C::@constructor::named |
| redirectedConstructor: <testLibraryFragment>::@class::C::@constructor::named |
| '''); |
| } |
| |
| test_class_constructor_redirected_thisInvocation_named_generic() async { |
| var library = await buildLibrary(''' |
| class C<T> { |
| const C.named(); |
| const C() : this.named(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| typeParameters |
| covariant T @8 |
| defaultType: dynamic |
| constructors |
| const named @23 |
| reference: <testLibraryFragment>::@class::C::@constructor::named |
| enclosingElement: <testLibraryFragment>::@class::C |
| periodOffset: 22 |
| nameEnd: 28 |
| const @40 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| constantInitializers |
| RedirectingConstructorInvocation |
| thisKeyword: this @46 |
| period: . @50 |
| constructorName: SimpleIdentifier |
| token: named @51 |
| staticElement: <testLibraryFragment>::@class::C::@constructor::named |
| staticType: null |
| argumentList: ArgumentList |
| leftParenthesis: ( @56 |
| rightParenthesis: ) @57 |
| staticElement: <testLibraryFragment>::@class::C::@constructor::named |
| redirectedConstructor: <testLibraryFragment>::@class::C::@constructor::named |
| '''); |
| } |
| |
| test_class_constructor_redirected_thisInvocation_named_notConst() async { |
| var library = await buildLibrary(''' |
| class C { |
| C.named(); |
| C() : this.named(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| constructors |
| named @14 |
| reference: <testLibraryFragment>::@class::C::@constructor::named |
| enclosingElement: <testLibraryFragment>::@class::C |
| periodOffset: 13 |
| nameEnd: 19 |
| @25 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| redirectedConstructor: <testLibraryFragment>::@class::C::@constructor::named |
| '''); |
| } |
| |
| test_class_constructor_redirected_thisInvocation_unnamed() async { |
| var library = await buildLibrary(''' |
| class C { |
| const C(); |
| const C.named() : this(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| constructors |
| const @18 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| const named @33 |
| reference: <testLibraryFragment>::@class::C::@constructor::named |
| enclosingElement: <testLibraryFragment>::@class::C |
| periodOffset: 32 |
| nameEnd: 38 |
| constantInitializers |
| RedirectingConstructorInvocation |
| thisKeyword: this @43 |
| argumentList: ArgumentList |
| leftParenthesis: ( @47 |
| rightParenthesis: ) @48 |
| staticElement: <testLibraryFragment>::@class::C::@constructor::new |
| redirectedConstructor: <testLibraryFragment>::@class::C::@constructor::new |
| '''); |
| } |
| |
| test_class_constructor_redirected_thisInvocation_unnamed_generic() async { |
| var library = await buildLibrary(''' |
| class C<T> { |
| const C(); |
| const C.named() : this(); |
| } |
| '''); |
| checkElementText(library, r''' |
| library |
| reference: <testLibrary> |
| definingUnit: <testLibraryFragment> |
| units |
| <testLibraryFragment> |
| enclosingElement: <testLibrary> |
| classes |
| class C @6 |
| reference: <testLibraryFragment>::@class::C |
| enclosingElement: <testLibraryFragment> |
| typeParameters |
| covariant T @8 |
| defaultType: dynamic |
| constructors |
| const @21 |
| reference: <testLibraryFragment>::@class::C::@constructor::new |
| enclosingElement: <testLibraryFragment>::@class::C |
| const named @36 |
| reference: <testLibraryFragment>::@class::C::@constructor::named |
| enclosingElement: <testLibraryFragment>::@class::C |
| periodOffset: 35 |
| nameEnd: 41 |
| constantInitializers |
| RedirectingConstructorInvocation |
| thisKeyword: this @46 |
| |