#1205. Static methods equality tests fixed
diff --git a/LanguageFeatures/Constructor-tear-offs/equality_A03_t02.dart b/LanguageFeatures/Constructor-tear-offs/equality_A03_t02.dart
index 755674a..7e201a4 100644
--- a/LanguageFeatures/Constructor-tear-offs/equality_A03_t02.dart
+++ b/LanguageFeatures/Constructor-tear-offs/equality_A03_t02.dart
@@ -4,34 +4,23 @@
/// @assertion Test equality of function and methods tearoffs.
///
-/// @description Checks equality of local non-generic functions
+/// @description Checks that the equality properties of any function object
+/// obtained by generic function instantiation is determined by the equality of
+/// the source function objects
/// @author sgrekhov@unipro.ru
+/// @issue 47317
// SharedOptions=--enable-experiment=constructor-tearoffs
import "../../Utils/expect.dart";
-var g;
-
main() {
- int localFunction1() => 42;
+ X localFunction<X>(X x) => x;
- var f1 = localFunction1;
- g = localFunction1;
- Expect.equals(f1, g);
- Expect.identical(f1, g);
- {
- int localFunction2() => 42;
- var f2 = localFunction2;
- g = localFunction2;
- Expect.equals(f2, g);
- Expect.identical(f2, g);
- }
- {
- int localFunction3() => 42;
- f1 = localFunction3;
- g = localFunction3;
- }
- Expect.equals(f1, g);
- Expect.identical(f1, g);
+ var f1_1 = localFunction;
+ var f1_2 = localFunction;
+ int Function(int) f2_1 = f1_1;
+ int Function(int) f2_2 = f1_2;
+
+ Expect.equals(f1_1 == f1_2, f2_1 == f2_2);
}
diff --git a/LanguageFeatures/Constructor-tear-offs/equality_A03_t03.dart b/LanguageFeatures/Constructor-tear-offs/equality_A03_t03.dart
index 07e83f4..01235fc 100644
--- a/LanguageFeatures/Constructor-tear-offs/equality_A03_t03.dart
+++ b/LanguageFeatures/Constructor-tear-offs/equality_A03_t03.dart
@@ -12,25 +12,13 @@
import "../../Utils/expect.dart";
-var g1;
-var g2;
+Function foo(String message) {
+ int g() => message.length;
+ return g;
+}
main() {
- X localFunction1<X>(X x) => x;
- X localFunction2<X>(X x) => x;
-
- var f1_1 = localFunction1<int>;
- var f1_2 = localFunction1<int>;
- var f2 = localFunction2<int>;
-
- Expect.notEquals(f1_1, f1_2);
- Expect.notEquals(f2, f1_1);
- Expect.notEquals(f2, f1_2);
-
- g1 = localFunction1<int>;
- g2 = localFunction1<int>;
-
- Expect.notEquals(g1, g2);
- Expect.notEquals(g1, f1_1);
- Expect.notEquals(g2, f1_2);
+ var f1 = foo("1");
+ var f2 = foo("123");
+ Expect.notEquals(f1, f2);
}
diff --git a/LanguageFeatures/Constructor-tear-offs/equality_A03_t04.dart b/LanguageFeatures/Constructor-tear-offs/equality_A03_t04.dart
deleted file mode 100644
index 558acea..0000000
--- a/LanguageFeatures/Constructor-tear-offs/equality_A03_t04.dart
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (c) 2021, 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 Test equality of function and methods tearoffs.
-/// https://github.com/dart-lang/language/issues/1712
-///
-/// @description Checks equality of instantiated local generic functions
-/// @author sgrekhov@unipro.ru
-
-// SharedOptions=--enable-experiment=constructor-tearoffs
-
-import "../../Utils/expect.dart";
-
-typedef X Foo<X>(X x);
-
-Foo getFoo() {
- X localFunction<X>(X x) => x;
- return localFunction;
-}
-
-Foo<int> getIntFoo() {
- X localFunction<X>(X x) => x;
- return localFunction<int>;
-}
-
-var g1 = getFoo();
-var g2 = getFoo();
-var ig1 = getIntFoo();
-var ig2 = getIntFoo();
-
-main() {
- Expect.notEquals(g1, g2);
- Expect.notEquals(ig1, ig2);
- Expect.notEquals(ig1, g1);
-}
diff --git a/LanguageFeatures/Constructor-tear-offs/equality_A04_t01.dart b/LanguageFeatures/Constructor-tear-offs/equality_A04_t01.dart
new file mode 100644
index 0000000..27766fd
--- /dev/null
+++ b/LanguageFeatures/Constructor-tear-offs/equality_A04_t01.dart
@@ -0,0 +1,34 @@
+// Copyright (c) 2021, 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 Test equality of function and methods tearoffs.
+/// https://github.com/dart-lang/language/issues/1712
+///
+/// @description Checks equality of non-generic static methods tearoffs
+/// @author sgrekhov@unipro.ru
+
+// SharedOptions=--enable-experiment=constructor-tearoffs
+
+import "../../Utils/expect.dart";
+
+class C {
+ static void foo1() {}
+ static void foo2() {}
+}
+
+main() {
+ const c1 = C.foo1;
+ const c2 = C.foo1;
+ const c3 = C.foo2;
+ var v1 = C.foo1;
+ var v2 = C.foo1;
+ var v3 = C.foo2;
+
+ const CheckIdentical(c1, c2);
+ Expect.notEquals(c3, c1);
+ Expect.equals(c1, v1);
+ Expect.identical(v1, v2);
+ Expect.identical(c3, v3);
+ Expect.notEquals(v1, v3);
+}
diff --git a/LanguageFeatures/Constructor-tear-offs/equality_A04_t02.dart b/LanguageFeatures/Constructor-tear-offs/equality_A04_t02.dart
new file mode 100644
index 0000000..1c0f345
--- /dev/null
+++ b/LanguageFeatures/Constructor-tear-offs/equality_A04_t02.dart
@@ -0,0 +1,34 @@
+// Copyright (c) 2021, 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 Test equality of function and methods tearoffs.
+/// https://github.com/dart-lang/language/issues/1712
+///
+/// @description Checks equality of instantiated generic static methods tearoffs
+/// @author sgrekhov@unipro.ru
+
+// SharedOptions=--enable-experiment=constructor-tearoffs
+
+import "../../Utils/expect.dart";
+
+class C {
+ static X foo1<X>(X x) => x;
+ static X foo2<X>(X x) => x;
+}
+
+main() {
+ const c1 = C.foo1;
+ const c2 = C.foo1;
+ const c3 = C.foo2;
+ var v1 = C.foo1;
+ var v2 = C.foo1;
+ var v3 = C.foo2;
+
+ const CheckIdentical(c1, c2);
+ Expect.notEquals(c3, c1);
+ Expect.equals(c1, v1);
+ Expect.identical(v1, v2);
+ Expect.identical(c3, v3);
+ Expect.notEquals(v1, v3);
+}
diff --git a/LanguageFeatures/Constructor-tear-offs/equality_A04_t03.dart b/LanguageFeatures/Constructor-tear-offs/equality_A04_t03.dart
new file mode 100644
index 0000000..cac5b15
--- /dev/null
+++ b/LanguageFeatures/Constructor-tear-offs/equality_A04_t03.dart
@@ -0,0 +1,34 @@
+// Copyright (c) 2021, 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 Test equality of function and methods tearoffs.
+/// https://github.com/dart-lang/language/issues/1712
+///
+/// @description Checks equality of instantiated generic static methods tearoffs
+/// @author sgrekhov@unipro.ru
+
+// SharedOptions=--enable-experiment=constructor-tearoffs
+
+import "../../Utils/expect.dart";
+
+class C {
+ static X foo1<X>(X x) => x;
+ static X foo2<X>(X x) => x;
+}
+
+main() {
+ const c1 = C.foo1<int>;
+ const c2 = C.foo1<int>;
+ const c3 = C.foo2<int>;
+ var v1 = C.foo1<int>;
+ var v2 = C.foo1<int>;
+ var v3 = C.foo2<int>;
+
+ const CheckIdentical(c1, c2);
+ Expect.notEquals(c3, c1);
+ Expect.equals(c1, v1);
+ Expect.identical(v1, v2);
+ Expect.identical(c3, v3);
+ Expect.notEquals(v1, v3);
+}
diff --git a/LanguageFeatures/Constructor-tear-offs/equality_A04_t04.dart b/LanguageFeatures/Constructor-tear-offs/equality_A04_t04.dart
new file mode 100644
index 0000000..b5cfc67
--- /dev/null
+++ b/LanguageFeatures/Constructor-tear-offs/equality_A04_t04.dart
@@ -0,0 +1,27 @@
+// Copyright (c) 2021, 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 Test equality of function and methods tearoffs.
+/// https://github.com/dart-lang/language/issues/1712
+///
+/// @description Checks equality of instantiated generic static methods tearoffs
+/// @author sgrekhov@unipro.ru
+
+// SharedOptions=--enable-experiment=constructor-tearoffs
+
+import "../../Utils/expect.dart";
+
+class C {
+ static X foo1<X>(X x) => x;
+ static X foo2<X>(X x) => x;
+}
+
+main() {
+ var v1 = C.foo1<int>;
+ int Function(int) v2 = C.foo1;
+ var v3 = C.foo2<int>;
+
+ Expect.identical(v1, v2);
+ Expect.notEquals(v1, v3);
+}
diff --git a/LanguageFeatures/Constructor-tear-offs/equality_A04_t05.dart b/LanguageFeatures/Constructor-tear-offs/equality_A04_t05.dart
new file mode 100644
index 0000000..b7dc3eb
--- /dev/null
+++ b/LanguageFeatures/Constructor-tear-offs/equality_A04_t05.dart
@@ -0,0 +1,28 @@
+// Copyright (c) 2021, 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 Test equality of function and methods tearoffs.
+/// https://github.com/dart-lang/language/issues/1712
+///
+/// @description Checks equality of instantiated generic static methods tearoffs
+/// @author sgrekhov@unipro.ru
+
+// SharedOptions=--enable-experiment=constructor-tearoffs
+
+import "../../Utils/expect.dart";
+
+class C {
+ static X foo1<X>(X x) => x;
+}
+
+main() {
+ const c1 = C.foo1<int>;
+ const c2 = C.foo1<num>;
+ var v1 = C.foo1<int>;
+ var v2 = C.foo1<num>;
+
+ const CheckNotIdentical(c1, c2);
+ Expect.identical(c1, v1);
+ Expect.notEquals(v1, v2);
+}