-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#2162. Add static member and non-redirecting factory constructor conf…
…lict test (#3056)
- Loading branch information
Showing
2 changed files
with
94 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 { | ||
|
92 changes: 92 additions & 0 deletions
92
Language/Classes/Class_Member_Conflicts/static_member_and_constructor_t05.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |