diff --git a/pkg/analyzer/lib/src/summary2/element_builder.dart b/pkg/analyzer/lib/src/summary2/element_builder.dart index c1b5665e12b..e0160550514 100644 --- a/pkg/analyzer/lib/src/summary2/element_builder.dart +++ b/pkg/analyzer/lib/src/summary2/element_builder.dart @@ -2081,6 +2081,10 @@ class FragmentBuilder extends ThrowingAstVisitor { } } for (var (i, formalParameter) in formalParameters.indexed) { + if (formalParameter is! RegularFormalParameterImpl) { + continue; + } + var isExtensionTypeRepresentation = i == 0 && isFirstFormalExtensionTypeRepresentation; if (formalParameter.finalOrVarKeyword != null || diff --git a/pkg/analyzer/test/src/summary/elements/class_test.dart b/pkg/analyzer/test/src/summary/elements/class_test.dart index e439bc9a42f..3587754ac70 100644 --- a/pkg/analyzer/test/src/summary/elements/class_test.dart +++ b/pkg/analyzer/test/src/summary/elements/class_test.dart @@ -11738,6 +11738,65 @@ library '''); } + test_constructor_primary_formalParameter_field_requiredPositional_final() async { + var library = await buildLibrary(r''' +class A(final this.foo) { + final int foo; +} +'''); + checkElementText(library, r''' +library + reference: + fragments + #F0 + element: + classes + #F1 class A (nameOffset:6) (firstTokenOffset:0) (offset:6) + element: ::@class::A + fields + #F2 isFinal isOriginDeclaration foo (nameOffset:38) (firstTokenOffset:38) (offset:38) + element: ::@class::A::@field::foo + inducedGetter: #F3 + constructors + #F4 isComplete isOriginDeclaration isPrimary new (nameOffset:) (firstTokenOffset:6) (offset:6) + element: ::@class::A::@constructor::new + typeName: A + typeNameOffset: 6 + formalParameters + #F5 requiredPositional hasImplicitType isFinal isOriginDeclaration this.foo (nameOffset:19) (firstTokenOffset:8) (offset:19) + element: ::@class::A::@constructor::new::@formalParameter::foo + getters + #F3 isComplete isOriginVariable foo (nameOffset:) (firstTokenOffset:) (offset:38) + element: ::@class::A::@getter::foo + inducingVariable: #F2 + classes + isSimplyBounded class A + reference: ::@class::A + firstFragment: #F1 + fields + isFinal isOriginDeclaration foo + reference: ::@class::A::@field::foo + firstFragment: #F2 + type: int + getter: ::@class::A::@getter::foo + constructors + isOriginDeclaration isPrimary new + reference: ::@class::A::@constructor::new + firstFragment: #F4 + formalParameters + #E0 requiredPositional hasImplicitType isFinal this.foo + firstFragment: #F5 + type: int + field: ::@class::A::@field::foo + getters + isOriginVariable foo + reference: ::@class::A::@getter::foo + firstFragment: #F3 + returnType: int + variable: ::@class::A::@field::foo +'''); + } + test_constructor_primary_formalParameter_regular_requiredPositional_functionTypedSuffix() async { var library = await buildLibrary(r''' class A(int foo()) {} @@ -11872,6 +11931,68 @@ library '''); } + test_constructor_primary_formalParameter_super_requiredPositional_final() async { + var library = await buildLibrary(r''' +class A(int foo) {} + +class B(final super.foo) extends A {} +'''); + checkElementText(library, r''' +library + reference: + fragments + #F0 + element: + classes + #F1 class A (nameOffset:6) (firstTokenOffset:0) (offset:6) + element: ::@class::A + constructors + #F2 isComplete isOriginDeclaration isPrimary new (nameOffset:) (firstTokenOffset:6) (offset:6) + element: ::@class::A::@constructor::new + typeName: A + typeNameOffset: 6 + formalParameters + #F3 requiredPositional isOriginDeclaration foo (nameOffset:12) (firstTokenOffset:8) (offset:12) + element: ::@class::A::@constructor::new::@formalParameter::foo + #F4 hasExtendsClause class B (nameOffset:27) (firstTokenOffset:21) (offset:27) + element: ::@class::B + constructors + #F5 isComplete isOriginDeclaration isPrimary new (nameOffset:) (firstTokenOffset:27) (offset:27) + element: ::@class::B::@constructor::new + typeName: B + typeNameOffset: 27 + formalParameters + #F6 requiredPositional hasImplicitType isFinal isOriginDeclaration super.foo (nameOffset:41) (firstTokenOffset:29) (offset:41) + element: ::@class::B::@constructor::new::@formalParameter::foo + classes + isSimplyBounded class A + reference: ::@class::A + firstFragment: #F1 + constructors + isOriginDeclaration isPrimary new + reference: ::@class::A::@constructor::new + firstFragment: #F2 + formalParameters + #E0 requiredPositional foo + firstFragment: #F3 + type: int + isSimplyBounded class B + reference: ::@class::B + firstFragment: #F4 + supertype: A + constructors + isOriginDeclaration isPrimary new + reference: ::@class::B::@constructor::new + firstFragment: #F5 + formalParameters + #E1 requiredPositional hasImplicitType isFinal super.foo + firstFragment: #F6 + type: int + superConstructorParameter: ::@class::A::@constructor::new::@formalParameter::foo + superConstructor: ::@class::A::@constructor::new +'''); + } + test_constructor_primary_named_formalParameter_super_optionalNamed() async { var library = await buildLibrary(r''' class A {