blob: ac17733a8e7f5baf1fada37e34fce7e1d4a855ad [file]
// 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 A compile-time error occurs if a class, mixin class, enum, or
/// extension type has a primary constructor whose name is also the name of a
/// constructor declared in the body, or if it declares a primary constructor
/// whose name is `C.n`, and the body declares a static member whose basename is
/// `n`.
///
/// @description Check that it is a compile-time error if an extension type has
/// a primary constructor whose name is `C.n`, and the body declares a static
/// member whose basename is `n`.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=primary-constructors
extension type ET1.someName(int _) {
// ^^^^^^^^
// [analyzer] unspecified
static int someName = 0;
// ^^^^^^^^
// [cfe] unspecified
}
extension type ET2.someName(int _) {
// ^^^^^^^^
// [analyzer] unspecified
static int get someName => 0;
// ^^^^^^^^
// [cfe] unspecified
}
extension type ET3._someName(int _) {
// ^^^^^^^^^
// [analyzer] unspecified
static void _someName(int _) {}
// ^^^^^^^^^
// [cfe] unspecified
}
extension type ET4.someName(int _) {
// ^^^^^^^^
// [analyzer] unspecified
static void set someName(int _) {}
// ^^^^^^^^
// [cfe] unspecified
}
main() {
print(ET1);
print(ET2);
print(ET3);
print(ET4);
}