Merge remote-tracking branch 'remotes/origin/weak-reference-fix'
diff --git a/Language/Enums/syntax_t08.dart b/Language/Enums/syntax_t08.dart
index fe25a56..719fd1d 100644
--- a/Language/Enums/syntax_t08.dart
+++ b/Language/Enums/syntax_t08.dart
@@ -20,6 +20,4 @@
main() {
E e = E.b;
-// ^
-// [cfe] unspecified
}
diff --git a/Language/Enums/syntax_t09.dart b/Language/Enums/syntax_t09.dart
index a4e4694..20240e6 100644
--- a/Language/Enums/syntax_t09.dart
+++ b/Language/Enums/syntax_t09.dart
@@ -19,6 +19,4 @@
main() {
E e = E.b;
-// ^
-// [cfe] unspecified
}
diff --git a/Language/Functions/Formal_Parameters/Optional_Formals/syntax_t12.dart b/Language/Functions/Formal_Parameters/Optional_Formals/syntax_t12.dart
index 9486942..e558463 100644
--- a/Language/Functions/Formal_Parameters/Optional_Formals/syntax_t12.dart
+++ b/Language/Functions/Formal_Parameters/Optional_Formals/syntax_t12.dart
@@ -14,14 +14,11 @@
/// brackets are mixed in an optional parameters declaration.
/// @author rodionov
-
foo({const p: 1]) {
// ^
// [analyzer] unspecified
// [cfe] unspecified
p = 1;
-//^
-// [cfe] unspecified
}
main() {
diff --git a/Language/Functions/Formal_Parameters/Required_Formals/syntax_t03.dart b/Language/Functions/Formal_Parameters/Required_Formals/syntax_t03.dart
index 465287b..b23f89d 100644
--- a/Language/Functions/Formal_Parameters/Required_Formals/syntax_t03.dart
+++ b/Language/Functions/Formal_Parameters/Required_Formals/syntax_t03.dart
@@ -27,14 +27,11 @@
/// declared as const
/// @author msyabro
-
func(const x) {
// ^
// [analyzer] unspecified
// [cfe] unspecified
x = 1;
-//^
-// [cfe] unspecified
}
main() {
diff --git a/LanguageFeatures/Enhanced-Enum/implementing_enum_A04_t25.dart b/LanguageFeatures/Enhanced-Enum/implementing_enum_A04_t25.dart
new file mode 100644
index 0000000..b621bb6
--- /dev/null
+++ b/LanguageFeatures/Enhanced-Enum/implementing_enum_A04_t25.dart
@@ -0,0 +1,49 @@
+// Copyright (c) 2022, 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 It’s currently a compile-time error for a class to implement,
+/// extend or mix-in the Enum class.
+///
+/// Because we want to allow interfaces and mixins that are intended to be
+/// applied to enum declarations, and therefore to assume Enum to be a
+/// superclass, we loosen that restriction to:
+/// ...
+/// It's a compile-time error if a class or mixin declaration has Enum as a
+/// superinterface, and that class or mixin declares or inherits a concrete
+/// instance member named `index`, `hashCode` or `==` (an `operator ==`
+/// declaration). That `index` member could override the `index` getter
+/// inherited from `Enum`, and we currently do not allow that. The `hashCode`
+/// and `operator ==` declarations would prevent the enum class from having
+/// "primitive equality", and we want to ensure that enums can be used in
+/// switches.
+///
+/// @description Check that it's a compile-time error if a class declaration has
+/// Enum as a superinterface, and it declares a non-abstract instance member
+/// named `operator ==`.
+/// @author sgrekhov@unipro.ru
+
+// SharedOptions=--enable-experiment=enhanced-enums
+
+abstract class E1 extends Enum {
+ bool operator ==(Object other) {
+// ^^^^^^^^^^^
+// [analyzer] unspecified
+// [cfe] unspecified
+ return true;
+ }
+}
+
+abstract class E2 extends Enum {
+ bool operator ==(covariant E2 other) {
+// ^^^^^^^^^^^
+// [analyzer] unspecified
+// [cfe] unspecified
+ return false;
+ }
+}
+
+main() {
+ print(E1);
+ print(E2);
+}
diff --git a/LanguageFeatures/Enhanced-Enum/implementing_enum_A04_t26.dart b/LanguageFeatures/Enhanced-Enum/implementing_enum_A04_t26.dart
new file mode 100644
index 0000000..b397111
--- /dev/null
+++ b/LanguageFeatures/Enhanced-Enum/implementing_enum_A04_t26.dart
@@ -0,0 +1,56 @@
+// Copyright (c) 2022, 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 It’s currently a compile-time error for a class to implement,
+/// extend or mix-in the Enum class.
+///
+/// Because we want to allow interfaces and mixins that are intended to be
+/// applied to enum declarations, and therefore to assume Enum to be a
+/// superclass, we loosen that restriction to:
+/// ...
+/// It's a compile-time error if a class or mixin declaration has Enum as a
+/// superinterface, and that class or mixin declares or inherits a concrete
+/// instance member named `index`, `hashCode` or `==` (an `operator ==`
+/// declaration). That `index` member could override the `index` getter
+/// inherited from `Enum`, and we currently do not allow that. The `hashCode`
+/// and `operator ==` declarations would prevent the enum class from having
+/// "primitive equality", and we want to ensure that enums can be used in
+/// switches.
+///
+/// @description Check that it's a compile-time error if an enum declaration has
+/// Enum as a superinterface, and it declares a non-abstract instance member
+/// named `operator ==`.
+/// @author sgrekhov@unipro.ru
+
+// SharedOptions=--enable-experiment=enhanced-enums
+
+enum E1 {
+ e1,
+ e2;
+
+ bool operator ==(Object other) {
+// ^^^^^^^^^^^
+// [analyzer] unspecified
+// [cfe] unspecified
+ return true;
+ }
+}
+
+enum E2 {
+ e1(42),
+ e2(0);
+
+ const E2(int i);
+ bool operator ==(covariant E2 other) {
+// ^^^^^^^^^^^
+// [analyzer] unspecified
+// [cfe] unspecified
+ return false;
+ }
+}
+
+main() {
+ print(E1);
+ print(E2);
+}
diff --git a/LanguageFeatures/Enhanced-Enum/implementing_enum_A04_t27.dart b/LanguageFeatures/Enhanced-Enum/implementing_enum_A04_t27.dart
new file mode 100644
index 0000000..c45e1cc
--- /dev/null
+++ b/LanguageFeatures/Enhanced-Enum/implementing_enum_A04_t27.dart
@@ -0,0 +1,49 @@
+// Copyright (c) 2022, 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 It’s currently a compile-time error for a class to implement,
+/// extend or mix-in the Enum class.
+///
+/// Because we want to allow interfaces and mixins that are intended to be
+/// applied to enum declarations, and therefore to assume Enum to be a
+/// superclass, we loosen that restriction to:
+/// ...
+/// It's a compile-time error if a class or mixin declaration has Enum as a
+/// superinterface, and that class or mixin declares or inherits a concrete
+/// instance member named `index`, `hashCode` or `==` (an `operator ==`
+/// declaration). That `index` member could override the `index` getter
+/// inherited from `Enum`, and we currently do not allow that. The `hashCode`
+/// and `operator ==` declarations would prevent the enum class from having
+/// "primitive equality", and we want to ensure that enums can be used in
+/// switches.
+///
+/// @description Check that it's a compile-time error if a mixin declaration has
+/// Enum as a superinterface, and it declares a non-abstract instance member
+/// named `operator ==`.
+/// @author sgrekhov@unipro.ru
+
+// SharedOptions=--enable-experiment=enhanced-enums
+
+mixin M1 on Enum {
+ bool operator ==(Object other) {
+// ^^^^^^^^^^^
+// [analyzer] unspecified
+// [cfe] unspecified
+ return true;
+ }
+}
+
+mixin M2 on Enum {
+ bool operator ==(covariant E2 other) {
+// ^^^^^^^^^^^
+// [analyzer] unspecified
+// [cfe] unspecified
+ return false;
+ }
+}
+
+main() {
+ print(M1);
+ print(M2);
+}
diff --git a/LanguageFeatures/Enhanced-Enum/semantics_A10_t05.dart b/LanguageFeatures/Enhanced-Enum/semantics_A10_t05.dart
index 9af14d3..8ae29c5 100644
--- a/LanguageFeatures/Enhanced-Enum/semantics_A10_t05.dart
+++ b/LanguageFeatures/Enhanced-Enum/semantics_A10_t05.dart
@@ -25,9 +25,6 @@
e3;
String toString([int index = 0]) => "E1";
- bool operator ==(covariant E1 other) {
- return true;
- }
}
enum E2<T> {
@@ -38,25 +35,13 @@
const E2(T t);
String toString([int index = 0]) => "E2";
- bool operator ==(covariant E2 other) {
- return false;
- }
}
main() {
Expect.equals("E1", E1.e1.toString());
Expect.equals("E1", E1.e2.toString(1));
Expect.equals("E1", E1.e3.toString());
- Expect.isTrue(E1.e1 == E1.e2);
- Expect.isTrue(E1.e1 == E1.e3);
- Expect.isTrue(E1.e3 == E1.e2);
Expect.equals("E2", E2.e1.toString());
Expect.equals("E2", E2.e2.toString(1));
Expect.equals("E2", E2.e3.toString());
- Expect.isFalse(E2.e1 == E2.e2);
- Expect.isFalse(E2.e1 == E2.e3);
- Expect.isFalse(E2.e3 == E2.e2);
- Expect.isFalse(E2.e1 == E2.e1);
- Expect.isFalse(E2.e2 == E2.e2);
- Expect.isFalse(E2.e3 == E2.e3);
}
diff --git a/LanguageFeatures/FinalizationRegistry/ffi/Finalizer/attach_A06_t01.dart b/LanguageFeatures/FinalizationRegistry/ffi/Finalizer/attach_A06_t01.dart
index 9055584..a642c30 100644
--- a/LanguageFeatures/FinalizationRegistry/ffi/Finalizer/attach_A06_t01.dart
+++ b/LanguageFeatures/FinalizationRegistry/ffi/Finalizer/attach_A06_t01.dart
@@ -17,10 +17,11 @@
Nonce(this.value);
}
-final finalizerTokens = <String>{};
-
+final finalizerTokens = <String>[];
+int count = 0;
final Finalizer finalizer = Finalizer((token) {
finalizerTokens.add(token);
+ count++;
});
@pragma('vm:never-inline')
@@ -35,5 +36,8 @@
attachToFinalizer(Nonce(1), Nonce(2), Nonce(3));
await triggerGcWithDelay();
- Expect.setEquals({"Finalization token"}, finalizerTokens);
+ Expect.listEquals(
+ ["Finalization token", "Finalization token", "Finalization token"],
+ finalizerTokens);
+ Expect.equals(3, count);
}
diff --git a/LanguageFeatures/FinalizationRegistry/ffi/Finalizer/attach_A06_t02.dart b/LanguageFeatures/FinalizationRegistry/ffi/Finalizer/attach_A06_t02.dart
index ef7e187..48b52ed 100644
--- a/LanguageFeatures/FinalizationRegistry/ffi/Finalizer/attach_A06_t02.dart
+++ b/LanguageFeatures/FinalizationRegistry/ffi/Finalizer/attach_A06_t02.dart
@@ -18,11 +18,17 @@
}
final finalizerTokens = <String>{};
-int cnt = 0;
+int count = 0;
final Finalizer finalizer = Finalizer((token) {
- cnt++;
- finalizerTokens.add(token);
+ if (count >= 0) {
+ if (finalizerTokens.contains(token)) {
+ count = -1;
+ } else {
+ finalizerTokens.add(token);
+ count++;
+ }
+ }
});
@pragma('vm:never-inline')
@@ -36,13 +42,10 @@
main() async {
Nonce token = Nonce(1);
attachToFinalizer(token);
- for (int i = 0; i < 5; i++) {
- await triggerGcWithDelay();
- Expect.setEquals({
- "Finalization token 1",
- "Finalization token 2",
- "Finalization token 3"
- }, finalizerTokens);
- }
- Expect.equals(1, cnt);
+
+ await triggerGcWithDelay();
+ Expect.setEquals(
+ {"Finalization token 1", "Finalization token 2", "Finalization token 3"},
+ finalizerTokens);
+ Expect.equals(3, count);
}
diff --git a/LanguageFeatures/FinalizationRegistry/ffi/Finalizer/attach_A06_t03.dart b/LanguageFeatures/FinalizationRegistry/ffi/Finalizer/attach_A06_t03.dart
index 0d1da1c..ac45f23 100644
--- a/LanguageFeatures/FinalizationRegistry/ffi/Finalizer/attach_A06_t03.dart
+++ b/LanguageFeatures/FinalizationRegistry/ffi/Finalizer/attach_A06_t03.dart
@@ -30,11 +30,11 @@
finalizer.attach(value, "Token 1", detach: token1);
finalizer.attach(value, "Token 2", detach: token2);
finalizer.attach(value, "Token 3", detach: token3);
- finalizer.attach(value, "Token 1", detach: token1);
+ finalizer.attach(value, "Token 1", detach: token3);
finalizer.attach(value, "Token 2", detach: token2);
- finalizer.attach(value, "Token 3", detach: token3);
- finalizer.attach(value, "Token 1", detach: token1);
- finalizer.attach(value, "Token 2", detach: token2);
+ finalizer.attach(value, "Token 3", detach: token1);
+ finalizer.attach(value, "Token 1", detach: token2);
+ finalizer.attach(value, "Token 2", detach: token1);
finalizer.attach(value, "Token 3", detach: token3);
}
diff --git a/LanguageFeatures/FinalizationRegistry/ffi/Finalizer/throw_A01_t01.dart b/LanguageFeatures/FinalizationRegistry/ffi/Finalizer/throw_A01_t01.dart
new file mode 100644
index 0000000..9bcd2d1
--- /dev/null
+++ b/LanguageFeatures/FinalizationRegistry/ffi/Finalizer/throw_A01_t01.dart
@@ -0,0 +1,37 @@
+// Copyright (c) 2022, 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 Finalization callbacks must not throw.
+///
+/// @description Checks that all exceptions thrown by finalization callbacks are
+/// ignored
+/// @author sgrekhov@unipro.ru
+
+import '../../gc_utils_lib.dart';
+import '../../../../Utils/expect.dart';
+
+int count = 0;
+String? returnedToken = null;
+
+final Finalizer finalizer = Finalizer((token) {
+ count++;
+ if (token == "throw") {
+ throw Exception("Some exception");
+ }
+ returnedToken = token;
+});
+
+@pragma('vm:never-inline')
+void attachToFinalizer() {
+ var o = Object();
+ finalizer.attach(o, "throw");
+ finalizer.attach(o, "Don't throw");
+}
+
+main() async {
+ attachToFinalizer();
+ await triggerGcWithDelay();
+ Expect.equals("Don't throw", returnedToken);
+ Expect.equals(2, count);
+}