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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -412,10 +412,7 @@ class ResolvedAstPrinter extends ThrowingAstVisitor<void> {
_writeln('DefaultFormalParameter');
_withIndent(() {
_writeNamedChildEntities(node);
if (_withResolution) {
_writeElement('declaredElement', node.declaredElement);
_writeType('declaredElementType', node.declaredElement!.type);
}
_writeDeclaredElement(node, node.declaredElement);
});
}
@ -559,10 +556,7 @@ class ResolvedAstPrinter extends ThrowingAstVisitor<void> {
_writeln('FieldFormalParameter');
_withIndent(() {
_writeNamedChildEntities(node);
if (_withResolution) {
_writeElement('declaredElement', node.declaredElement);
_writeType('declaredElementType', node.declaredElement!.type);
}
_writeDeclaredElement(node, node.declaredElement);
});
}
@ -643,10 +637,7 @@ class ResolvedAstPrinter extends ThrowingAstVisitor<void> {
_writeln('FunctionDeclaration');
_withIndent(() {
_writeNamedChildEntities(node);
if (_withResolution) {
_writeElement('declaredElement', node.declaredElement);
_writeType('declaredElementType', node.declaredElement!.type);
}
_writeDeclaredElement(node, node.declaredElement);
});
}
@ -710,10 +701,7 @@ class ResolvedAstPrinter extends ThrowingAstVisitor<void> {
_writeln('FunctionTypedFormalParameter');
_withIndent(() {
_writeNamedChildEntities(node);
if (_withResolution) {
_writeElement('declaredElement', node.declaredElement);
_writeType('declaredElementType', node.declaredElement!.type);
}
_writeDeclaredElement(node, node.declaredElement);
});
}
@ -966,10 +954,7 @@ class ResolvedAstPrinter extends ThrowingAstVisitor<void> {
_writeln('MethodDeclaration');
_withIndent(() {
_writeNamedChildEntities(node);
if (_withResolution) {
_writeElement('declaredElement', node.declaredElement);
_writeType('declaredElementType', node.declaredElement!.type);
}
_writeDeclaredElement(node, node.declaredElement);
});
}
@ -1323,10 +1308,7 @@ class ResolvedAstPrinter extends ThrowingAstVisitor<void> {
_writeln('SimpleFormalParameter');
_withIndent(() {
_writeNamedChildEntities(node);
if (_withResolution) {
_writeDeclaredElement(node, node.declaredElement);
_writeType('declaredElementType', node.declaredElement!.type);
}
_writeDeclaredElement(node, node.declaredElement);
});
}
@ -1398,10 +1380,7 @@ class ResolvedAstPrinter extends ThrowingAstVisitor<void> {
_writeln('SuperFormalParameter');
_withIndent(() {
_writeNamedChildEntities(node);
if (_withResolution) {
_writeDeclaredElement(node, node.declaredElement);
_writeType('declaredElementType', node.declaredElement!.type);
}
_writeDeclaredElement(node, node.declaredElement);
});
}
@ -1772,9 +1751,22 @@ Expected parent: (${parent.runtimeType}) $parent
final expected = _expectedFormalParameterElements(node);
_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) {