blob: 7cb2cdff29afd5673df4435c60d468bd759213c1 [file] [log] [blame]
// Copyright (c) 2011, 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.
//
// Dart test program for testing optional named parameters in type tests.
main() {
Function anyFunction;
void acceptFunNumOptBool(void funNumOptBool(num n, {bool b})) {}
;
void funNum(num n) {}
;
void funNumBool(num n, bool b) {}
;
void funNumOptBool(num n, {bool b: true}) {}
;
void funNumOptBoolX(num n, {bool x: true}) {}
;
anyFunction = funNum;
anyFunction = funNumBool;
anyFunction = funNumOptBool;
anyFunction = funNumOptBoolX;
acceptFunNumOptBool(funNumOptBool);
acceptFunNumOptBool(funNum);
// ^^^^^^
// [analyzer] COMPILE_TIME_ERROR.INVALID_CAST_FUNCTION
// [cfe] The local function has type 'void Function(num)' that isn't of expected type 'void Function(num, {bool b})'.
acceptFunNumOptBool(funNumBool);
// ^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
// [cfe] The argument type 'void Function(num, bool)' can't be assigned to the parameter type 'void Function(num, {bool b})'.
acceptFunNumOptBool(funNumOptBoolX);
// ^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
// [cfe] The argument type 'void Function(num, {bool x})' can't be assigned to the parameter type 'void Function(num, {bool b})'.
}