Skip to content

Commit

Permalink
#2162. Add static member and non-redirecting factory constructor conf…
Browse files Browse the repository at this point in the history
…lict test (#3056)
  • Loading branch information
sgrekhov authored Jan 27, 2025
1 parent 1d760c1 commit 3044f30
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
/// constructor named `C.n` and a static member with basename `n`.
///
/// @description Check that it is a compile-time error if class `C` declares a
/// factory constructor named `C.n` and a static member with basename `n`.
/// redirecting factory constructor named `C.n` and a static member with
/// basename `n`.
/// @author [email protected]
class C {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// 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 Let `C` be a class. It is a compile-time error if `C` declares a
/// constructor named `C.n` and a static member with basename `n`.
///
/// @description Check that it is a compile-time error if class `C` declares a
/// non-redirecting factory constructor named `C.n` and a static member with
/// basename `n`.
/// @author [email protected]
class C {
C();

factory C.s1() => C();
// ^^
// [analyzer] unspecified
static set s1(var value) {}
// ^^
// [cfe] unspecified

factory C.s2() => C();
// ^^
// [analyzer] unspecified
static void s2() {}
// ^^
// [cfe] unspecified

factory C.s3() => C();
// ^^
// [analyzer] unspecified
static int s3() => 1;
// ^^
// [cfe] unspecified

factory C.s4() => C();
// ^^
// [analyzer] unspecified
static int get s4 => 1;
// ^^
// [cfe] unspecified

factory C.s5() => C();
// ^^
// [analyzer] unspecified
static int s5 = 1;
// ^^
// [cfe] unspecified
}

extension type ET(int n) {
factory ET.s1(int n) => ET(n);
// ^^
// [analyzer] unspecified
static set s1(var _) {}
// ^^
// [cfe] unspecified

factory ET.s2(int n) => ET(n);
// ^^
// [analyzer] unspecified
static void s2() {}
// ^^
// [cfe] unspecified

factory ET.s3(int n) => ET(n);
// ^^
// [analyzer] unspecified
static int s3() => 1;
// ^^
// [cfe] unspecified

factory ET.s4(int n) => ET(n);
// ^^
// [analyzer] unspecified
static int get s4 => 1;
// ^^
// [cfe] unspecified

factory ET.s5(int n) => ET(n);
// ^^
// [analyzer] unspecified
static int s5 = 1;
// ^^
// [cfe] unspecified
}

main() {
print(C);
print(ET);
}

0 comments on commit 3044f30

Please sign in to comment.