Use typeStringByNullability() where possible.

Change-Id: Ie8229a863996e2a42c0ab8b6b3ec4020a2d79969
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214580
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
Konstantin Shcheglov 2021-09-27 14:17:16 +00:00 committed by commit-bot@chromium.org
parent 94a079896b
commit a0bd1d89ad
3 changed files with 23 additions and 20 deletions

View file

@ -273,7 +273,7 @@ h(int x) {}
''');
assertTypeArgumentTypes(findNode.methodInvocation('f()'),
[typeToStringWithNullability ? 'int' : 'num']);
[typeStringByNullability(nullable: 'int', legacy: 'num')]);
}
test_minus_int_double() async {
@ -320,7 +320,7 @@ h(int x) {}
''');
assertTypeArgumentTypes(findNode.methodInvocation('f()'),
[typeToStringWithNullability ? 'int' : 'num']);
[typeStringByNullability(nullable: 'int', legacy: 'num')]);
}
test_mod_int_double() async {
@ -421,7 +421,7 @@ h(double x) {}
''');
assertTypeArgumentTypes(findNode.methodInvocation('f()'),
[typeToStringWithNullability ? 'double' : 'num']);
[typeStringByNullability(nullable: 'double', legacy: 'num')]);
}
test_plus_int_context_int() async {
@ -434,7 +434,7 @@ h(int x) {}
''');
assertTypeArgumentTypes(findNode.methodInvocation('f()'),
[typeToStringWithNullability ? 'int' : 'num']);
[typeStringByNullability(nullable: 'int', legacy: 'num')]);
}
test_plus_int_context_int_target_rewritten() async {
@ -447,7 +447,7 @@ h(int x) {}
''');
assertTypeArgumentTypes(findNode.methodInvocation('f()'),
[typeToStringWithNullability ? 'int' : 'num']);
[typeStringByNullability(nullable: 'int', legacy: 'num')]);
}
test_plus_int_context_int_via_extension_explicit() async {
@ -774,7 +774,7 @@ h(int x) {}
''');
assertTypeArgumentTypes(findNode.methodInvocation('f()'),
[typeToStringWithNullability ? 'int' : 'num']);
[typeStringByNullability(nullable: 'int', legacy: 'num')]);
}
test_star_int_double() async {

View file

@ -189,7 +189,7 @@ void f(A a) {
numPlusElement,
isLegacy: isLegacyLibrary,
),
type: typeToStringWithNullability ? 'double' : 'num',
type: typeStringByNullability(nullable: 'double', legacy: 'num'),
);
assertParameterElement(
assignment.rightHandSide,

View file

@ -33,9 +33,9 @@ h(double x) {}
''');
assertTypeArgumentTypes(findNode.methodInvocation('f(),'),
[typeToStringWithNullability ? 'double' : 'num']);
[typeStringByNullability(nullable: 'double', legacy: 'num')]);
assertTypeArgumentTypes(findNode.methodInvocation('f())'),
[typeToStringWithNullability ? 'double' : 'num']);
[typeStringByNullability(nullable: 'double', legacy: 'num')]);
}
test_clamp_double_context_int() async {
@ -79,7 +79,8 @@ f(double a, double b, double c) {
elementMatcher(numElement.getMethod('clamp'),
isLegacy: isLegacyLibrary),
'num Function(num, num)',
expectedType: typeToStringWithNullability ? 'double' : 'num');
expectedType:
typeStringByNullability(nullable: 'double', legacy: 'num'));
}
test_clamp_double_double_int() async {
@ -154,9 +155,9 @@ h(int x) {}
''');
assertTypeArgumentTypes(findNode.methodInvocation('f(),'),
[typeToStringWithNullability ? 'int' : 'num']);
[typeStringByNullability(nullable: 'int', legacy: 'num')]);
assertTypeArgumentTypes(findNode.methodInvocation('f())'),
[typeToStringWithNullability ? 'int' : 'num']);
[typeStringByNullability(nullable: 'int', legacy: 'num')]);
}
test_clamp_int_context_none() async {
@ -288,7 +289,7 @@ f(int a, int b, int c) {
elementMatcher(numElement.getMethod('clamp'),
isLegacy: isLegacyLibrary),
'num Function(num, num)',
expectedType: typeToStringWithNullability ? 'int' : 'num');
expectedType: typeStringByNullability(nullable: 'int', legacy: 'num'));
}
test_clamp_int_int_int_from_cascade() async {
@ -307,7 +308,7 @@ f(int a, int b, int c) {
elementMatcher(numElement.getMethod('clamp'),
isLegacy: isLegacyLibrary),
'num Function(num, num)',
expectedType: typeToStringWithNullability ? 'int' : 'num');
expectedType: typeStringByNullability(nullable: 'int', legacy: 'num'));
}
test_clamp_int_int_int_via_extension_explicit() async {
@ -377,7 +378,8 @@ f(Never a, int b, int c) {
assertMethodInvocation(
findNode.methodInvocation('clamp'), isNull, 'dynamic',
expectedType: typeToStringWithNullability ? 'Never' : 'dynamic');
expectedType:
typeStringByNullability(nullable: 'Never', legacy: 'dynamic'));
}
test_clamp_other_context_int() async {
@ -2217,7 +2219,7 @@ h(int x) {}
''');
assertTypeArgumentTypes(findNode.methodInvocation('f()'),
[typeToStringWithNullability ? 'int' : 'num']);
[typeStringByNullability(nullable: 'int', legacy: 'num')]);
}
test_remainder_int_context_int_target_rewritten() async {
@ -2230,7 +2232,7 @@ h(int x) {}
''');
assertTypeArgumentTypes(findNode.methodInvocation('f()'),
[typeToStringWithNullability ? 'int' : 'num']);
[typeStringByNullability(nullable: 'int', legacy: 'num')]);
}
test_remainder_int_context_int_via_extension_explicit() async {
@ -2273,7 +2275,8 @@ f(int a, double b) {
elementMatcher(numElement.getMethod('remainder'),
isLegacy: isLegacyLibrary),
'num Function(num)',
expectedType: typeToStringWithNullability ? 'double' : 'num');
expectedType:
typeStringByNullability(nullable: 'double', legacy: 'num'));
}
test_remainder_int_int() async {
@ -2288,7 +2291,7 @@ f(int a, int b) {
elementMatcher(numElement.getMethod('remainder'),
isLegacy: isLegacyLibrary),
'num Function(num)',
expectedType: typeToStringWithNullability ? 'int' : 'num');
expectedType: typeStringByNullability(nullable: 'int', legacy: 'num'));
}
test_remainder_int_int_target_rewritten() async {
@ -2303,7 +2306,7 @@ f(int Function() a, int b) {
elementMatcher(numElement.getMethod('remainder'),
isLegacy: isLegacyLibrary),
'num Function(num)',
expectedType: typeToStringWithNullability ? 'int' : 'num');
expectedType: typeStringByNullability(nullable: 'int', legacy: 'num'));
}
test_remainder_other_context_int_via_extension_explicit() async {