Fixes #1166: test updated so that they check that function invocation cannot be constant. New tests added.
diff --git a/LanguageFeatures/Constructor-tear-offs/named_constructor_A08_t01.dart b/LanguageFeatures/Constructor-tear-offs/named_constructor_A08_t01.dart
index 9a32bc0..f4ba264 100644
--- a/LanguageFeatures/Constructor-tear-offs/named_constructor_A08_t01.dart
+++ b/LanguageFeatures/Constructor-tear-offs/named_constructor_A08_t01.dart
@@ -11,6 +11,7 @@
/// @author iarkh@unipro.ru
/// @issue 46899
/// @issue 46900
+/// @issue 46925
// SharedOptions=--enable-experiment=constructor-tearoffs
@@ -26,13 +27,13 @@
const v1 = MyClass.new;
const v2 = MyClass.constr;
- const c1 = v1(3, 14);
- const c2 = v1(3, 14);
- Expect.identical(c1, c2);
+ var c1 = v1(3, 14);
+ var c2 = v1(3, 14);
+ Expect.notEquals(c1, c2);
- const c3 = v2();
- const c4 = v2();
- Expect.identical(c3, c4);
+ var c3 = v2();
+ var c4 = v2();
+ Expect.notEquals(c3, c4);
Expect.notEquals(c1, c3);
}
diff --git a/LanguageFeatures/Constructor-tear-offs/named_constructor_A08_t02.dart b/LanguageFeatures/Constructor-tear-offs/named_constructor_A08_t02.dart
index 39f0615..7d37515 100644
--- a/LanguageFeatures/Constructor-tear-offs/named_constructor_A08_t02.dart
+++ b/LanguageFeatures/Constructor-tear-offs/named_constructor_A08_t02.dart
@@ -5,11 +5,12 @@
/// @assertion An instantiated tear-off is constant and canonicalized if the
/// instantiating types are constant, and not even equal if they are not.
///
-/// @description Checks that An instantiated tear-off is constant and
+/// @description Checks that an instantiated tear-off is constant and
/// canonicalized if the instantiating types are constant - test generic class
/// @author iarkh@unipro.ru
/// @issue 46899
/// @issue 46900
+/// @issue 46925
// SharedOptions=--enable-experiment=constructor-tearoffs
@@ -27,19 +28,29 @@
const v3 = MyClass<int>.new;
const v4 = MyClass<String>.constr;
- const c1 = v1(3, 14);
- const c2 = v1(3, 14);
- Expect.identical(c1, c2);
+ const v5 = MyClass<String>.new;
+ const v6 = MyClass<int>.constr;
+ const v7 = MyClass<int>.new;
+ const v8 = MyClass<String>.constr;
- const c3 = v2();
- const c4 = v2();
- Expect.identical(c3, c4);
+ Expect.identical(v1, v5);
+ Expect.identical(v2, v6);
+ Expect.identical(v3, v7);
+ Expect.identical(v4, v8);
+
+ var c1 = v1(3, 14);
+ var c2 = v1(3, 14);
+ Expect.notEquals(c1, c2);
+
+ var c3 = v2();
+ var c4 = v2();
+ Expect.notEquals(c3, c4);
Expect.notEquals(c1, c3);
- const c5 = v3(3, 14);
+ var c5 = v3(3, 14);
Expect.notEquals(c1, c5);
- const c6 = v4();
+ var c6 = v4();
Expect.notEquals(c3, c6);
}
diff --git a/LanguageFeatures/Constructor-tear-offs/named_constructor_A08_t05.dart b/LanguageFeatures/Constructor-tear-offs/named_constructor_A08_t05.dart
new file mode 100644
index 0000000..6ddc65f
--- /dev/null
+++ b/LanguageFeatures/Constructor-tear-offs/named_constructor_A08_t05.dart
@@ -0,0 +1,36 @@
+// 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 An instantiated tear-off is constant and canonicalized if the
+/// instantiating types are constant, and not even equal if they are not.
+///
+/// @description Checks that invocation of a constructor tearoff is never a
+/// constant expression
+/// (see https://github.com/dart-lang/sdk/issues/46925#issuecomment-900420499)
+/// @author iarkh@unipro.ru
+/// @issue 46899
+/// @issue 46900
+/// @issue 46925
+
+// SharedOptions=--enable-experiment=constructor-tearoffs
+
+class MyClass {
+ final a;
+ const MyClass(int i, int j) : a = (i + j);
+ const MyClass.constr() : a = 0;
+}
+
+main() {
+ const v1 = MyClass.new;
+ const c1 = v1(3, 14);
+// ^^
+// [analyzer] unspecified
+// [cfe] unspecified
+
+ const v2 = MyClass.constr;
+ const c2 = v2();
+// ^^
+// [analyzer] unspecified
+// [cfe] unspecified
+}
diff --git a/LanguageFeatures/Constructor-tear-offs/named_constructor_A08_t06.dart b/LanguageFeatures/Constructor-tear-offs/named_constructor_A08_t06.dart
new file mode 100644
index 0000000..937424e
--- /dev/null
+++ b/LanguageFeatures/Constructor-tear-offs/named_constructor_A08_t06.dart
@@ -0,0 +1,60 @@
+// 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 An instantiated tear-off is constant and canonicalized if the
+/// instantiating types are constant, and not even equal if they are not.
+///
+/// @description Checks that invocation of a constructor tearoff is never a
+/// constant expression test generic class
+/// (see https://github.com/dart-lang/sdk/issues/46925#issuecomment-900420499)
+/// @author iarkh@unipro.ru
+/// @issue 46899
+/// @issue 46900
+/// @issue 46925
+
+// SharedOptions=--enable-experiment=constructor-tearoffs
+
+class MyClass<T> {
+ final a;
+ const MyClass(int i, int j) : a = (i + j);
+ const MyClass.constr() : a = 0;
+}
+
+main() {
+ const v1 = MyClass<String>.new;
+ const c1 = v1(3, 14);
+// ^^
+// [analyzer] unspecified
+// [cfe] unspecified
+
+ const v2 = MyClass<int>.constr;
+ const c2 = v2();
+// ^^
+// [analyzer] unspecified
+// [cfe] unspecified
+
+ const v3 = MyClass<int>.new;
+ const c3 = v3(3, 14);
+// ^^
+// [analyzer] unspecified
+// [cfe] unspecified
+
+ const v4 = MyClass<String>.constr;
+ const c4 = v4();
+// ^^
+// [analyzer] unspecified
+// [cfe] unspecified
+
+ const v5 = MyClass.new;
+ const c5 = v5(3, 14);
+// ^^
+// [analyzer] unspecified
+// [cfe] unspecified
+
+ const v6 = MyClass.constr;
+ const c6 = v6();
+// ^^
+// [analyzer] unspecified
+// [cfe] unspecified
+}