Replace declaredElementType with nested 'type' in expectations.

Change-Id: I4cd95528e24b0278f74e270e5685ef2d89d5e505
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/288263
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
Konstantin Shcheglov 2023-03-10 19:35:24 +00:00 committed by Commit Queue
parent fadbd51c83
commit af52197dd6
9 changed files with 89 additions and 97 deletions

View file

@ -3049,10 +3049,8 @@ void main() {
]); ]);
final node = findNode.functionDeclaration('f<T>'); final node = findNode.functionDeclaration('f<T>');
assertResolvedNodeText( if (isNullSafetyEnabled) {
node, assertResolvedNodeText(node, r'''
isNullSafetyEnabled
? r'''
FunctionDeclaration FunctionDeclaration
returnType: NamedType returnType: NamedType
name: SimpleIdentifier name: SimpleIdentifier
@ -3080,7 +3078,7 @@ FunctionDeclaration
type: T type: T
name: x name: x
declaredElement: self::@function::f::@parameter::x declaredElement: self::@function::f::@parameter::x
declaredElementType: T type: T
rightParenthesis: ) rightParenthesis: )
body: ExpressionFunctionBody body: ExpressionFunctionBody
functionDefinition: => functionDefinition: =>
@ -3091,9 +3089,10 @@ FunctionDeclaration
declaredElement: self::@function::f declaredElement: self::@function::f
staticType: T Function<T>(T) staticType: T Function<T>(T)
declaredElement: self::@function::f declaredElement: self::@function::f
declaredElementType: T Function<T>(T) type: T Function<T>(T)
''' ''');
: r''' } else {
assertResolvedNodeText(node, r'''
FunctionDeclaration FunctionDeclaration
returnType: NamedType returnType: NamedType
name: SimpleIdentifier name: SimpleIdentifier
@ -3121,7 +3120,7 @@ FunctionDeclaration
type: T* type: T*
name: x name: x
declaredElement: self::@function::f::@parameter::x declaredElement: self::@function::f::@parameter::x
declaredElementType: T* type: T*
rightParenthesis: ) rightParenthesis: )
body: ExpressionFunctionBody body: ExpressionFunctionBody
functionDefinition: => functionDefinition: =>
@ -3132,8 +3131,9 @@ FunctionDeclaration
declaredElement: self::@function::f declaredElement: self::@function::f
staticType: T* Function<T>(T*)* staticType: T* Function<T>(T*)*
declaredElement: self::@function::f declaredElement: self::@function::f
declaredElementType: T* Function<T>(T*)* type: T* Function<T>(T*)*
'''); ''');
}
} }
test_genericFunction_bounds() async { test_genericFunction_bounds() async {
@ -3143,10 +3143,8 @@ FunctionDeclaration
]); ]);
final node = findNode.functionDeclaration('f<T'); final node = findNode.functionDeclaration('f<T');
assertResolvedNodeText( if (isNullSafetyEnabled) {
node, assertResolvedNodeText(node, r'''
isNullSafetyEnabled
? r'''
FunctionDeclaration FunctionDeclaration
returnType: NamedType returnType: NamedType
name: SimpleIdentifier name: SimpleIdentifier
@ -3181,7 +3179,7 @@ FunctionDeclaration
type: T type: T
name: x name: x
declaredElement: self::@function::f::@parameter::x declaredElement: self::@function::f::@parameter::x
declaredElementType: T type: T
rightParenthesis: ) rightParenthesis: )
body: ExpressionFunctionBody body: ExpressionFunctionBody
functionDefinition: => functionDefinition: =>
@ -3192,9 +3190,10 @@ FunctionDeclaration
declaredElement: self::@function::f declaredElement: self::@function::f
staticType: T Function<T extends num>(T) staticType: T Function<T extends num>(T)
declaredElement: self::@function::f declaredElement: self::@function::f
declaredElementType: T Function<T extends num>(T) type: T Function<T extends num>(T)
''' ''');
: r''' } else {
assertResolvedNodeText(node, r'''
FunctionDeclaration FunctionDeclaration
returnType: NamedType returnType: NamedType
name: SimpleIdentifier name: SimpleIdentifier
@ -3229,7 +3228,7 @@ FunctionDeclaration
type: T* type: T*
name: x name: x
declaredElement: self::@function::f::@parameter::x declaredElement: self::@function::f::@parameter::x
declaredElementType: T* type: T*
rightParenthesis: ) rightParenthesis: )
body: ExpressionFunctionBody body: ExpressionFunctionBody
functionDefinition: => functionDefinition: =>
@ -3240,8 +3239,9 @@ FunctionDeclaration
declaredElement: self::@function::f declaredElement: self::@function::f
staticType: T* Function<T extends num*>(T*)* staticType: T* Function<T extends num*>(T*)*
declaredElement: self::@function::f declaredElement: self::@function::f
declaredElementType: T* Function<T extends num*>(T*)* type: T* Function<T extends num*>(T*)*
'''); ''');
}
} }
test_genericFunction_parameter() async { test_genericFunction_parameter() async {
@ -3265,10 +3265,8 @@ class C<E> {
]); ]);
final node = findNode.methodDeclaration('f<T>'); final node = findNode.methodDeclaration('f<T>');
assertResolvedNodeText( if (isNullSafetyEnabled) {
node, assertResolvedNodeText(node, r'''
isNullSafetyEnabled
? r'''
MethodDeclaration MethodDeclaration
modifierKeyword: static modifierKeyword: static
returnType: NamedType returnType: NamedType
@ -3289,7 +3287,7 @@ MethodDeclaration
type: T type: T
name: x name: x
declaredElement: self::@class::C::@method::f::@parameter::x declaredElement: self::@class::C::@method::f::@parameter::x
declaredElementType: T type: T
rightParenthesis: ) rightParenthesis: )
body: ExpressionFunctionBody body: ExpressionFunctionBody
functionDefinition: => functionDefinition: =>
@ -3298,9 +3296,10 @@ MethodDeclaration
staticType: Null staticType: Null
semicolon: ; semicolon: ;
declaredElement: self::@class::C::@method::f declaredElement: self::@class::C::@method::f
declaredElementType: T Function<T>(T) type: T Function<T>(T)
''' ''');
: r''' } else {
assertResolvedNodeText(node, r'''
MethodDeclaration MethodDeclaration
modifierKeyword: static modifierKeyword: static
returnType: NamedType returnType: NamedType
@ -3321,7 +3320,7 @@ MethodDeclaration
type: T* type: T*
name: x name: x
declaredElement: self::@class::C::@method::f::@parameter::x declaredElement: self::@class::C::@method::f::@parameter::x
declaredElementType: T* type: T*
rightParenthesis: ) rightParenthesis: )
body: ExpressionFunctionBody body: ExpressionFunctionBody
functionDefinition: => functionDefinition: =>
@ -3330,8 +3329,9 @@ MethodDeclaration
staticType: Null* staticType: Null*
semicolon: ; semicolon: ;
declaredElement: self::@class::C::@method::f declaredElement: self::@class::C::@method::f
declaredElementType: T* Function<T>(T*)* type: T* Function<T>(T*)*
'''); ''');
}
} }
test_genericFunction_typedef() async { test_genericFunction_typedef() async {
@ -3961,10 +3961,8 @@ class D extends C {
: []); : []);
final node = findNode.methodDeclaration('f<T>(T y)'); final node = findNode.methodDeclaration('f<T>(T y)');
assertResolvedNodeText( if (isNullSafetyEnabled) {
node, assertResolvedNodeText(node, r'''
isNullSafetyEnabled
? r'''
MethodDeclaration MethodDeclaration
returnType: NamedType returnType: NamedType
name: SimpleIdentifier name: SimpleIdentifier
@ -3984,7 +3982,7 @@ MethodDeclaration
type: T type: T
name: y name: y
declaredElement: self::@class::D::@method::f::@parameter::y declaredElement: self::@class::D::@method::f::@parameter::y
declaredElementType: T type: T
rightParenthesis: ) rightParenthesis: )
body: ExpressionFunctionBody body: ExpressionFunctionBody
functionDefinition: => functionDefinition: =>
@ -3993,9 +3991,10 @@ MethodDeclaration
staticType: Null staticType: Null
semicolon: ; semicolon: ;
declaredElement: self::@class::D::@method::f declaredElement: self::@class::D::@method::f
declaredElementType: T Function<T>(T) type: T Function<T>(T)
''' ''');
: r''' } else {
assertResolvedNodeText(node, r'''
MethodDeclaration MethodDeclaration
returnType: NamedType returnType: NamedType
name: SimpleIdentifier name: SimpleIdentifier
@ -4015,7 +4014,7 @@ MethodDeclaration
type: T* type: T*
name: y name: y
declaredElement: self::@class::D::@method::f::@parameter::y declaredElement: self::@class::D::@method::f::@parameter::y
declaredElementType: T* type: T*
rightParenthesis: ) rightParenthesis: )
body: ExpressionFunctionBody body: ExpressionFunctionBody
functionDefinition: => functionDefinition: =>
@ -4024,8 +4023,9 @@ MethodDeclaration
staticType: Null* staticType: Null*
semicolon: ; semicolon: ;
declaredElement: self::@class::D::@method::f declaredElement: self::@class::D::@method::f
declaredElementType: T* Function<T>(T*)* type: T* Function<T>(T*)*
'''); ''');
}
} }
test_genericMethod_override_bounds() async { test_genericMethod_override_bounds() async {

View file

@ -63,7 +63,7 @@ GenericFunctionType
staticType: null staticType: null
type: double type: double
declaredElement: @-1 declaredElement: @-1
declaredElementType: double type: double
rightParenthesis: ) rightParenthesis: )
declaredElement: GenericFunctionTypeElement declaredElement: GenericFunctionTypeElement
parameters parameters

View file

@ -576,7 +576,7 @@ GenericFunctionType
staticType: null staticType: null
type: int type: int
declaredElement: @-1 declaredElement: @-1
declaredElementType: int type: int
rightParenthesis: ) rightParenthesis: )
declaredElement: GenericFunctionTypeElement declaredElement: GenericFunctionTypeElement
parameters parameters
@ -607,7 +607,7 @@ GenericFunctionType
staticType: null staticType: null
type: int* type: int*
declaredElement: @-1 declaredElement: @-1
declaredElementType: int* type: int*
rightParenthesis: ) rightParenthesis: )
declaredElement: GenericFunctionTypeElement declaredElement: GenericFunctionTypeElement
parameters parameters
@ -801,7 +801,7 @@ GenericFunctionType
staticType: null staticType: null
type: String type: String
declaredElement: @-1 declaredElement: @-1
declaredElementType: String type: String
rightParenthesis: ) rightParenthesis: )
declaredElement: GenericFunctionTypeElement declaredElement: GenericFunctionTypeElement
parameters parameters
@ -832,7 +832,7 @@ GenericFunctionType
staticType: null staticType: null
type: String* type: String*
declaredElement: @-1 declaredElement: @-1
declaredElementType: String* type: String*
rightParenthesis: ) rightParenthesis: )
declaredElement: GenericFunctionTypeElement declaredElement: GenericFunctionTypeElement
parameters parameters

View file

@ -41,7 +41,7 @@ FieldFormalParameter
period: . period: .
name: f name: f
declaredElement: self::@enum::E::@constructor::new::@parameter::f declaredElement: self::@enum::E::@constructor::new::@parameter::f
declaredElementType: int type: int
'''); ''');
} }
} }

View file

@ -3803,7 +3803,7 @@ FunctionReference
staticType: null staticType: null
type: T type: T
declaredElement: @-1 declaredElement: @-1
declaredElementType: T type: T
rightParenthesis: ) rightParenthesis: )
declaredElement: GenericFunctionTypeElement declaredElement: GenericFunctionTypeElement
parameters parameters
@ -4026,7 +4026,7 @@ FunctionReference
type: T type: T
name: a name: a
declaredElement: @36::@parameter::a declaredElement: @36::@parameter::a
declaredElementType: T type: T
rightParenthesis: ) rightParenthesis: )
body: BlockFunctionBody body: BlockFunctionBody
block: Block block: Block

View file

@ -102,10 +102,10 @@ SuperFormalParameter
type: int type: int
name: b name: b
declaredElement: self::@class::B::@constructor::new::@parameter::a::@parameter::b declaredElement: self::@class::B::@constructor::new::@parameter::a::@parameter::b
declaredElementType: int type: int
rightParenthesis: ) rightParenthesis: )
declaredElement: self::@class::B::@constructor::new::@parameter::a declaredElement: self::@class::B::@constructor::new::@parameter::a
declaredElementType: T Function<T>(int) type: T Function<T>(int)
'''); ''');
} }
@ -123,7 +123,7 @@ SuperFormalParameter
period: . period: .
name: a name: a
declaredElement: self::@function::f::@parameter::a declaredElement: self::@function::f::@parameter::a
declaredElementType: dynamic type: dynamic
'''); ''');
} }
@ -145,7 +145,7 @@ SuperFormalParameter
period: . period: .
name: a name: a
declaredElement: self::@class::B::@constructor::new::@parameter::a declaredElement: self::@class::B::@constructor::new::@parameter::a
declaredElementType: int? type: int?
'''); ''');
} }
@ -167,7 +167,7 @@ SuperFormalParameter
period: . period: .
name: a name: a
declaredElement: self::@class::B::@constructor::new::@parameter::a declaredElement: self::@class::B::@constructor::new::@parameter::a
declaredElementType: int? type: int?
'''); ''');
} }
@ -190,7 +190,7 @@ SuperFormalParameter
period: . period: .
name: a name: a
declaredElement: self::@class::B::@constructor::new::@parameter::a declaredElement: self::@class::B::@constructor::new::@parameter::a
declaredElementType: int type: int
'''); ''');
} }
@ -212,7 +212,7 @@ SuperFormalParameter
period: . period: .
name: a name: a
declaredElement: self::@class::B::@constructor::new::@parameter::a declaredElement: self::@class::B::@constructor::new::@parameter::a
declaredElementType: int type: int
'''); ''');
} }

View file

@ -55,7 +55,7 @@ VariableDeclaration
parameter: SimpleFormalParameter parameter: SimpleFormalParameter
name: z name: z
declaredElement: @99::@parameter::z declaredElement: @99::@parameter::z
declaredElementType: Object? type: Object?
rightParenthesis: ) rightParenthesis: )
body: ExpressionFunctionBody body: ExpressionFunctionBody
functionDefinition: => functionDefinition: =>
@ -119,7 +119,7 @@ VariableDeclaration
parameter: SimpleFormalParameter parameter: SimpleFormalParameter
name: z name: z
declaredElement: @107::@parameter::z declaredElement: @107::@parameter::z
declaredElementType: String type: String
rightParenthesis: ) rightParenthesis: )
body: ExpressionFunctionBody body: ExpressionFunctionBody
functionDefinition: => functionDefinition: =>

View file

@ -4677,7 +4677,7 @@ library
type: double type: double
name: a @78 name: a @78
declaredElement: a@78 declaredElement: a@78
declaredElementType: double type: double
rightParenthesis: ) @79 rightParenthesis: ) @79
declaredElement: GenericFunctionTypeElement declaredElement: GenericFunctionTypeElement
parameters parameters
@ -24606,7 +24606,7 @@ library
type: String type: String
name: a @52 name: a @52
declaredElement: a@52 declaredElement: a@52
declaredElementType: String type: String
rightParenthesis: ) @53 rightParenthesis: ) @53
declaredElement: GenericFunctionTypeElement declaredElement: GenericFunctionTypeElement
parameters parameters
@ -24678,7 +24678,7 @@ library
type: String type: String
name: a @52 name: a @52
declaredElement: a@52 declaredElement: a@52
declaredElementType: String type: String
rightParenthesis: ) @53 rightParenthesis: ) @53
declaredElement: GenericFunctionTypeElement declaredElement: GenericFunctionTypeElement
parameters parameters
@ -24763,9 +24763,9 @@ library
type: int? type: int?
name: a @63 name: a @63
declaredElement: a@63 declaredElement: a@63
declaredElementType: int? type: int?
declaredElement: a@63 declaredElement: a@63
declaredElementType: int? type: int?
rightDelimiter: } @64 rightDelimiter: } @64
rightParenthesis: ) @65 rightParenthesis: ) @65
declaredElement: GenericFunctionTypeElement declaredElement: GenericFunctionTypeElement
@ -24846,9 +24846,9 @@ library
type: int? type: int?
name: a @63 name: a @63
declaredElement: a@63 declaredElement: a@63
declaredElementType: int? type: int?
declaredElement: a@63 declaredElement: a@63
declaredElementType: int? type: int?
rightDelimiter: ] @64 rightDelimiter: ] @64
rightParenthesis: ) @65 rightParenthesis: ) @65
declaredElement: GenericFunctionTypeElement declaredElement: GenericFunctionTypeElement
@ -24929,9 +24929,9 @@ library
type: int type: int
name: a @71 name: a @71
declaredElement: a@71 declaredElement: a@71
declaredElementType: int type: int
declaredElement: a@71 declaredElement: a@71
declaredElementType: int type: int
rightDelimiter: } @72 rightDelimiter: } @72
rightParenthesis: ) @73 rightParenthesis: ) @73
declaredElement: GenericFunctionTypeElement declaredElement: GenericFunctionTypeElement
@ -25009,7 +25009,7 @@ library
type: int type: int
name: a @61 name: a @61
declaredElement: a@61 declaredElement: a@61
declaredElementType: int type: int
rightParenthesis: ) @62 rightParenthesis: ) @62
declaredElement: GenericFunctionTypeElement declaredElement: GenericFunctionTypeElement
parameters parameters

View file

@ -412,10 +412,7 @@ class ResolvedAstPrinter extends ThrowingAstVisitor<void> {
_writeln('DefaultFormalParameter'); _writeln('DefaultFormalParameter');
_withIndent(() { _withIndent(() {
_writeNamedChildEntities(node); _writeNamedChildEntities(node);
if (_withResolution) { _writeDeclaredElement(node, node.declaredElement);
_writeElement('declaredElement', node.declaredElement);
_writeType('declaredElementType', node.declaredElement!.type);
}
}); });
} }
@ -559,10 +556,7 @@ class ResolvedAstPrinter extends ThrowingAstVisitor<void> {
_writeln('FieldFormalParameter'); _writeln('FieldFormalParameter');
_withIndent(() { _withIndent(() {
_writeNamedChildEntities(node); _writeNamedChildEntities(node);
if (_withResolution) { _writeDeclaredElement(node, node.declaredElement);
_writeElement('declaredElement', node.declaredElement);
_writeType('declaredElementType', node.declaredElement!.type);
}
}); });
} }
@ -643,10 +637,7 @@ class ResolvedAstPrinter extends ThrowingAstVisitor<void> {
_writeln('FunctionDeclaration'); _writeln('FunctionDeclaration');
_withIndent(() { _withIndent(() {
_writeNamedChildEntities(node); _writeNamedChildEntities(node);
if (_withResolution) { _writeDeclaredElement(node, node.declaredElement);
_writeElement('declaredElement', node.declaredElement);
_writeType('declaredElementType', node.declaredElement!.type);
}
}); });
} }
@ -710,10 +701,7 @@ class ResolvedAstPrinter extends ThrowingAstVisitor<void> {
_writeln('FunctionTypedFormalParameter'); _writeln('FunctionTypedFormalParameter');
_withIndent(() { _withIndent(() {
_writeNamedChildEntities(node); _writeNamedChildEntities(node);
if (_withResolution) { _writeDeclaredElement(node, node.declaredElement);
_writeElement('declaredElement', node.declaredElement);
_writeType('declaredElementType', node.declaredElement!.type);
}
}); });
} }
@ -966,10 +954,7 @@ class ResolvedAstPrinter extends ThrowingAstVisitor<void> {
_writeln('MethodDeclaration'); _writeln('MethodDeclaration');
_withIndent(() { _withIndent(() {
_writeNamedChildEntities(node); _writeNamedChildEntities(node);
if (_withResolution) { _writeDeclaredElement(node, node.declaredElement);
_writeElement('declaredElement', node.declaredElement);
_writeType('declaredElementType', node.declaredElement!.type);
}
}); });
} }
@ -1323,10 +1308,7 @@ class ResolvedAstPrinter extends ThrowingAstVisitor<void> {
_writeln('SimpleFormalParameter'); _writeln('SimpleFormalParameter');
_withIndent(() { _withIndent(() {
_writeNamedChildEntities(node); _writeNamedChildEntities(node);
if (_withResolution) { _writeDeclaredElement(node, node.declaredElement);
_writeDeclaredElement(node, node.declaredElement);
_writeType('declaredElementType', node.declaredElement!.type);
}
}); });
} }
@ -1398,10 +1380,7 @@ class ResolvedAstPrinter extends ThrowingAstVisitor<void> {
_writeln('SuperFormalParameter'); _writeln('SuperFormalParameter');
_withIndent(() { _withIndent(() {
_writeNamedChildEntities(node); _writeNamedChildEntities(node);
if (_withResolution) { _writeDeclaredElement(node, node.declaredElement);
_writeDeclaredElement(node, node.declaredElement);
_writeType('declaredElementType', node.declaredElement!.type);
}
}); });
} }
@ -1772,9 +1751,22 @@ Expected parent: (${parent.runtimeType}) $parent
final expected = _expectedFormalParameterElements(node); final expected = _expectedFormalParameterElements(node);
_assertHasIdenticalElement(expected, declaredElement); _assertHasIdenticalElement(expected, declaredElement);
} }
}
_writeElement('declaredElement', declaredElement); _writeElement('declaredElement', declaredElement);
DartType type;
if (declaredElement is ExecutableElementImpl) {
type = declaredElement.type;
} else if (declaredElement is VariableElement) {
type = declaredElement.type;
} else {
throw StateError('Unexpected: $declaredElement');
}
_withIndent(() {
_writeType('type', type);
});
}
} }
void _writeDirectiveUri(DirectiveUri? uri) { void _writeDirectiveUri(DirectiveUri? uri) {