Replace assertFunctionExpressionInvocation() with textual dumps.
Change-Id: I4f9d4da934a128c6413880a4bd5a8e3adf3678f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/261783
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
diff --git a/pkg/analyzer/test/src/dart/resolution/for_element_test.dart b/pkg/analyzer/test/src/dart/resolution/for_element_test.dart
index b7df822..b7c00565 100644
--- a/pkg/analyzer/test/src/dart/resolution/for_element_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/for_element_test.dart
@@ -76,13 +76,20 @@
}
''');
- assertFunctionExpressionInvocation(
- findNode.functionExpressionInvocation('b()'),
- element: null,
- typeArgumentTypes: [],
- invokeType: 'bool Function()',
- type: 'bool',
- );
+ final node = findNode.functionExpressionInvocation('b()');
+ assertResolvedNodeText(node, r'''
+FunctionExpressionInvocation
+ function: SimpleIdentifier
+ token: b
+ staticElement: self::@function::f::@parameter::b
+ staticType: bool Function()
+ argumentList: ArgumentList
+ leftParenthesis: (
+ rightParenthesis: )
+ staticElement: <null>
+ staticInvokeType: bool Function()
+ staticType: bool
+''');
}
test_declaredVariableScope() async {
diff --git a/pkg/analyzer/test/src/dart/resolution/for_statement_test.dart b/pkg/analyzer/test/src/dart/resolution/for_statement_test.dart
index 95aca6d..447418d 100644
--- a/pkg/analyzer/test/src/dart/resolution/for_statement_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/for_statement_test.dart
@@ -110,12 +110,19 @@
}
''');
- assertFunctionExpressionInvocation(
- findNode.functionExpressionInvocation('b()'),
- element: null,
- typeArgumentTypes: [],
- invokeType: 'bool Function()',
- type: 'bool',
- );
+ final node = findNode.functionExpressionInvocation('b()');
+ assertResolvedNodeText(node, r'''
+FunctionExpressionInvocation
+ function: SimpleIdentifier
+ token: b
+ staticElement: self::@function::f::@parameter::b
+ staticType: bool Function()
+ argumentList: ArgumentList
+ leftParenthesis: (
+ rightParenthesis: )
+ staticElement: <null>
+ staticInvokeType: bool Function()
+ staticType: bool
+''');
}
}
diff --git a/pkg/analyzer/test/src/dart/resolution/function_expression_invocation_test.dart b/pkg/analyzer/test/src/dart/resolution/function_expression_invocation_test.dart
index 2e84ca2..954de6f 100644
--- a/pkg/analyzer/test/src/dart/resolution/function_expression_invocation_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/function_expression_invocation_test.dart
@@ -27,13 +27,29 @@
}
''');
- assertFunctionExpressionInvocation(
- findNode.functionExpressionInvocation('a(0)'),
- element: findElement.method('call'),
- typeArgumentTypes: ['int'],
- invokeType: 'void Function(int)',
- type: 'void',
- );
+ final node = findNode.functionExpressionInvocation('a(0)');
+ assertResolvedNodeText(node, r'''
+FunctionExpressionInvocation
+ function: SimpleIdentifier
+ token: a
+ staticElement: self::@function::f::@parameter::a
+ staticType: A
+ argumentList: ArgumentList
+ leftParenthesis: (
+ arguments
+ IntegerLiteral
+ literal: 0
+ parameter: ParameterMember
+ base: root::@parameter::t
+ substitution: {T: int}
+ staticType: int
+ rightParenthesis: )
+ staticElement: self::@class::A::@method::call
+ staticInvokeType: void Function(int)
+ staticType: void
+ typeArgumentTypes
+ int
+''');
}
test_call_infer_fromArguments_listLiteral() async {
@@ -49,13 +65,34 @@
}
''');
- assertFunctionExpressionInvocation(
- findNode.functionExpressionInvocation('a(['),
- element: findElement.method('call'),
- typeArgumentTypes: ['int'],
- invokeType: 'List<int> Function(List<int>)',
- type: 'List<int>',
- );
+ final node = findNode.functionExpressionInvocation('a([');
+ assertResolvedNodeText(node, r'''
+FunctionExpressionInvocation
+ function: SimpleIdentifier
+ token: a
+ staticElement: self::@function::main::@parameter::a
+ staticType: A
+ argumentList: ArgumentList
+ leftParenthesis: (
+ arguments
+ ListLiteral
+ leftBracket: [
+ elements
+ IntegerLiteral
+ literal: 0
+ staticType: int
+ rightBracket: ]
+ parameter: ParameterMember
+ base: root::@parameter::_
+ substitution: {T: int}
+ staticType: List<int>
+ rightParenthesis: )
+ staticElement: self::@class::A::@method::call
+ staticInvokeType: List<int> Function(List<int>)
+ staticType: List<int>
+ typeArgumentTypes
+ int
+''');
}
test_call_infer_fromContext() async {
@@ -71,13 +108,22 @@
}
''');
- assertFunctionExpressionInvocation(
- findNode.functionExpressionInvocation('a()'),
- element: findElement.method('call'),
- typeArgumentTypes: ['int'],
- invokeType: 'int Function()',
- type: 'int',
- );
+ final node = findNode.functionExpressionInvocation('a()');
+ assertResolvedNodeText(node, r'''
+FunctionExpressionInvocation
+ function: SimpleIdentifier
+ token: a
+ staticElement: self::@function::f::@parameter::a
+ staticType: A
+ argumentList: ArgumentList
+ leftParenthesis: (
+ rightParenthesis: )
+ staticElement: self::@class::A::@method::call
+ staticInvokeType: int Function()
+ staticType: int
+ typeArgumentTypes
+ int
+''');
}
test_call_typeArguments() async {
@@ -93,13 +139,22 @@
}
''');
- assertFunctionExpressionInvocation(
- findNode.functionExpressionInvocation('a<int>()'),
- element: findElement.method('call'),
- typeArgumentTypes: ['int'],
- invokeType: 'int Function()',
- type: 'int',
- );
+ final node = findNode.functionExpressionInvocation('a<int>()');
+ assertResolvedNodeText(node, r'''
+FunctionExpressionInvocation
+ function: SimpleIdentifier
+ token: a
+ staticElement: self::@function::f::@parameter::a
+ staticType: A
+ argumentList: ArgumentList
+ leftParenthesis: (
+ rightParenthesis: )
+ staticElement: self::@class::A::@method::call
+ staticInvokeType: int Function()
+ staticType: int
+ typeArgumentTypes
+ int
+''');
}
test_never() async {
@@ -112,15 +167,36 @@
error(HintCode.DEAD_CODE, 26, 8),
]);
- assertFunctionExpressionInvocation(
- findNode.functionExpressionInvocation('x<int>(1 + 2)'),
- element: null,
- typeArgumentTypes: ['int'],
- invokeType: 'dynamic',
- type: 'Never',
- );
-
- assertType(findNode.binary('1 + 2'), 'int');
+ final node = findNode.functionExpressionInvocation('x<int>(1 + 2)');
+ assertResolvedNodeText(node, r'''
+FunctionExpressionInvocation
+ function: SimpleIdentifier
+ token: x
+ staticElement: self::@function::f::@parameter::x
+ staticType: Never
+ argumentList: ArgumentList
+ leftParenthesis: (
+ arguments
+ BinaryExpression
+ leftOperand: IntegerLiteral
+ literal: 1
+ staticType: int
+ operator: +
+ rightOperand: IntegerLiteral
+ literal: 2
+ parameter: dart:core::@class::num::@method::+::@parameter::other
+ staticType: int
+ parameter: <null>
+ staticElement: dart:core::@class::num::@method::+
+ staticInvokeType: num Function(num)
+ staticType: int
+ rightParenthesis: )
+ staticElement: <null>
+ staticInvokeType: dynamic
+ staticType: Never
+ typeArgumentTypes
+ int
+''');
}
test_neverQ() async {
@@ -132,15 +208,36 @@
error(CompileTimeErrorCode.UNCHECKED_INVOCATION_OF_NULLABLE_VALUE, 21, 1),
]);
- assertFunctionExpressionInvocation(
- findNode.functionExpressionInvocation('x<int>(1 + 2)'),
- element: null,
- typeArgumentTypes: ['int'],
- invokeType: 'dynamic',
- type: 'dynamic',
- );
-
- assertType(findNode.binary('1 + 2'), 'int');
+ final node = findNode.functionExpressionInvocation('x<int>(1 + 2)');
+ assertResolvedNodeText(node, r'''
+FunctionExpressionInvocation
+ function: SimpleIdentifier
+ token: x
+ staticElement: self::@function::f::@parameter::x
+ staticType: Never?
+ argumentList: ArgumentList
+ leftParenthesis: (
+ arguments
+ BinaryExpression
+ leftOperand: IntegerLiteral
+ literal: 1
+ staticType: int
+ operator: +
+ rightOperand: IntegerLiteral
+ literal: 2
+ parameter: dart:core::@class::num::@method::+::@parameter::other
+ staticType: int
+ parameter: <null>
+ staticElement: dart:core::@class::num::@method::+
+ staticInvokeType: num Function(num)
+ staticType: int
+ rightParenthesis: )
+ staticElement: <null>
+ staticInvokeType: dynamic
+ staticType: dynamic
+ typeArgumentTypes
+ int
+''');
}
test_nullShorting() async {
@@ -156,13 +253,27 @@
}
''');
- assertFunctionExpressionInvocation(
- findNode.functionExpressionInvocation('a?.foo()'),
- element: null,
- typeArgumentTypes: [],
- invokeType: 'int Function()',
- type: 'int?',
- );
+ final node = findNode.functionExpressionInvocation('a?.foo()');
+ assertResolvedNodeText(node, r'''
+FunctionExpressionInvocation
+ function: PropertyAccess
+ target: SimpleIdentifier
+ token: a
+ staticElement: self::@class::B::@method::bar::@parameter::a
+ staticType: A?
+ operator: ?.
+ propertyName: SimpleIdentifier
+ token: foo
+ staticElement: self::@class::A::@getter::foo
+ staticType: int Function()
+ staticType: int Function()
+ argumentList: ArgumentList
+ leftParenthesis: (
+ rightParenthesis: )
+ staticElement: <null>
+ staticInvokeType: int Function()
+ staticType: int?
+''');
}
test_nullShorting_extends() async {
@@ -178,19 +289,34 @@
}
''');
- assertFunctionExpressionInvocation(
- findNode.functionExpressionInvocation('a?.foo()'),
- element: null,
- typeArgumentTypes: [],
- invokeType: 'int Function()',
- type: 'int',
- );
-
- assertPropertyAccess2(
- findNode.propertyAccess('isEven'),
- element: intElement.getGetter('isEven'),
- type: 'bool?',
- );
+ var node = findNode.propertyAccess('isEven');
+ assertResolvedNodeText(node, r'''
+PropertyAccess
+ target: FunctionExpressionInvocation
+ function: PropertyAccess
+ target: SimpleIdentifier
+ token: a
+ staticElement: self::@class::B::@method::bar::@parameter::a
+ staticType: A?
+ operator: ?.
+ propertyName: SimpleIdentifier
+ token: foo
+ staticElement: self::@class::A::@getter::foo
+ staticType: int Function()
+ staticType: int Function()
+ argumentList: ArgumentList
+ leftParenthesis: (
+ rightParenthesis: )
+ staticElement: <null>
+ staticInvokeType: int Function()
+ staticType: int
+ operator: .
+ propertyName: SimpleIdentifier
+ token: isEven
+ staticElement: dart:core::@class::int::@getter::isEven
+ staticType: bool
+ staticType: bool?
+''');
}
test_record_field_named() async {
@@ -313,13 +439,38 @@
}
''');
- assertFunctionExpressionInvocation(
- findNode.functionExpressionInvocation('(0)'),
- element: null,
- typeArgumentTypes: [],
- invokeType: 'dynamic',
- type: 'dynamic',
- );
+ final node = findNode.functionExpressionInvocation('(0)');
+ assertResolvedNodeText(node, r'''
+FunctionExpressionInvocation
+ function: ParenthesizedExpression
+ leftParenthesis: (
+ expression: AsExpression
+ expression: SimpleIdentifier
+ token: main
+ staticElement: self::@function::main
+ staticType: dynamic Function()*
+ asOperator: as
+ type: NamedType
+ name: SimpleIdentifier
+ token: dynamic
+ staticElement: dynamic@-1
+ staticType: null
+ type: dynamic
+ staticType: dynamic
+ rightParenthesis: )
+ staticType: dynamic
+ argumentList: ArgumentList
+ leftParenthesis: (
+ arguments
+ IntegerLiteral
+ literal: 0
+ parameter: <null>
+ staticType: int*
+ rightParenthesis: )
+ staticElement: <null>
+ staticInvokeType: dynamic
+ staticType: dynamic
+''');
}
test_dynamic_withTypeArguments() async {
@@ -329,12 +480,40 @@
}
''');
- assertFunctionExpressionInvocation(
- findNode.functionExpressionInvocation('(0)'),
- element: null,
- typeArgumentTypes: ['bool', 'int'],
- invokeType: 'dynamic',
- type: 'dynamic',
- );
+ final node = findNode.functionExpressionInvocation('(0)');
+ assertResolvedNodeText(node, r'''
+FunctionExpressionInvocation
+ function: ParenthesizedExpression
+ leftParenthesis: (
+ expression: AsExpression
+ expression: SimpleIdentifier
+ token: main
+ staticElement: self::@function::main
+ staticType: dynamic Function()*
+ asOperator: as
+ type: NamedType
+ name: SimpleIdentifier
+ token: dynamic
+ staticElement: dynamic@-1
+ staticType: null
+ type: dynamic
+ staticType: dynamic
+ rightParenthesis: )
+ staticType: dynamic
+ argumentList: ArgumentList
+ leftParenthesis: (
+ arguments
+ IntegerLiteral
+ literal: 0
+ parameter: <null>
+ staticType: int*
+ rightParenthesis: )
+ staticElement: <null>
+ staticInvokeType: dynamic
+ staticType: dynamic
+ typeArgumentTypes
+ bool*
+ int*
+''');
}
}
diff --git a/pkg/analyzer/test/src/dart/resolution/if_element_test.dart b/pkg/analyzer/test/src/dart/resolution/if_element_test.dart
index 9eb0ae3..e814dec 100644
--- a/pkg/analyzer/test/src/dart/resolution/if_element_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/if_element_test.dart
@@ -21,12 +21,19 @@
}
''');
- assertFunctionExpressionInvocation(
- findNode.functionExpressionInvocation('b()'),
- element: null,
- typeArgumentTypes: [],
- invokeType: 'bool Function()',
- type: 'bool',
- );
+ final node = findNode.functionExpressionInvocation('b()');
+ assertResolvedNodeText(node, r'''
+FunctionExpressionInvocation
+ function: SimpleIdentifier
+ token: b
+ staticElement: self::@function::f::@parameter::b
+ staticType: bool Function()
+ argumentList: ArgumentList
+ leftParenthesis: (
+ rightParenthesis: )
+ staticElement: <null>
+ staticInvokeType: bool Function()
+ staticType: bool
+''');
}
}
diff --git a/pkg/analyzer/test/src/dart/resolution/resolution.dart b/pkg/analyzer/test/src/dart/resolution/resolution.dart
index 92b5513..70305af 100644
--- a/pkg/analyzer/test/src/dart/resolution/resolution.dart
+++ b/pkg/analyzer/test/src/dart/resolution/resolution.dart
@@ -296,19 +296,6 @@
assertElement(node.declaredElement, element);
}
- void assertFunctionExpressionInvocation(
- FunctionExpressionInvocation node, {
- required ExecutableElement? element,
- required List<String> typeArgumentTypes,
- required String invokeType,
- required String type,
- }) {
- assertElement(node, element);
- assertTypeArgumentTypes(node, typeArgumentTypes);
- assertInvokeType(node, invokeType);
- assertType(node, type);
- }
-
void assertHasTestErrors() {
expect(result.errors, isNotEmpty);
}
diff --git a/pkg/analyzer/test/src/diagnostics/extension_override_access_to_static_member_test.dart b/pkg/analyzer/test/src/diagnostics/extension_override_access_to_static_member_test.dart
index 8279ab9..b6f2d72 100644
--- a/pkg/analyzer/test/src/diagnostics/extension_override_access_to_static_member_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/extension_override_access_to_static_member_test.dart
@@ -30,14 +30,31 @@
2),
]);
- var invocation = findNode.functionExpressionInvocation('();');
- assertFunctionExpressionInvocation(
- invocation,
- element: findElement.method('call', of: 'E'),
- typeArgumentTypes: [],
- invokeType: 'void Function()',
- type: 'void',
- );
+ final node = findNode.functionExpressionInvocation('();');
+ assertResolvedNodeText(node, r'''
+FunctionExpressionInvocation
+ function: ExtensionOverride
+ extensionName: SimpleIdentifier
+ token: E
+ staticElement: self::@extension::E
+ staticType: null
+ argumentList: ArgumentList
+ leftParenthesis: (
+ arguments
+ IntegerLiteral
+ literal: 0
+ parameter: <null>
+ staticType: int
+ rightParenthesis: )
+ extendedType: int
+ staticType: null
+ argumentList: ArgumentList
+ leftParenthesis: (
+ rightParenthesis: )
+ staticElement: self::@extension::E::@method::call
+ staticInvokeType: void Function()
+ staticType: void
+''');
}
test_getter() async {