[Analyzer] Report EXTRA_POSITIONAL_ARGUMENTS and EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED against first unmatched argument
Fixes #44598. Change-Id: I6bccf4f5448de024f27d0ed1ba51c730e22b6fe9 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/178020 Commit-Queue: Brian Wilkerson <brianwilkerson@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
committed by
commit-bot@chromium.org
parent
d5335340f4
commit
c818059287
@@ -12,10 +12,11 @@ import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
|
||||
class AddMissingParameter extends MultiCorrectionProducer {
|
||||
@override
|
||||
Iterable<CorrectionProducer> get producers sync* {
|
||||
if (node is! ArgumentList) {
|
||||
// node is the unmatched argument.
|
||||
if (node.parent is! ArgumentList) {
|
||||
return;
|
||||
}
|
||||
var context = ExecutableParameters(sessionHelper, node.parent);
|
||||
var context = ExecutableParameters(sessionHelper, node.parent.parent);
|
||||
if (context == null) {
|
||||
return;
|
||||
}
|
||||
@@ -65,7 +66,8 @@ abstract class _AddMissingParameter extends CorrectionProducer {
|
||||
|
||||
Future<void> _addParameter(
|
||||
ChangeBuilder builder, int offset, String prefix, String suffix) async {
|
||||
ArgumentList argumentList = node;
|
||||
// node is the unmatched argument.
|
||||
ArgumentList argumentList = node.parent;
|
||||
List<Expression> arguments = argumentList.arguments;
|
||||
var numRequired = context.required.length;
|
||||
if (numRequired >= arguments.length) {
|
||||
|
||||
+2
-1
@@ -16,7 +16,8 @@ class ConvertToNamedArguments extends CorrectionProducer {
|
||||
|
||||
@override
|
||||
Future<void> compute(ChangeBuilder builder) async {
|
||||
var argumentList = node;
|
||||
// node is the unmatched argument.
|
||||
var argumentList = node.parent;
|
||||
if (argumentList is ArgumentList) {
|
||||
// Prepare parameters.
|
||||
List<ParameterElement> parameters;
|
||||
|
||||
@@ -24,8 +24,10 @@ class CreateConstructor extends CorrectionProducer {
|
||||
|
||||
@override
|
||||
Future<void> compute(ChangeBuilder builder) async {
|
||||
if (node is ArgumentList && node.parent is InstanceCreationExpression) {
|
||||
await _proposeFromInstanceCreation(builder);
|
||||
final argumentList = node.parent is ArgumentList ? node.parent : node;
|
||||
if (argumentList is ArgumentList &&
|
||||
argumentList.parent is InstanceCreationExpression) {
|
||||
await _proposeFromInstanceCreation(builder, argumentList.parent);
|
||||
} else {
|
||||
await _proposeFromConstructorName(builder);
|
||||
}
|
||||
@@ -90,8 +92,8 @@ class CreateConstructor extends CorrectionProducer {
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _proposeFromInstanceCreation(ChangeBuilder builder) async {
|
||||
InstanceCreationExpression instanceCreation = node.parent;
|
||||
Future<void> _proposeFromInstanceCreation(ChangeBuilder builder,
|
||||
InstanceCreationExpression instanceCreation) async {
|
||||
_constructorName = instanceCreation.constructorName;
|
||||
// should be synthetic default constructor
|
||||
var constructorElement = _constructorName.staticElement;
|
||||
|
||||
@@ -82,6 +82,8 @@ class DataDriven extends MultiCorrectionProducer {
|
||||
return nameFromParent(node);
|
||||
} else if (node is ArgumentList) {
|
||||
return nameFromParent(node);
|
||||
} else if (node?.parent is ArgumentList) {
|
||||
return nameFromParent(node.parent);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -86,6 +86,8 @@ class TemplateContext {
|
||||
static AstNode _getInvocation(AstNode node) {
|
||||
if (node is ArgumentList) {
|
||||
return node.parent;
|
||||
} else if (node.parent is ArgumentList) {
|
||||
return node.parent.parent;
|
||||
} else if (node is InstanceCreationExpression ||
|
||||
node is InvocationExpression) {
|
||||
return node;
|
||||
|
||||
@@ -238,6 +238,9 @@ class ModifyParameters extends Change<_Data> {
|
||||
if (argumentList is ArgumentList) {
|
||||
return _Data(argumentList);
|
||||
}
|
||||
} else if (parent?.parent is InvocationExpression) {
|
||||
var argumentList = (parent.parent as InvocationExpression).argumentList;
|
||||
return _Data(argumentList);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -3445,7 +3445,7 @@ class CompileTimeErrorCode extends AnalyzerErrorCode {
|
||||
// ```dart
|
||||
// void f(int a, int b) {}
|
||||
// void g() {
|
||||
// f[!(1, 2, 3)!];
|
||||
// f(1, 2, [!3!]);
|
||||
// }
|
||||
// ```
|
||||
//
|
||||
@@ -3486,7 +3486,7 @@ class CompileTimeErrorCode extends AnalyzerErrorCode {
|
||||
// %language=2.9
|
||||
// void f(int a, int b, {int c}) {}
|
||||
// void g() {
|
||||
// f[!(1, 2, 3)!];
|
||||
// f(1, 2, [!3!]);
|
||||
// }
|
||||
// ```
|
||||
//
|
||||
|
||||
@@ -2215,7 +2215,8 @@ class ResolverVisitor extends ScopedVisitor {
|
||||
/// correspond to the list of arguments.
|
||||
///
|
||||
/// An error will be reported to [onError] if any of the arguments cannot be
|
||||
/// matched to a parameter. onError can be null to ignore the error.
|
||||
/// matched to a parameter. onError will be provided the node of the first
|
||||
/// argument that is not matched. onError can be null to ignore the error.
|
||||
///
|
||||
/// Returns the parameters that correspond to the arguments. If no parameter
|
||||
/// matched an argument, that position will be `null` in the list.
|
||||
@@ -2254,6 +2255,7 @@ class ResolverVisitor extends ScopedVisitor {
|
||||
int positionalArgumentCount = 0;
|
||||
HashSet<String> usedNames;
|
||||
bool noBlankArguments = true;
|
||||
Expression firstUnresolvedArgument;
|
||||
for (int i = 0; i < argumentCount; i++) {
|
||||
Expression argument = arguments[i];
|
||||
if (argument is NamedExpression) {
|
||||
@@ -2284,6 +2286,8 @@ class ResolverVisitor extends ScopedVisitor {
|
||||
positionalArgumentCount++;
|
||||
if (unnamedIndex < unnamedParameterCount) {
|
||||
resolvedParameters[i] = unnamedParameters[unnamedIndex++];
|
||||
} else {
|
||||
firstUnresolvedArgument ??= argument;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2304,7 +2308,7 @@ class ResolverVisitor extends ScopedVisitor {
|
||||
errorCode = CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS;
|
||||
}
|
||||
if (onError != null) {
|
||||
onError(errorCode, argumentList,
|
||||
onError(errorCode, firstUnresolvedArgument,
|
||||
[unnamedParameterCount, positionalArgumentCount]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1039,7 +1039,7 @@ class B extends A {
|
||||
CompileTimeErrorCode.UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_MEMBER,
|
||||
71,
|
||||
3),
|
||||
error(CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS, 74, 3),
|
||||
error(CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS, 75, 1),
|
||||
]);
|
||||
|
||||
assertMethodInvocation2(
|
||||
@@ -1348,7 +1348,7 @@ main() {
|
||||
}
|
||||
''', [
|
||||
error(HintCode.UNUSED_IMPORT, 7, 11),
|
||||
error(CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS, 65, 7),
|
||||
error(CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS, 66, 5),
|
||||
]);
|
||||
|
||||
var import = findElement.importFind('dart:math');
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:analyzer/src/error/codes.dart';
|
||||
import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode;
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import '../dart/resolution/context_collection_resolution.dart';
|
||||
@@ -26,8 +27,8 @@ main() {
|
||||
const A(0);
|
||||
}
|
||||
''', [
|
||||
error(CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED, 50,
|
||||
3),
|
||||
error(CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED, 51,
|
||||
1),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -40,8 +41,8 @@ class B extends A {
|
||||
const B() : super(0);
|
||||
}
|
||||
''', [
|
||||
error(CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED, 71,
|
||||
3),
|
||||
error(CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED, 72,
|
||||
1),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -51,8 +52,8 @@ main() {
|
||||
(int x, {int y}) {} (0, 1);
|
||||
}
|
||||
''', [
|
||||
error(CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED, 31,
|
||||
6),
|
||||
error(CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED, 35,
|
||||
1),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -63,8 +64,23 @@ main() {
|
||||
f(0, 1, '2');
|
||||
}
|
||||
''', [
|
||||
error(CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED, 25,
|
||||
11),
|
||||
error(CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED, 26,
|
||||
1),
|
||||
]);
|
||||
}
|
||||
|
||||
test_partiallyTypedName() async {
|
||||
await assertErrorsInCode(r'''
|
||||
f({int xx, int yy, int zz}) {}
|
||||
|
||||
main() {
|
||||
f(xx: 1, yy: 2, z);
|
||||
}
|
||||
''', [
|
||||
error(CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED, 59,
|
||||
1),
|
||||
error(ParserErrorCode.POSITIONAL_AFTER_NAMED_ARGUMENT, 59, 1),
|
||||
error(CompileTimeErrorCode.UNDEFINED_IDENTIFIER, 59, 1),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -80,7 +96,7 @@ main() {
|
||||
const A(0);
|
||||
}
|
||||
''', [
|
||||
error(CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS, 43, 3),
|
||||
error(CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS, 44, 1),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -93,7 +109,7 @@ class B extends A {
|
||||
const B() : super(0);
|
||||
}
|
||||
''', [
|
||||
error(CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS, 64, 3),
|
||||
error(CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS, 65, 1),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -103,7 +119,7 @@ main() {
|
||||
(int x) {} (0, 1);
|
||||
}
|
||||
''', [
|
||||
error(CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS, 22, 6),
|
||||
error(CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS, 26, 1),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -114,7 +130,7 @@ main() {
|
||||
f(0, 1, '2');
|
||||
}
|
||||
''', [
|
||||
error(CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS, 19, 11),
|
||||
error(CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS, 20, 1),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -324,7 +324,7 @@ void f(Never? x) {
|
||||
x.toString(1 + 2);
|
||||
}
|
||||
''', [
|
||||
error(CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS, 31, 7),
|
||||
error(CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS, 32, 5),
|
||||
]);
|
||||
|
||||
assertMethodInvocation(
|
||||
|
||||
@@ -2278,11 +2278,11 @@ main() {
|
||||
}
|
||||
''', [
|
||||
error(HintCode.UNUSED_LOCAL_VARIABLE, 71, 1),
|
||||
error(CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS, 117, 9),
|
||||
error(CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS, 137, 15),
|
||||
error(CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS, 124, 1),
|
||||
error(CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS, 148, 3),
|
||||
error(CompileTimeErrorCode.NOT_ENOUGH_POSITIONAL_ARGUMENTS, 159, 3),
|
||||
error(CompileTimeErrorCode.NOT_ENOUGH_POSITIONAL_ARGUMENTS, 173, 5),
|
||||
error(CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS, 189, 9),
|
||||
error(CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS, 196, 1),
|
||||
error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 190, 1),
|
||||
error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 193, 1),
|
||||
error(CompileTimeErrorCode.NOT_ENOUGH_POSITIONAL_ARGUMENTS, 209, 3),
|
||||
|
||||
@@ -689,7 +689,7 @@ main() {
|
||||
}
|
||||
''', [
|
||||
error(HintCode.UNUSED_LOCAL_VARIABLE, 29, 1),
|
||||
error(CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS, 38, 4),
|
||||
error(CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS, 39, 2),
|
||||
]);
|
||||
|
||||
var a = findLocalVariable(_resultUnit, 'a');
|
||||
|
||||
@@ -3149,7 +3149,7 @@ parameters but is invoked with 3 arguments:
|
||||
{% prettify dart tag=pre+code %}
|
||||
void f(int a, int b) {}
|
||||
void g() {
|
||||
f[!(1, 2, 3)!];
|
||||
f(1, 2, [!3!]);
|
||||
}
|
||||
{% endprettify %}
|
||||
|
||||
@@ -3183,7 +3183,7 @@ third argument:
|
||||
{% prettify dart tag=pre+code %}
|
||||
void f(int a, int b, {int c}) {}
|
||||
void g() {
|
||||
f[!(1, 2, 3)!];
|
||||
f(1, 2, [!3!]);
|
||||
}
|
||||
{% endprettify %}
|
||||
|
||||
|
||||
@@ -32,7 +32,8 @@ main() {
|
||||
// [analyzer] COMPILE_TIME_ERROR.NOT_ENOUGH_POSITIONAL_ARGUMENTS
|
||||
// [cfe] Too few positional arguments: 1 required, 0 given.
|
||||
c2(3, 4);
|
||||
//^^^^^^
|
||||
// ^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
|
||||
//^^^^^^
|
||||
// [cfe] Too many positional arguments: 1 allowed, but 2 found.
|
||||
}
|
||||
|
||||
@@ -15,8 +15,9 @@ main() {
|
||||
// [analyzer] COMPILE_TIME_ERROR.NOT_ENOUGH_POSITIONAL_ARGUMENTS
|
||||
// [cfe] Too few positional arguments: 1 required, 0 given.
|
||||
const A(1, 2);
|
||||
// ^^^^^^
|
||||
// ^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
|
||||
// ^^^^^^
|
||||
// [cfe] Too many positional arguments: 1 allowed, but 2 found.
|
||||
const A.named();
|
||||
const A.named(b: 1);
|
||||
@@ -34,7 +35,8 @@ main() {
|
||||
const A.optional();
|
||||
const A.optional(42);
|
||||
const A.optional(42, 54);
|
||||
// ^^^^^^^^
|
||||
// ^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
|
||||
// ^^^^^^^^
|
||||
// [cfe] Too many positional arguments: 1 allowed, but 2 found.
|
||||
}
|
||||
|
||||
@@ -16,7 +16,8 @@ main() {
|
||||
// [cfe] Too few positional arguments: 1 required, 0 given.
|
||||
new Klass(1);
|
||||
new Klass(1, 2);
|
||||
// ^^^^^^
|
||||
// ^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
|
||||
// ^^^^^^
|
||||
// [cfe] Too many positional arguments: 1 allowed, but 2 found.
|
||||
}
|
||||
|
||||
@@ -8,7 +8,8 @@ class A {
|
||||
|
||||
main() {
|
||||
new A(42);
|
||||
// ^^^^
|
||||
// ^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
|
||||
// ^^^^
|
||||
// [cfe] Too many positional arguments: 0 allowed, but 1 found.
|
||||
}
|
||||
|
||||
@@ -32,8 +32,9 @@ class A {
|
||||
// ^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.SUPER_IN_REDIRECTING_CONSTRUCTOR
|
||||
// [cfe] A redirecting constructor can't have other initializers.
|
||||
// ^^^
|
||||
// ^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
|
||||
// ^^^
|
||||
// [cfe] Too many positional arguments: 0 allowed, but 1 found.
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,6 @@ void main() {
|
||||
lib.loadLibrary(10);
|
||||
//^
|
||||
// [cfe] 'loadLibrary' takes no arguments.
|
||||
// ^^^^
|
||||
// ^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
|
||||
}
|
||||
|
||||
@@ -14,7 +14,8 @@ main() {
|
||||
var niederhorn = Niederhorn();
|
||||
niederhorn.goodCall(1, 2, 3);
|
||||
niederhorn.goodCall(1, 2, 3, 4);
|
||||
// ^^^^^^^^^^^^
|
||||
// ^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
|
||||
// ^^^^^^^^^^^^
|
||||
// [cfe] Too many positional arguments: 3 allowed, but 4 found.
|
||||
}
|
||||
|
||||
@@ -97,16 +97,18 @@ main() {
|
||||
new D6();
|
||||
|
||||
new C0(1,2,3);
|
||||
// ^^^^^^^
|
||||
// ^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
|
||||
// ^^^^^^^
|
||||
// [cfe] Too many positional arguments: 0 allowed, but 3 found.
|
||||
new C0.named();
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.NEW_WITH_UNDEFINED_CONSTRUCTOR
|
||||
// [cfe] Method not found: 'C0.named'.
|
||||
new D0(1,2,3);
|
||||
// ^^^^^^^
|
||||
// ^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
|
||||
// ^^^^^^^
|
||||
// [cfe] Too many positional arguments: 0 allowed, but 3 found.
|
||||
new D0.named();
|
||||
// ^^^^^
|
||||
|
||||
@@ -20,14 +20,16 @@ main() {
|
||||
|
||||
// Parameter b passed twice.
|
||||
np.f42(10, 25, b: 25);
|
||||
// ^^^^^^^^^^^^^^^
|
||||
// ^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED
|
||||
// ^^^^^^^^^^^^^^^
|
||||
// [cfe] Too many positional arguments: 1 allowed, but 2 found.
|
||||
|
||||
// Parameter x does not exist.
|
||||
np.f42(10, 25, x: 99);
|
||||
// ^^^^^^^^^^^^^^^
|
||||
// ^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED
|
||||
// ^^^^^^^^^^^^^^^
|
||||
// [cfe] Too many positional arguments: 1 allowed, but 2 found.
|
||||
// ^
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_NAMED_PARAMETER
|
||||
@@ -40,8 +42,9 @@ main() {
|
||||
|
||||
// Too many parameters.
|
||||
np.f42(10, 20, 30, 40);
|
||||
// ^^^^^^^^^^^^^^^^
|
||||
// ^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED
|
||||
// ^^^^^^^^^^^^^^^^
|
||||
// [cfe] Too many positional arguments: 1 allowed, but 4 found.
|
||||
|
||||
// Too few parameters.
|
||||
|
||||
@@ -37,8 +37,9 @@ class NamedParametersAggregatedTests {
|
||||
main() {
|
||||
// Expect compile-time error due to missing comma in function definition.
|
||||
NamedParametersAggregatedTests.f_missing_comma(10, 25);
|
||||
// ^^^^^^^^
|
||||
// ^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
|
||||
// ^^^^^^^^
|
||||
// [cfe] Too many positional arguments: 1 allowed, but 2 found.
|
||||
|
||||
// Expect compile-time error due to duplicate named argument.
|
||||
|
||||
@@ -63,36 +63,42 @@ class OptionalNamedParametersTest {
|
||||
Expect.equals(20, F10());
|
||||
Expect.equals(20, np.f21());
|
||||
Expect.equals(20, F10(20));
|
||||
// ^^^^
|
||||
// ^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED
|
||||
// ^^^^
|
||||
// [cfe] Too many positional arguments: 0 allowed, but 1 found.
|
||||
Expect.equals(20, np.f21(20));
|
||||
// ^^^^
|
||||
// ^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED
|
||||
// ^^^^
|
||||
// [cfe] Too many positional arguments: 0 allowed, but 1 found.
|
||||
Expect.equals(20, F10(b: 20));
|
||||
Expect.equals(20, np.f21(b: 20));
|
||||
Expect.equals(1020, F21(10));
|
||||
Expect.equals(1020, np.f32(10));
|
||||
Expect.equals(1025, F21(10, 25));
|
||||
// ^^^^^^^^
|
||||
// ^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED
|
||||
// ^^^^^^^^
|
||||
// [cfe] Too many positional arguments: 1 allowed, but 2 found.
|
||||
Expect.equals(1025, np.f32(10, 25));
|
||||
// ^^^^^^^^
|
||||
// ^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED
|
||||
// ^^^^^^^^
|
||||
// [cfe] Too many positional arguments: 1 allowed, but 2 found.
|
||||
Expect.equals(1025, F21(10, b: 25));
|
||||
Expect.equals(1025, np.f32(10, b: 25));
|
||||
Expect.equals(102030, F31(10));
|
||||
Expect.equals(102030, np.f42(10));
|
||||
Expect.equals(102530, F31(10, 25));
|
||||
// ^^^^^^^^
|
||||
// ^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED
|
||||
// ^^^^^^^^
|
||||
// [cfe] Too many positional arguments: 1 allowed, but 2 found.
|
||||
Expect.equals(102530, np.f42(10, 25));
|
||||
// ^^^^^^^^
|
||||
// ^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED
|
||||
// ^^^^^^^^
|
||||
// [cfe] Too many positional arguments: 1 allowed, but 2 found.
|
||||
Expect.equals(102530, F31(10, b: 25));
|
||||
Expect.equals(102530, np.f42(10, b: 25));
|
||||
@@ -101,12 +107,14 @@ class OptionalNamedParametersTest {
|
||||
Expect.equals(102535, F31(10, b: 25, c: 35));
|
||||
Expect.equals(102535, np.f42(10, b: 25, c: 35));
|
||||
Expect.equals(102535, F31(10, 25, c:35));
|
||||
// ^^^^^^^^^^^^^^
|
||||
// ^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED
|
||||
// ^^^^^^^^^^^^^^
|
||||
// [cfe] Too many positional arguments: 1 allowed, but 2 found.
|
||||
Expect.equals(102535, np.f42(10, 25, c:35));
|
||||
// ^^^^^^^^^^^^^^
|
||||
// ^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED
|
||||
// ^^^^^^^^^^^^^^
|
||||
// [cfe] Too many positional arguments: 1 allowed, but 2 found.
|
||||
Expect.equals(102535, F31(10, c: 35, b: 25));
|
||||
Expect.equals(102535, np.f42(10, c: 35, b: 25));
|
||||
@@ -116,8 +124,9 @@ class OptionalNamedParametersTest {
|
||||
Expect.equals(10203540, np.f52(10, c: 35));
|
||||
Expect.equals(10250045, F41(10, d: 45, b: 25));
|
||||
Expect.equals(10250045, F41(10, 25, d:45));
|
||||
// ^^^^^^^^^^^^^^
|
||||
// ^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED
|
||||
// ^^^^^^^^^^^^^^
|
||||
// [cfe] Too many positional arguments: 1 allowed, but 2 found.
|
||||
Expect.equals(10250045, np.f52(10, d: 45, b: 25));
|
||||
Expect.equals(10253545, F41(10, d: 45, c: 35, b: 25));
|
||||
|
||||
@@ -33,7 +33,8 @@ main() {
|
||||
Expect.equals(x.b, 0);
|
||||
|
||||
var y = new A.f(42, 43);
|
||||
// ^^^^^^^^
|
||||
// ^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
|
||||
// ^^^^^^^^
|
||||
// [cfe] Too many positional arguments: 1 allowed, but 2 found.
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ main() {
|
||||
new C(42);
|
||||
// ^
|
||||
// [cfe] Can't use 'C' because it is declared more than once.
|
||||
// ^^^^
|
||||
// ^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,8 @@ main() {
|
||||
Niesen.goodCall(1, 2, 3);
|
||||
|
||||
Niesen.goodCall(1, 2, 3, 4);
|
||||
// ^^^^^^^^^^^^
|
||||
// ^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
|
||||
// ^^^^^^^^^^^^
|
||||
// [cfe] Too many positional arguments: 3 allowed, but 4 found.
|
||||
}
|
||||
|
||||
@@ -32,7 +32,8 @@ main() {
|
||||
// [analyzer] COMPILE_TIME_ERROR.NOT_ENOUGH_POSITIONAL_ARGUMENTS
|
||||
// [cfe] Too few positional arguments: 1 required, 0 given.
|
||||
c2(3, 4);
|
||||
//^^^^^^
|
||||
// ^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
|
||||
//^^^^^^
|
||||
// [cfe] Too many positional arguments: 1 allowed, but 2 found.
|
||||
}
|
||||
|
||||
@@ -15,8 +15,9 @@ main() {
|
||||
// [analyzer] COMPILE_TIME_ERROR.NOT_ENOUGH_POSITIONAL_ARGUMENTS
|
||||
// [cfe] Too few positional arguments: 1 required, 0 given.
|
||||
const A(1, 2);
|
||||
// ^^^^^^
|
||||
// ^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
|
||||
// ^^^^^^
|
||||
// [cfe] Too many positional arguments: 1 allowed, but 2 found.
|
||||
const A.named();
|
||||
const A.named(b: 1);
|
||||
@@ -34,7 +35,8 @@ main() {
|
||||
const A.optional();
|
||||
const A.optional(42);
|
||||
const A.optional(42, 54);
|
||||
// ^^^^^^^^
|
||||
// ^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
|
||||
// ^^^^^^^^
|
||||
// [cfe] Too many positional arguments: 1 allowed, but 2 found.
|
||||
}
|
||||
|
||||
@@ -16,7 +16,8 @@ main() {
|
||||
// [cfe] Too few positional arguments: 1 required, 0 given.
|
||||
new Klass(1);
|
||||
new Klass(1, 2);
|
||||
// ^^^^^^
|
||||
// ^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
|
||||
// ^^^^^^
|
||||
// [cfe] Too many positional arguments: 1 allowed, but 2 found.
|
||||
}
|
||||
|
||||
@@ -8,7 +8,8 @@ class A {
|
||||
|
||||
main() {
|
||||
new A(42);
|
||||
// ^^^^
|
||||
// ^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
|
||||
// ^^^^
|
||||
// [cfe] Too many positional arguments: 0 allowed, but 1 found.
|
||||
}
|
||||
|
||||
@@ -32,8 +32,9 @@ class A {
|
||||
// ^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.SUPER_IN_REDIRECTING_CONSTRUCTOR
|
||||
// [cfe] A redirecting constructor can't have other initializers.
|
||||
// ^^^
|
||||
// ^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
|
||||
// ^^^
|
||||
// [cfe] Too many positional arguments: 0 allowed, but 1 found.
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,6 @@ void main() {
|
||||
lib.loadLibrary(10);
|
||||
//^
|
||||
// [cfe] 'loadLibrary' takes no arguments.
|
||||
// ^^^^
|
||||
// ^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
|
||||
}
|
||||
|
||||
@@ -14,7 +14,8 @@ main() {
|
||||
var niederhorn = Niederhorn();
|
||||
niederhorn.goodCall(1, 2, 3);
|
||||
niederhorn.goodCall(1, 2, 3, 4);
|
||||
// ^^^^^^^^^^^^
|
||||
// ^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
|
||||
// ^^^^^^^^^^^^
|
||||
// [cfe] Too many positional arguments: 3 allowed, but 4 found.
|
||||
}
|
||||
|
||||
@@ -97,16 +97,18 @@ main() {
|
||||
new D6();
|
||||
|
||||
new C0(1,2,3);
|
||||
// ^^^^^^^
|
||||
// ^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
|
||||
// ^^^^^^^
|
||||
// [cfe] Too many positional arguments: 0 allowed, but 3 found.
|
||||
new C0.named();
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.NEW_WITH_UNDEFINED_CONSTRUCTOR
|
||||
// [cfe] Method not found: 'C0.named'.
|
||||
new D0(1,2,3);
|
||||
// ^^^^^^^
|
||||
// ^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
|
||||
// ^^^^^^^
|
||||
// [cfe] Too many positional arguments: 0 allowed, but 3 found.
|
||||
new D0.named();
|
||||
// ^^^^^
|
||||
|
||||
@@ -20,14 +20,16 @@ main() {
|
||||
|
||||
// Parameter b passed twice.
|
||||
np.f42(10, 25, b: 25);
|
||||
// ^^^^^^^^^^^^^^^
|
||||
// ^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED
|
||||
// ^^^^^^^^^^^^^^^
|
||||
// [cfe] Too many positional arguments: 1 allowed, but 2 found.
|
||||
|
||||
// Parameter x does not exist.
|
||||
np.f42(10, 25, x: 99);
|
||||
// ^^^^^^^^^^^^^^^
|
||||
// ^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED
|
||||
// ^^^^^^^^^^^^^^^
|
||||
// [cfe] Too many positional arguments: 1 allowed, but 2 found.
|
||||
// ^
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_NAMED_PARAMETER
|
||||
@@ -40,8 +42,9 @@ main() {
|
||||
|
||||
// Too many parameters.
|
||||
np.f42(10, 20, 30, 40);
|
||||
// ^^^^^^^^^^^^^^^^
|
||||
// ^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED
|
||||
// ^^^^^^^^^^^^^^^^
|
||||
// [cfe] Too many positional arguments: 1 allowed, but 4 found.
|
||||
|
||||
// Too few parameters.
|
||||
|
||||
@@ -37,8 +37,9 @@ class NamedParametersAggregatedTests {
|
||||
main() {
|
||||
// Expect compile-time error due to missing comma in function definition.
|
||||
NamedParametersAggregatedTests.f_missing_comma(10, 25);
|
||||
// ^^^^^^^^
|
||||
// ^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
|
||||
// ^^^^^^^^
|
||||
// [cfe] Too many positional arguments: 1 allowed, but 2 found.
|
||||
|
||||
// Expect compile-time error due to duplicate named argument.
|
||||
|
||||
@@ -63,36 +63,42 @@ class OptionalNamedParametersTest {
|
||||
Expect.equals(20, F10());
|
||||
Expect.equals(20, np.f21());
|
||||
Expect.equals(20, F10(20));
|
||||
// ^^^^
|
||||
// ^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED
|
||||
// ^^^^
|
||||
// [cfe] Too many positional arguments: 0 allowed, but 1 found.
|
||||
Expect.equals(20, np.f21(20));
|
||||
// ^^^^
|
||||
// ^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED
|
||||
// ^^^^
|
||||
// [cfe] Too many positional arguments: 0 allowed, but 1 found.
|
||||
Expect.equals(20, F10(b: 20));
|
||||
Expect.equals(20, np.f21(b: 20));
|
||||
Expect.equals(1020, F21(10));
|
||||
Expect.equals(1020, np.f32(10));
|
||||
Expect.equals(1025, F21(10, 25));
|
||||
// ^^^^^^^^
|
||||
// ^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED
|
||||
// ^^^^^^^^
|
||||
// [cfe] Too many positional arguments: 1 allowed, but 2 found.
|
||||
Expect.equals(1025, np.f32(10, 25));
|
||||
// ^^^^^^^^
|
||||
// ^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED
|
||||
// ^^^^^^^^
|
||||
// [cfe] Too many positional arguments: 1 allowed, but 2 found.
|
||||
Expect.equals(1025, F21(10, b: 25));
|
||||
Expect.equals(1025, np.f32(10, b: 25));
|
||||
Expect.equals(102030, F31(10));
|
||||
Expect.equals(102030, np.f42(10));
|
||||
Expect.equals(102530, F31(10, 25));
|
||||
// ^^^^^^^^
|
||||
// ^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED
|
||||
// ^^^^^^^^
|
||||
// [cfe] Too many positional arguments: 1 allowed, but 2 found.
|
||||
Expect.equals(102530, np.f42(10, 25));
|
||||
// ^^^^^^^^
|
||||
// ^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED
|
||||
// ^^^^^^^^
|
||||
// [cfe] Too many positional arguments: 1 allowed, but 2 found.
|
||||
Expect.equals(102530, F31(10, b: 25));
|
||||
Expect.equals(102530, np.f42(10, b: 25));
|
||||
@@ -101,12 +107,14 @@ class OptionalNamedParametersTest {
|
||||
Expect.equals(102535, F31(10, b: 25, c: 35));
|
||||
Expect.equals(102535, np.f42(10, b: 25, c: 35));
|
||||
Expect.equals(102535, F31(10, 25, c:35));
|
||||
// ^^^^^^^^^^^^^^
|
||||
// ^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED
|
||||
// ^^^^^^^^^^^^^^
|
||||
// [cfe] Too many positional arguments: 1 allowed, but 2 found.
|
||||
Expect.equals(102535, np.f42(10, 25, c:35));
|
||||
// ^^^^^^^^^^^^^^
|
||||
// ^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED
|
||||
// ^^^^^^^^^^^^^^
|
||||
// [cfe] Too many positional arguments: 1 allowed, but 2 found.
|
||||
Expect.equals(102535, F31(10, c: 35, b: 25));
|
||||
Expect.equals(102535, np.f42(10, c: 35, b: 25));
|
||||
@@ -116,8 +124,9 @@ class OptionalNamedParametersTest {
|
||||
Expect.equals(10203540, np.f52(10, c: 35));
|
||||
Expect.equals(10250045, F41(10, d: 45, b: 25));
|
||||
Expect.equals(10250045, F41(10, 25, d:45));
|
||||
// ^^^^^^^^^^^^^^
|
||||
// ^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED
|
||||
// ^^^^^^^^^^^^^^
|
||||
// [cfe] Too many positional arguments: 1 allowed, but 2 found.
|
||||
Expect.equals(10250045, np.f52(10, d: 45, b: 25));
|
||||
Expect.equals(10253545, F41(10, d: 45, c: 35, b: 25));
|
||||
|
||||
@@ -33,7 +33,8 @@ main() {
|
||||
Expect.equals(x.b, 0);
|
||||
|
||||
var y = new A.f(42, 43);
|
||||
// ^^^^^^^^
|
||||
// ^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
|
||||
// ^^^^^^^^
|
||||
// [cfe] Too many positional arguments: 1 allowed, but 2 found.
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ main() {
|
||||
new C(42);
|
||||
// ^
|
||||
// [cfe] Can't use 'C' because it is declared more than once.
|
||||
// ^^^^
|
||||
// ^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,8 @@ main() {
|
||||
Niesen.goodCall(1, 2, 3);
|
||||
|
||||
Niesen.goodCall(1, 2, 3, 4);
|
||||
// ^^^^^^^^^^^^
|
||||
// ^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
|
||||
// ^^^^^^^^^^^^
|
||||
// [cfe] Too many positional arguments: 3 allowed, but 4 found.
|
||||
}
|
||||
|
||||
@@ -47,6 +47,6 @@ main() {
|
||||
foo.bar.add(4, 5, 10);
|
||||
// ^
|
||||
// [cfe] Error: Too many positional arguments: 2 allowed, but 3 found.
|
||||
// ^^^^^^^^^^
|
||||
// ^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
|
||||
}
|
||||
|
||||
@@ -47,6 +47,6 @@ main() {
|
||||
foo.bar.add(4, 5, 10);
|
||||
// ^
|
||||
// [cfe] Error: Too many positional arguments: 2 allowed, but 3 found.
|
||||
// ^^^^^^^^^^
|
||||
// ^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user