blob: 5b9d64e6e495216d0e6e6561fcfb156b62e5ea33 [file] [edit]
// Copyright (c) 2025, 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.
/// @assertion Given a named initializing formal or field parameter (for a
/// primary constructor) with private name `p` in constructor `C`:
/// - If `p` has no corresponding public name `n`, then compile-time error.
///
/// @description Check that it is a compile-time error if a named formal
/// parameter of a primary constructor has a private name with no corresponding
/// public name.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=private-named-parameters,primary-constructors
class C1({var String __p}) {
// ^^^
// [analyzer] unspecified
// [cfe] unspecified
}
class C2({required final String _1}) {
// ^^
// [analyzer] unspecified
// [cfe] unspecified
}
enum E1({required final String __p}) {
// ^^^
// [analyzer] unspecified
// [cfe] unspecified
e0(_p: "");
// ^^
// [analyzer] unspecified
// [cfe] unspecified
}
enum E2({final String _1 = ""}) {
// ^^
// [analyzer] unspecified
// [cfe] unspecified
e0;
}
main() {
print(C1);
print(C2);
print(E1);
print(E2);
}