Files
sdk/tests/language_2/argument/not_enough_positional_arguments_test.dart
T
Robert Nystrom fc1b1ecc71 Move files under language_2 into subdirectories.
Change-Id: Idbcc965a27e9ffeedf5e0a1068b019de4193070f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127745
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2019-12-11 19:18:00 +00:00

73 lines
1.8 KiB
Dart

// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
foo(a, [b]) {}
bar(a, {b}) {}
class A {
A();
A.test(a, [b]);
}
class B {
B()
: super.test(b: 1)
//^^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER
// [cfe] Superclass has no constructor named 'Object.test'.
;
}
class C extends A {
C()
: super.test(b: 1)
// ^^^^^^
// [analyzer] COMPILE_TIME_ERROR.NOT_ENOUGH_POSITIONAL_ARGUMENTS
// [cfe] Too few positional arguments: 1 required, 0 given.
// ^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_NAMED_PARAMETER
;
}
class D {
D();
D.test(a, {b});
}
class E extends D {
E()
: super.test(b: 1)
// ^^^^^^
// [analyzer] COMPILE_TIME_ERROR.NOT_ENOUGH_POSITIONAL_ARGUMENTS
// [cfe] Too few positional arguments: 1 required, 0 given.
;
}
main() {
new A.test(b: 1);
// ^^^^^^
// [analyzer] COMPILE_TIME_ERROR.NOT_ENOUGH_POSITIONAL_ARGUMENTS
// [cfe] Too few positional arguments: 1 required, 0 given.
// ^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_NAMED_PARAMETER
new B();
new C();
new D.test(b: 1);
// ^^^^^^
// [analyzer] COMPILE_TIME_ERROR.NOT_ENOUGH_POSITIONAL_ARGUMENTS
// [cfe] Too few positional arguments: 1 required, 0 given.
new E();
foo(b: 1);
// ^^^^^^
// [analyzer] COMPILE_TIME_ERROR.NOT_ENOUGH_POSITIONAL_ARGUMENTS
// [cfe] Too few positional arguments: 1 required, 0 given.
// ^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_NAMED_PARAMETER
bar(b: 1);
// ^^^^^^
// [analyzer] COMPILE_TIME_ERROR.NOT_ENOUGH_POSITIONAL_ARGUMENTS
// [cfe] Too few positional arguments: 1 required, 0 given.
}