Fixes #464. Legacy-libraries tests added
diff --git a/LanguageFeatures/nnbd/legacy_libraries_A01_t01.dart b/LanguageFeatures/nnbd/legacy_libraries_A01_t01.dart
new file mode 100644
index 0000000..fe109bb
--- /dev/null
+++ b/LanguageFeatures/nnbd/legacy_libraries_A01_t01.dart
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2019, 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  All opted-in libraries upstream from the legacy library are
+ * viewed by the legacy library with nullability related features erased from
+ * their APIs. In particular:
+ *  - All types of the form T? in the opted-in API are treated as T.
+ *  - All required named parameters are treated as optional named parameters.
+ *  - The type Never is treated as the type Null
+ *
+ * @description Check that all types of the form T? in the opted-in API are
+ * treated as T
+ * @author sgrekhov@unipro.ru
+ */
+// @dart=2.4
+// SharedOptions=--enable-experiment=non-nullable
+import "../../Utils/expect.dart";
+import "opted_in_lib.dart";
+
+main() {
+  Expect.isNull(aVar1);
+  Expect.isNull(cVar1);
+  Expect.isNull(sVar1);
+  Expect.isNull(iVar1);
+
+  aVar1 = new A();
+  Expect.isTrue(aVar1 is A);
+  aVar1 = null;
+
+  cVar1 = new C<A>(aVar1);
+  Expect.isTrue(cVar1 is C<A>);
+  cVar1 = null;
+
+  sVar1 = "Lily was here";
+  Expect.isTrue(sVar1 is String);
+  sVar1 = null;
+
+  iVar1 = 42;
+  Expect.isTrue(iVar1 is int);
+  iVar1 = null;
+
+  A a = null;
+  C<A> c = null;
+}
diff --git a/LanguageFeatures/nnbd/legacy_libraries_A01_t02.dart b/LanguageFeatures/nnbd/legacy_libraries_A01_t02.dart
new file mode 100644
index 0000000..b2c2418
--- /dev/null
+++ b/LanguageFeatures/nnbd/legacy_libraries_A01_t02.dart
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2019, 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  All opted-in libraries upstream from the legacy library are
+ * viewed by the legacy library with nullability related features erased from
+ * their APIs. In particular:
+ *  - All types of the form T? in the opted-in API are treated as T.
+ *  - All required named parameters are treated as optional named parameters.
+ *  - The type Never is treated as the type Null
+ *
+ * @description Check that all types of the form T? in the opted-in API are
+ * treated as T
+ * @author sgrekhov@unipro.ru
+ */
+// @dart=2.4
+// SharedOptions=--enable-experiment=non-nullable
+import "../../Utils/expect.dart";
+import "opted_in_lib.dart";
+
+main() {
+  Expect.isTrue(aVar2 is A);
+  Expect.isTrue(cVar2 is C<A>);
+  Expect.isTrue(sVar2 is String);
+  Expect.isTrue(iVar2 is int);
+  aVar2 = null;
+  cVar2 = null;
+  sVar2 = null;
+  iVar2 = null;
+}
diff --git a/LanguageFeatures/nnbd/legacy_libraries_A01_t03.dart b/LanguageFeatures/nnbd/legacy_libraries_A01_t03.dart
new file mode 100644
index 0000000..8f9ed27
--- /dev/null
+++ b/LanguageFeatures/nnbd/legacy_libraries_A01_t03.dart
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2019, 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  All opted-in libraries upstream from the legacy library are
+ * viewed by the legacy library with nullability related features erased from
+ * their APIs. In particular:
+ *  - All types of the form T? in the opted-in API are treated as T.
+ *  - All required named parameters are treated as optional named parameters.
+ *  - The type Never is treated as the type Null
+ *
+ * @description Check that all types of the form T? in the opted-in API are
+ * treated as T
+ * @author sgrekhov@unipro.ru
+ */
+// @dart=2.4
+// SharedOptions=--enable-experiment=non-nullable,nonfunction-type-aliases
+import "../../Utils/expect.dart";
+import "opted_in_aliases_lib.dart";
+
+main() {
+  AAliasNonNullable a1 = null;
+  AAliasNullable a2 = null;
+  StringAliasNonNullable s1 = null;
+  StringAliasNullable s2 = null;
+  IntAliasNonNullable i1 = null;
+  IntAliasNullable i2 = null;
+
+  a1 = new A();
+  a2 = new A();
+  s1 = "Lily was here";
+  s2 = "Show must go on";
+  i1 = 42;
+  i2 = 13;
+
+  Expect.isTrue(a1 is A);
+  Expect.isTrue(s1 is String);
+  Expect.isTrue(i1 is int);
+  Expect.isTrue(a2 is A);
+  Expect.isTrue(s2 is String);
+  Expect.isTrue(i2 is int);
+}
diff --git a/LanguageFeatures/nnbd/legacy_libraries_A01_t04.dart b/LanguageFeatures/nnbd/legacy_libraries_A01_t04.dart
new file mode 100644
index 0000000..66594f7
--- /dev/null
+++ b/LanguageFeatures/nnbd/legacy_libraries_A01_t04.dart
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2019, 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  All opted-in libraries upstream from the legacy library are
+ * viewed by the legacy library with nullability related features erased from
+ * their APIs. In particular:
+ *  - All types of the form T? in the opted-in API are treated as T.
+ *  - All required named parameters are treated as optional named parameters.
+ *  - The type Never is treated as the type Null
+ *
+ * @description Check that all types of the form T? in the opted-in API are
+ * treated as T
+ * @author sgrekhov@unipro.ru
+ */
+// @dart=2.4
+// SharedOptions=--enable-experiment=non-nullable,nonfunction-type-aliases
+import "../../Utils/expect.dart";
+import "opted_in_lib.dart";
+
+typedef AAlias = A;
+typedef StringAlias = String;
+typedef IntAlias = int;
+
+main() {
+  AAlias a1 = null;
+  StringAlias s1 = null;
+  IntAlias i1 = null;
+
+  a1 = new A();
+  s1 = "Lily was here";
+  i1 = 42;
+
+  Expect.isTrue(a1 is A);
+  Expect.isTrue(s1 is String);
+  Expect.isTrue(i1 is int);
+}
diff --git a/LanguageFeatures/nnbd/legacy_libraries_A02_t01.dart b/LanguageFeatures/nnbd/legacy_libraries_A02_t01.dart
new file mode 100644
index 0000000..7369db2
--- /dev/null
+++ b/LanguageFeatures/nnbd/legacy_libraries_A02_t01.dart
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2019, 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  All opted-in libraries upstream from the legacy library are
+ * viewed by the legacy library with nullability related features erased from
+ * their APIs. In particular:
+ *  - All types of the form T? in the opted-in API are treated as T.
+ *  - All required named parameters are treated as optional named parameters.
+ *  - The type Never is treated as the type Null
+ *
+ * @description Check that all required named parameters are treated as optional
+ * named parameters.
+ * @author sgrekhov@unipro.ru
+ */
+// @dart=2.4
+// SharedOptions=--enable-experiment=non-nullable
+import "opted_in_lib.dart";
+
+main() {
+  C.bar();
+  test();
+  new C().test();
+
+  C.bar(named: "Lily");
+  test(named: "was");
+  new C().test(named: "here");
+}
diff --git a/LanguageFeatures/nnbd/legacy_libraries_A03_t01.dart b/LanguageFeatures/nnbd/legacy_libraries_A03_t01.dart
new file mode 100644
index 0000000..372f13f
--- /dev/null
+++ b/LanguageFeatures/nnbd/legacy_libraries_A03_t01.dart
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2019, 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  All opted-in libraries upstream from the legacy library are
+ * viewed by the legacy library with nullability related features erased from
+ * their APIs. In particular:
+ *  - All types of the form T? in the opted-in API are treated as T.
+ *  - All required named parameters are treated as optional named parameters.
+ *  - The type Never is treated as the type Null
+ *
+ * @description Check that the type Never is treated as the type Null
+ * @author sgrekhov@unipro.ru
+ */
+// @dart=2.4
+// SharedOptions=--enable-experiment=non-nullable
+import "../../Utils/expect.dart";
+import "opted_in_lib.dart";
+
+main() {
+  Expect.isNull(Never is Null);
+}
diff --git a/LanguageFeatures/nnbd/legacy_libraries_A03_t02.dart b/LanguageFeatures/nnbd/legacy_libraries_A03_t02.dart
new file mode 100644
index 0000000..eb98abf
--- /dev/null
+++ b/LanguageFeatures/nnbd/legacy_libraries_A03_t02.dart
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2019, 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  All opted-in libraries upstream from the legacy library are
+ * viewed by the legacy library with nullability related features erased from
+ * their APIs. In particular:
+ *  - All types of the form T? in the opted-in API are treated as T.
+ *  - All required named parameters are treated as optional named parameters.
+ *  - The type Never is treated as the type Null
+ *
+ * @description Check that the type Never is treated as the type Null
+ * @author sgrekhov@unipro.ru
+ */
+// @dart=2.4
+// SharedOptions=--enable-experiment=non-nullable,nonfunction-type-aliases
+import "../../Utils/expect.dart";
+import "opted_in_aliases_lib.dart";
+
+main() {
+  Expect.isTrue(NeverAlias is Null);
+}
diff --git a/LanguageFeatures/nnbd/legacy_libraries_A04_t01.dart b/LanguageFeatures/nnbd/legacy_libraries_A04_t01.dart
new file mode 100644
index 0000000..81bf835
--- /dev/null
+++ b/LanguageFeatures/nnbd/legacy_libraries_A04_t01.dart
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2019, 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  In a legacy library, none of the new syntax introduced by this
+ * proposal is available, and it is a static error if it is used.
+ *
+ * @description Check that it is a static error if NNBD syntax is used in a
+ * pre-NNBD legacy library
+ * @author sgrekhov@unipro.ru
+ */
+// @dart=2.4
+// SharedOptions=--enable-experiment=non-nullable
+
+class A {}
+
+class C {
+  static String? s;
+//             ^
+// [analyzer] unspecified
+// [cfe] unspecified
+  String? v;
+//      ^
+// [analyzer] unspecified
+// [cfe] unspecified
+
+  int? foo() => 42;
+//   ^
+// [analyzer] unspecified
+// [cfe] unspecified
+
+  void bar(int? x) {}
+//            ^
+// [analyzer] unspecified
+// [cfe] unspecified
+}
+
+main() {
+  A? a = null;
+// ^
+// [analyzer] unspecified
+// [cfe] unspecified
+
+  a = (A?) a;
+//      ^
+// [analyzer] unspecified
+// [cfe] unspecified
+
+  int? i = 42;
+//   ^
+// [analyzer] unspecified
+// [cfe] unspecified
+
+  int? foo() => 42;
+//   ^
+// [analyzer] unspecified
+// [cfe] unspecified
+
+  void bar(int? x) {}
+//            ^
+// [analyzer] unspecified
+// [cfe] unspecified
+}
diff --git a/LanguageFeatures/nnbd/legacy_libraries_A04_t02.dart b/LanguageFeatures/nnbd/legacy_libraries_A04_t02.dart
new file mode 100644
index 0000000..de6fc18
--- /dev/null
+++ b/LanguageFeatures/nnbd/legacy_libraries_A04_t02.dart
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2019, 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  In a legacy library, none of the new syntax introduced by this
+ * proposal is available, and it is a static error if it is used.
+ *
+ * @description Check that it is a static error if NNBD syntax is used in a
+ * pre-NNBD legacy library
+ * @author sgrekhov@unipro.ru
+ */
+// @dart=2.4
+// SharedOptions=--enable-experiment=non-nullable
+
+class A {}
+
+main() {
+  if (A is Never) {
+//         ^^^^^
+// [analyzer] unspecified
+// [cfe] unspecified
+  }
+}
diff --git a/LanguageFeatures/nnbd/legacy_libraries_A04_t03.dart b/LanguageFeatures/nnbd/legacy_libraries_A04_t03.dart
new file mode 100644
index 0000000..a47b9db
--- /dev/null
+++ b/LanguageFeatures/nnbd/legacy_libraries_A04_t03.dart
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2019, 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  In a legacy library, none of the new syntax introduced by this
+ * proposal is available, and it is a static error if it is used.
+ *
+ * @description Check that it is a static error if NNBD syntax is used in a
+ * pre-NNBD legacy library
+ * @author sgrekhov@unipro.ru
+ */
+// @dart=2.4
+// SharedOptions=--enable-experiment=non-nullable
+
+class A {}
+
+main() {
+  A a = new A();
+  a!;
+// ^
+// [analyzer] unspecified
+// [cfe] unspecified
+}
diff --git a/LanguageFeatures/nnbd/legacy_libraries_A04_t04.dart b/LanguageFeatures/nnbd/legacy_libraries_A04_t04.dart
new file mode 100644
index 0000000..f647a6c
--- /dev/null
+++ b/LanguageFeatures/nnbd/legacy_libraries_A04_t04.dart
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2019, 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  In a legacy library, none of the new syntax introduced by this
+ * proposal is available, and it is a static error if it is used.
+ *
+ * @description Check that it is a static error if NNBD syntax is used in a
+ * pre-NNBD legacy library
+ * @author sgrekhov@unipro.ru
+ */
+// @dart=2.4
+// SharedOptions=--enable-experiment=non-nullable
+
+class C {
+  static late final String s1;
+//       ^^^^
+// [analyzer] unspecified
+// [cfe] unspecified
+  static late String s2;
+//       ^^^^
+// [analyzer] unspecified
+// [cfe] unspecified
+  covariant late String v1;
+//          ^^^^
+// [analyzer] unspecified
+// [cfe] unspecified
+  late final String v2;
+//^^^^
+// [analyzer] unspecified
+// [cfe] unspecified
+  late String v3;
+//^^^^
+// [analyzer] unspecified
+// [cfe] unspecified
+}
+
+  late final String g1;
+//^^^^
+// [analyzer] unspecified
+// [cfe] unspecified
+  late String g2;
+//^^^^
+// [analyzer] unspecified
+// [cfe] unspecified
+
+main() {
+  late final String l1;
+//^^^^
+// [analyzer] unspecified
+// [cfe] unspecified
+  late String l2;
+//^^^^
+// [analyzer] unspecified
+// [cfe] unspecified
+}
diff --git a/LanguageFeatures/nnbd/legacy_libraries_A04_t05.dart b/LanguageFeatures/nnbd/legacy_libraries_A04_t05.dart
new file mode 100644
index 0000000..04838f2
--- /dev/null
+++ b/LanguageFeatures/nnbd/legacy_libraries_A04_t05.dart
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2019, 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  In a legacy library, none of the new syntax introduced by this
+ * proposal is available, and it is a static error if it is used.
+ *
+ * @description Check that it is a static error if NNBD syntax is used in a
+ * pre-NNBD legacy library
+ * @author sgrekhov@unipro.ru
+ */
+// @dart=2.4
+// SharedOptions=--enable-experiment=non-nullable
+
+foo(required String named) {}
+//  ^^^^^^^^
+// [analyzer] unspecified
+// [cfe] unspecified
+class C {
+  foo(named: s);
+}
diff --git a/LanguageFeatures/nnbd/legacy_libraries_A04_t06.dart b/LanguageFeatures/nnbd/legacy_libraries_A04_t06.dart
new file mode 100644
index 0000000..905749c
--- /dev/null
+++ b/LanguageFeatures/nnbd/legacy_libraries_A04_t06.dart
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2019, 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  In a legacy library, none of the new syntax introduced by this
+ * proposal is available, and it is a static error if it is used.
+ *
+ * @description Check that it is a static error if NNBD syntax is used in a
+ * pre-NNBD legacy library
+ * @author sgrekhov@unipro.ru
+ */
+// @dart=2.4
+// SharedOptions=--enable-experiment=non-nullable
+
+class C {
+  int operator[](int index) => index * 2;
+}
+
+main() {
+  C? c = null;
+  c?.[42];
+// ^
+// [analyzer] unspecified
+// [cfe] unspecified
+}
diff --git a/LanguageFeatures/nnbd/legacy_library_aliases_lib.dart b/LanguageFeatures/nnbd/legacy_library_aliases_lib.dart
index 8b782ea..f5d7c48 100644
--- a/LanguageFeatures/nnbd/legacy_library_aliases_lib.dart
+++ b/LanguageFeatures/nnbd/legacy_library_aliases_lib.dart
@@ -17,4 +17,4 @@
 
 typedef AAlias = A;
 typedef IntAlias = int;
-typedef StringAlias = String;
\ No newline at end of file
+typedef StringAlias = String;
diff --git a/LanguageFeatures/nnbd/legacy_library_lib.dart b/LanguageFeatures/nnbd/legacy_library_lib.dart
index 3ec7332..773388e 100644
--- a/LanguageFeatures/nnbd/legacy_library_lib.dart
+++ b/LanguageFeatures/nnbd/legacy_library_lib.dart
@@ -30,4 +30,4 @@
 
 class Const {
   const Const();
-}
\ No newline at end of file
+}
diff --git a/LanguageFeatures/nnbd/opted_in_aliases_lib.dart b/LanguageFeatures/nnbd/opted_in_aliases_lib.dart
new file mode 100644
index 0000000..6067720
--- /dev/null
+++ b/LanguageFeatures/nnbd/opted_in_aliases_lib.dart
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2019, 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.
+ */
+/**
+ * @author sgrekhov@unipro.ru
+ */
+// SharedOptions=--enable-experiment=non-nullable,nonfunction-type-aliases
+library opted_in_aliases_lib;
+
+class A {
+}
+
+typedef AAliasNonNullable = A;
+typedef AAliasNullable = A?;
+typedef StringAliasNonNullable = String;
+typedef StringAliasNullable = String?;
+typedef IntAliasNonNullable = int;
+typedef IntAliasNullable = int?;
+typedef NeverAlias = Never;
diff --git a/LanguageFeatures/nnbd/opted_in_lib.dart b/LanguageFeatures/nnbd/opted_in_lib.dart
new file mode 100644
index 0000000..574159f
--- /dev/null
+++ b/LanguageFeatures/nnbd/opted_in_lib.dart
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2019, 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.
+ */
+/**
+ * @author sgrekhov@unipro.ru
+ */
+// SharedOptions=--enable-experiment=non-nullable
+library opted_in_lib;
+
+class A {
+  void foo() {}
+  void test({required String named}) {}
+  static void bar({required String named}) {}
+}
+
+class C<X extends A> {
+  X x;
+  C(this.x);
+}
+
+void test({required String named}) {}
+
+A? aVar1 = null;
+C<A>? cVar1 = null;
+String? sVar1 = null;
+int? iVar1 = null;
+
+A aVar2 = new A();
+C<A> cVar2 = new C<A>(aVar2);
+String sVar2 = "Show must go on";
+int iVar2 = 42;