Version 2.13.0-185.0.dev
Merge commit '4162c560f0774196a7bbd6b9f7a8041eb45d021d' into 'dev'
diff --git a/tests/language/nonfunction_type_aliases/private_names/private_name_extension_test.dart b/tests/language/nonfunction_type_aliases/private_names/private_name_extension_test.dart
new file mode 100644
index 0000000..ece07c3
--- /dev/null
+++ b/tests/language/nonfunction_type_aliases/private_names/private_name_extension_test.dart
@@ -0,0 +1,45 @@
+// 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.
+
+// SharedOptions=--enable-experiment=nonfunction-type-aliases
+
+// Test that private names exported via public typedefs allow extension.
+
+import "package:expect/expect.dart";
+
+import "private_name_library.dart";
+
+class Derived extends PublicClass {
+ Derived() : super(0);
+}
+
+class AlsoDerived extends AlsoPublicClass {
+ AlsoDerived() : super.named(0);
+ int instanceMethod() => 0;
+ int _privateInstanceMethod() => 0;
+}
+
+/// Test that inherited methods work correctly.
+void test1() {
+ {
+ PublicClass p = Derived();
+ Expect.equals(3, p.instanceMethod());
+ Expect.throwsNoSuchMethodError(() => (p as dynamic)._privateInstanceMethod());
+ }
+}
+
+/// Test that inherited methods work correctly.
+void test2() {
+ {
+ var p = AlsoDerived();
+ Expect.equals(0, p.instanceMethod());
+ Expect.equals(0, p._privateInstanceMethod());
+ Expect.equals(0, (p as dynamic)._privateInstanceMethod());
+ }
+}
+
+void main() {
+ test1();
+ test2();
+}
diff --git a/tests/language/nonfunction_type_aliases/private_names/private_name_library.dart b/tests/language/nonfunction_type_aliases/private_names/private_name_library.dart
new file mode 100644
index 0000000..07e441c
--- /dev/null
+++ b/tests/language/nonfunction_type_aliases/private_names/private_name_library.dart
@@ -0,0 +1,32 @@
+// 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.
+
+// Shared code for tests that private names exported publicly via a typedef work
+// as expected.
+
+library private;
+
+class _PrivateClass {
+ int x;
+ _PrivateClass(this.x);
+ _PrivateClass.named(this.x);
+ static int staticMethod() => 3;
+ static int _privateStaticMethod() => 3;
+ int instanceMethod() => 3;
+ int _privateInstanceMethod() => 3;
+}
+
+typedef PublicClass = _PrivateClass;
+PublicClass mkPublicClass() => PublicClass(0);
+
+typedef _PrivateTypeDef = _PrivateClass;
+typedef AlsoPublicClass = _PrivateTypeDef;
+AlsoPublicClass mkAlsoPublicClass() => AlsoPublicClass(0);
+
+class _PrivateGenericClass<T> {
+ static int staticMethod() => 3;
+}
+typedef PublicGenericClass<T> = _PrivateGenericClass<T>;
+PublicGenericClass<T> mkPublicGenericClass<T>() => PublicGenericClass();
+typedef PublicGenericClassOfInt = _PrivateGenericClass<int>;
diff --git a/tests/language/nonfunction_type_aliases/private_names/private_name_static_methods_error_test.dart b/tests/language/nonfunction_type_aliases/private_names/private_name_static_methods_error_test.dart
new file mode 100644
index 0000000..53d90ec
--- /dev/null
+++ b/tests/language/nonfunction_type_aliases/private_names/private_name_static_methods_error_test.dart
@@ -0,0 +1,32 @@
+// 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.
+
+// SharedOptions=--enable-experiment=nonfunction-type-aliases
+
+// Test that private names exported via public typedefs don't give access to
+// private static methods.
+
+import "private_name_library.dart";
+
+/// Test that accessing private static methods is not accidentally enabled.
+void test1() {
+ {
+ PublicClass._privateStaticMethod();
+// ^^^^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_METHOD
+// [cfe] Method not found: '_PrivateClass._privateStaticMethod'.
+ AlsoPublicClass._privateStaticMethod();
+// ^^^^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_METHOD
+// [cfe] Method not found: '_PrivateClass._privateStaticMethod'.
+ PublicGenericClassOfInt._privateStaticMethod();
+// ^^^^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_METHOD
+// [cfe] Method not found: '_PrivateGenericClass._privateStaticMethod'.
+ }
+}
+
+void main() {
+ test1();
+}
diff --git a/tests/language/nonfunction_type_aliases/private_names/private_name_static_methods_test.dart b/tests/language/nonfunction_type_aliases/private_names/private_name_static_methods_test.dart
new file mode 100644
index 0000000..8ea31a4
--- /dev/null
+++ b/tests/language/nonfunction_type_aliases/private_names/private_name_static_methods_test.dart
@@ -0,0 +1,31 @@
+// 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.
+
+// SharedOptions=--enable-experiment=nonfunction-type-aliases
+
+// Test that private names exported via public typedefs work correctly for
+// accessing static methods.
+
+import "package:expect/expect.dart";
+
+import "../../static_type_helper.dart";
+import "private_name_library.dart";
+
+/// Test that each public typedef can be used to access static methods.
+void test1() {
+ {
+ Expect.equals(3, PublicClass.staticMethod());
+ PublicClass.staticMethod().expectStaticType<Exactly<int>>();
+
+ Expect.equals(3, AlsoPublicClass.staticMethod());
+ AlsoPublicClass.staticMethod().expectStaticType<Exactly<int>>();
+
+ Expect.equals(3, PublicGenericClassOfInt.staticMethod());
+ PublicGenericClassOfInt.staticMethod().expectStaticType<Exactly<int>>();
+ }
+}
+
+void main() {
+ test1();
+}
diff --git a/tests/language/nonfunction_type_aliases/private_names/private_name_types_test.dart b/tests/language/nonfunction_type_aliases/private_names/private_name_types_test.dart
new file mode 100644
index 0000000..27fa686
--- /dev/null
+++ b/tests/language/nonfunction_type_aliases/private_names/private_name_types_test.dart
@@ -0,0 +1,66 @@
+// 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.
+
+// SharedOptions=--enable-experiment=nonfunction-type-aliases
+
+// Test that private names exported via public typedefs work correctly as
+// types.
+
+import "package:expect/expect.dart";
+
+import "private_name_library.dart";
+import "private_name_library.dart" as prefixed;
+
+/// Test that each public typedef is usable as a type, and that the types
+/// behave as expected.
+void test1() {
+ {
+ PublicClass p0 = mkPublicClass();
+ AlsoPublicClass p1 = mkAlsoPublicClass();
+ // Test that equivalent private types are still equivalent
+ p0 = p1;
+ p1 = p0;
+ }
+
+ {
+ PublicGenericClass<int> p0 = mkPublicGenericClass();
+ PublicGenericClassOfInt p1 = mkPublicGenericClass();
+ // Test that equivalent private types are still equivalent
+ p0 = p1;
+ p1 = p0;
+
+ // Test that inference works on private generic names.
+ Type capture<T>(PublicGenericClass<T> a) => T;
+ Expect.equals(int, capture(p1));
+ }
+}
+
+/// Test that each public typedef is usable as a type when the types are
+/// imported with a prefix, and that the types behave as expected.
+void test2() {
+ {
+ prefixed.PublicClass p0 = prefixed.mkPublicClass();
+ prefixed.AlsoPublicClass p1 = prefixed.mkAlsoPublicClass();
+ // Test that equivalent private types are still equivalent
+ p0 = p1;
+ p1 = p0;
+ }
+
+ {
+ prefixed.PublicGenericClass<int> p0 = prefixed.mkPublicGenericClass();
+ prefixed.PublicGenericClassOfInt p1 = prefixed.mkPublicGenericClass();
+ // Test that equivalent private types are still equivalent
+ p0 = p1;
+ p1 = p0;
+
+ // Test that inference works on private generic names.
+ Type capture<T>(prefixed.PublicGenericClass<T> a) => T;
+ Expect.equals(capture(p1), int);
+ }
+}
+
+void main() {
+ test1();
+ test2();
+}
diff --git a/tools/VERSION b/tools/VERSION
index 6f895ad..9433708 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 13
PATCH 0
-PRERELEASE 184
+PRERELEASE 185
PRERELEASE_PATCH 0
\ No newline at end of file