[cfe] Handle nullability of typedefs

Closes #41496
Closes #41498
Closes #41499
Closes #41501
Closes #41505

Change-Id: I425b6137f9ea41d01c95332ef1f7d43ca7afb5a6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143811
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
diff --git a/.dart_tool/package_config.json b/.dart_tool/package_config.json
index af00b66..9a6403f 100644
--- a/.dart_tool/package_config.json
+++ b/.dart_tool/package_config.json
@@ -263,6 +263,11 @@
       "packageUri": ".nonexisting/"
     },
     {
+      "name": "front_end_nonfunction_type_aliases",
+      "rootUri": "../pkg/front_end/testcases/nonfunction_type_aliases",
+      "packageUri": ".nonexisting/"
+    },
+    {
       "name": "frontend_server",
       "rootUri": "../pkg/frontend_server",
       "packageUri": "lib/",
diff --git a/pkg/front_end/lib/src/fasta/builder/type_alias_builder.dart b/pkg/front_end/lib/src/fasta/builder/type_alias_builder.dart
index a852f46..7b26757 100644
--- a/pkg/front_end/lib/src/fasta/builder/type_alias_builder.dart
+++ b/pkg/front_end/lib/src/fasta/builder/type_alias_builder.dart
@@ -79,7 +79,7 @@
   bool get fromDill => false;
 
   Typedef build(SourceLibraryBuilder libraryBuilder) {
-    typedef..type ??= buildThisType(libraryBuilder);
+    typedef..type ??= buildThisType();
 
     TypeBuilder type = this.type;
     if (type is FunctionTypeBuilder) {
@@ -146,7 +146,7 @@
     return result;
   }
 
-  DartType buildThisType(LibraryBuilder library) {
+  DartType buildThisType() {
     if (thisType != null) {
       if (identical(thisType, cyclicTypeAliasMarker)) {
         library.addProblem(templateCyclicTypedef.withArguments(name),
@@ -181,7 +181,7 @@
   /// [arguments] have already been built.
   DartType buildTypesWithBuiltArguments(LibraryBuilder library,
       Nullability nullability, List<DartType> arguments) {
-    DartType thisType = buildThisType(library);
+    DartType thisType = buildThisType();
     if (const DynamicType() == thisType) return thisType;
     Nullability adjustedNullability =
         isNullAlias ? Nullability.nullable : nullability;
@@ -248,26 +248,32 @@
   DartType buildType(LibraryBuilder library,
       NullabilityBuilder nullabilityBuilder, List<TypeBuilder> arguments,
       [bool notInstanceContext]) {
-    DartType thisType = buildThisType(library);
+    DartType thisType = buildThisType();
     if (thisType is InvalidType) return thisType;
     // TODO(dmitryas): Remove the following comment when FutureOr has its own
     // encoding and isn't represented as an InterfaceType.
 
     // The following won't work if the right-hand side of the typedef is a
     // FutureOr.
-    Nullability rhsNullability = thisType.nullability;
+    Nullability nullability;
+    if (isNullAlias) {
+      // Null is always nullable.
+      nullability = Nullability.nullable;
+    } else if (!parent.isNonNullableByDefault ||
+        !library.isNonNullableByDefault) {
+      // The typedef is defined or used in an opt-out library so the nullability
+      // is based on the use site alone.
+      nullability = nullabilityBuilder.build(library);
+    } else {
+      nullability = uniteNullabilities(
+          thisType.nullability, nullabilityBuilder.build(library));
+    }
     if (typedef.typeParameters.isEmpty && arguments == null) {
-      Nullability nullability = isNullAlias
-          ? Nullability.nullable
-          : nullabilityBuilder.build(library);
-      return thisType
-          .withNullability(uniteNullabilities(rhsNullability, nullability));
+      return thisType.withNullability(nullability);
     }
     // Otherwise, substitute.
     return buildTypesWithBuiltArguments(
-        library,
-        uniteNullabilities(rhsNullability, nullabilityBuilder.build(library)),
-        buildTypeArguments(library, arguments));
+        library, nullability, buildTypeArguments(library, arguments));
   }
 
   TypeDeclarationBuilder _cachedUnaliasedDeclaration;
diff --git a/pkg/front_end/lib/src/fasta/dill/dill_type_alias_builder.dart b/pkg/front_end/lib/src/fasta/dill/dill_type_alias_builder.dart
index f13acd1..6a06914 100644
--- a/pkg/front_end/lib/src/fasta/dill/dill_type_alias_builder.dart
+++ b/pkg/front_end/lib/src/fasta/dill/dill_type_alias_builder.dart
@@ -45,7 +45,7 @@
   }
 
   @override
-  DartType buildThisType(LibraryBuilder library) {
+  DartType buildThisType() {
     return thisType ??= typedef.type;
   }
 
diff --git a/pkg/front_end/test/spell_checking_list_tests.txt b/pkg/front_end/test/spell_checking_list_tests.txt
index 44f1f77..95a7bb3 100644
--- a/pkg/front_end/test/spell_checking_list_tests.txt
+++ b/pkg/front_end/test/spell_checking_list_tests.txt
@@ -276,6 +276,9 @@
 isolates
 issue41210b
 issue41436c
+issue41496b
+issue41498b
+issue41499b
 iter
 joo
 jumped
diff --git a/pkg/front_end/testcases/nnbd/issue41496.dart b/pkg/front_end/testcases/nnbd/issue41496.dart
new file mode 100644
index 0000000..93d3769
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/issue41496.dart
@@ -0,0 +1,15 @@
+// Copyright (c) 2020, 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.
+
+import "issue41496_lib.dart";
+
+LegacyFoo f1;
+
+class C {
+  static LegacyFoo f2;
+}
+
+main() {
+  new C();
+}
diff --git a/pkg/front_end/testcases/nnbd/issue41496.dart.outline.expect b/pkg/front_end/testcases/nnbd/issue41496.dart.outline.expect
new file mode 100644
index 0000000..de2e711
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/issue41496.dart.outline.expect
@@ -0,0 +1,32 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/nnbd/issue41496.dart:7:11: Error: Field 'f1' should be initialized because its type 'void Function()' doesn't allow null.
+// LegacyFoo f1;
+//           ^^
+//
+// pkg/front_end/testcases/nnbd/issue41496.dart:10:20: Error: Field 'f2' should be initialized because its type 'void Function()' doesn't allow null.
+//   static LegacyFoo f2;
+//                    ^^
+//
+import self as self;
+import "dart:core" as core;
+
+import "org-dartlang-testcase:///issue41496_lib.dart";
+
+class C extends core::Object {
+  static field () → void f2;
+  synthetic constructor •() → self::C
+    ;
+}
+static field () → void f1;
+static method main() → dynamic
+  ;
+
+library opted_out_lib;
+import self as self2;
+
+typedef LegacyFoo = () →* void;
+static method test(() →* void f) → dynamic
+  ;
diff --git a/pkg/front_end/testcases/nnbd/issue41496.dart.strong.expect b/pkg/front_end/testcases/nnbd/issue41496.dart.strong.expect
new file mode 100644
index 0000000..5a1bc313
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/issue41496.dart.strong.expect
@@ -0,0 +1,33 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/nnbd/issue41496.dart:7:11: Error: Field 'f1' should be initialized because its type 'void Function()' doesn't allow null.
+// LegacyFoo f1;
+//           ^^
+//
+// pkg/front_end/testcases/nnbd/issue41496.dart:10:20: Error: Field 'f2' should be initialized because its type 'void Function()' doesn't allow null.
+//   static LegacyFoo f2;
+//                    ^^
+//
+import self as self;
+import "dart:core" as core;
+
+import "org-dartlang-testcase:///issue41496_lib.dart";
+
+class C extends core::Object {
+  static field () → void f2 = null;
+  synthetic constructor •() → self::C
+    : super core::Object::•()
+    ;
+}
+static field () → void f1;
+static method main() → dynamic {
+  new self::C::•();
+}
+
+library opted_out_lib;
+import self as self2;
+
+typedef LegacyFoo = () →* void;
+static method test(() →* void f) → dynamic {}
diff --git a/pkg/front_end/testcases/nnbd/issue41496.dart.strong.transformed.expect b/pkg/front_end/testcases/nnbd/issue41496.dart.strong.transformed.expect
new file mode 100644
index 0000000..5a1bc313
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/issue41496.dart.strong.transformed.expect
@@ -0,0 +1,33 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/nnbd/issue41496.dart:7:11: Error: Field 'f1' should be initialized because its type 'void Function()' doesn't allow null.
+// LegacyFoo f1;
+//           ^^
+//
+// pkg/front_end/testcases/nnbd/issue41496.dart:10:20: Error: Field 'f2' should be initialized because its type 'void Function()' doesn't allow null.
+//   static LegacyFoo f2;
+//                    ^^
+//
+import self as self;
+import "dart:core" as core;
+
+import "org-dartlang-testcase:///issue41496_lib.dart";
+
+class C extends core::Object {
+  static field () → void f2 = null;
+  synthetic constructor •() → self::C
+    : super core::Object::•()
+    ;
+}
+static field () → void f1;
+static method main() → dynamic {
+  new self::C::•();
+}
+
+library opted_out_lib;
+import self as self2;
+
+typedef LegacyFoo = () →* void;
+static method test(() →* void f) → dynamic {}
diff --git a/pkg/front_end/testcases/nnbd/issue41496.dart.weak.expect b/pkg/front_end/testcases/nnbd/issue41496.dart.weak.expect
new file mode 100644
index 0000000..5a1bc313
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/issue41496.dart.weak.expect
@@ -0,0 +1,33 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/nnbd/issue41496.dart:7:11: Error: Field 'f1' should be initialized because its type 'void Function()' doesn't allow null.
+// LegacyFoo f1;
+//           ^^
+//
+// pkg/front_end/testcases/nnbd/issue41496.dart:10:20: Error: Field 'f2' should be initialized because its type 'void Function()' doesn't allow null.
+//   static LegacyFoo f2;
+//                    ^^
+//
+import self as self;
+import "dart:core" as core;
+
+import "org-dartlang-testcase:///issue41496_lib.dart";
+
+class C extends core::Object {
+  static field () → void f2 = null;
+  synthetic constructor •() → self::C
+    : super core::Object::•()
+    ;
+}
+static field () → void f1;
+static method main() → dynamic {
+  new self::C::•();
+}
+
+library opted_out_lib;
+import self as self2;
+
+typedef LegacyFoo = () →* void;
+static method test(() →* void f) → dynamic {}
diff --git a/pkg/front_end/testcases/nnbd/issue41496.dart.weak.transformed.expect b/pkg/front_end/testcases/nnbd/issue41496.dart.weak.transformed.expect
new file mode 100644
index 0000000..5a1bc313
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/issue41496.dart.weak.transformed.expect
@@ -0,0 +1,33 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/nnbd/issue41496.dart:7:11: Error: Field 'f1' should be initialized because its type 'void Function()' doesn't allow null.
+// LegacyFoo f1;
+//           ^^
+//
+// pkg/front_end/testcases/nnbd/issue41496.dart:10:20: Error: Field 'f2' should be initialized because its type 'void Function()' doesn't allow null.
+//   static LegacyFoo f2;
+//                    ^^
+//
+import self as self;
+import "dart:core" as core;
+
+import "org-dartlang-testcase:///issue41496_lib.dart";
+
+class C extends core::Object {
+  static field () → void f2 = null;
+  synthetic constructor •() → self::C
+    : super core::Object::•()
+    ;
+}
+static field () → void f1;
+static method main() → dynamic {
+  new self::C::•();
+}
+
+library opted_out_lib;
+import self as self2;
+
+typedef LegacyFoo = () →* void;
+static method test(() →* void f) → dynamic {}
diff --git a/pkg/front_end/testcases/nnbd/issue41496_lib.dart b/pkg/front_end/testcases/nnbd/issue41496_lib.dart
new file mode 100644
index 0000000..8950f0d
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/issue41496_lib.dart
@@ -0,0 +1,11 @@
+// Copyright (c) 2020, 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.
+
+// @dart=2.6
+
+library opted_out_lib;
+
+typedef void LegacyFoo();
+
+test(LegacyFoo f) {}
diff --git a/pkg/front_end/testcases/nnbd/issue41496b.dart b/pkg/front_end/testcases/nnbd/issue41496b.dart
new file mode 100644
index 0000000..4bafd01
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/issue41496b.dart
@@ -0,0 +1,17 @@
+// Copyright (c) 2020, 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.
+
+// @dart=2.6
+
+library opted_out_lib;
+
+import 'issue41496b_lib.dart' as opt_in;
+
+typedef void LegacyFoo();
+
+test(LegacyFoo f) {}
+
+main() {
+  opt_in.main();
+}
diff --git a/pkg/front_end/testcases/nnbd/issue41496b.dart.outline.expect b/pkg/front_end/testcases/nnbd/issue41496b.dart.outline.expect
new file mode 100644
index 0000000..e596933
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/issue41496b.dart.outline.expect
@@ -0,0 +1,36 @@
+library opted_out_lib;
+import self as self;
+
+import "org-dartlang-testcase:///issue41496b_lib.dart" as opt_in;
+
+typedef LegacyFoo = () →* void;
+static method test(() →* void f) → dynamic
+  ;
+static method main() → dynamic
+  ;
+
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/nnbd/issue41496b_lib.dart:7:11: Error: Field 'f1' should be initialized because its type 'void Function()' doesn't allow null.
+// LegacyFoo f1;
+//           ^^
+//
+// pkg/front_end/testcases/nnbd/issue41496b_lib.dart:10:20: Error: Field 'f2' should be initialized because its type 'void Function()' doesn't allow null.
+//   static LegacyFoo f2;
+//                    ^^
+//
+import self as self2;
+import "dart:core" as core;
+
+import "org-dartlang-testcase:///issue41496b.dart";
+
+class C extends core::Object {
+  static field () → void f2;
+  synthetic constructor •() → self2::C
+    ;
+}
+static field () → void f1;
+static method main() → dynamic
+  ;
diff --git a/pkg/front_end/testcases/nnbd/issue41496b.dart.strong.expect b/pkg/front_end/testcases/nnbd/issue41496b.dart.strong.expect
new file mode 100644
index 0000000..b70a566
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/issue41496b.dart.strong.expect
@@ -0,0 +1,39 @@
+library opted_out_lib;
+import self as self;
+import "issue41496b_lib.dart" as iss;
+
+import "org-dartlang-testcase:///issue41496b_lib.dart" as opt_in;
+
+typedef LegacyFoo = () →* void;
+static method test(() →* void f) → dynamic {}
+static method main() → dynamic {
+  iss::main();
+}
+
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/nnbd/issue41496b_lib.dart:7:11: Error: Field 'f1' should be initialized because its type 'void Function()' doesn't allow null.
+// LegacyFoo f1;
+//           ^^
+//
+// pkg/front_end/testcases/nnbd/issue41496b_lib.dart:10:20: Error: Field 'f2' should be initialized because its type 'void Function()' doesn't allow null.
+//   static LegacyFoo f2;
+//                    ^^
+//
+import self as iss;
+import "dart:core" as core;
+
+import "org-dartlang-testcase:///issue41496b.dart";
+
+class C extends core::Object {
+  static field () → void f2 = null;
+  synthetic constructor •() → iss::C
+    : super core::Object::•()
+    ;
+}
+static field () → void f1;
+static method main() → dynamic {
+  new iss::C::•();
+}
diff --git a/pkg/front_end/testcases/nnbd/issue41496b.dart.strong.transformed.expect b/pkg/front_end/testcases/nnbd/issue41496b.dart.strong.transformed.expect
new file mode 100644
index 0000000..b70a566
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/issue41496b.dart.strong.transformed.expect
@@ -0,0 +1,39 @@
+library opted_out_lib;
+import self as self;
+import "issue41496b_lib.dart" as iss;
+
+import "org-dartlang-testcase:///issue41496b_lib.dart" as opt_in;
+
+typedef LegacyFoo = () →* void;
+static method test(() →* void f) → dynamic {}
+static method main() → dynamic {
+  iss::main();
+}
+
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/nnbd/issue41496b_lib.dart:7:11: Error: Field 'f1' should be initialized because its type 'void Function()' doesn't allow null.
+// LegacyFoo f1;
+//           ^^
+//
+// pkg/front_end/testcases/nnbd/issue41496b_lib.dart:10:20: Error: Field 'f2' should be initialized because its type 'void Function()' doesn't allow null.
+//   static LegacyFoo f2;
+//                    ^^
+//
+import self as iss;
+import "dart:core" as core;
+
+import "org-dartlang-testcase:///issue41496b.dart";
+
+class C extends core::Object {
+  static field () → void f2 = null;
+  synthetic constructor •() → iss::C
+    : super core::Object::•()
+    ;
+}
+static field () → void f1;
+static method main() → dynamic {
+  new iss::C::•();
+}
diff --git a/pkg/front_end/testcases/nnbd/issue41496b.dart.weak.expect b/pkg/front_end/testcases/nnbd/issue41496b.dart.weak.expect
new file mode 100644
index 0000000..b70a566
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/issue41496b.dart.weak.expect
@@ -0,0 +1,39 @@
+library opted_out_lib;
+import self as self;
+import "issue41496b_lib.dart" as iss;
+
+import "org-dartlang-testcase:///issue41496b_lib.dart" as opt_in;
+
+typedef LegacyFoo = () →* void;
+static method test(() →* void f) → dynamic {}
+static method main() → dynamic {
+  iss::main();
+}
+
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/nnbd/issue41496b_lib.dart:7:11: Error: Field 'f1' should be initialized because its type 'void Function()' doesn't allow null.
+// LegacyFoo f1;
+//           ^^
+//
+// pkg/front_end/testcases/nnbd/issue41496b_lib.dart:10:20: Error: Field 'f2' should be initialized because its type 'void Function()' doesn't allow null.
+//   static LegacyFoo f2;
+//                    ^^
+//
+import self as iss;
+import "dart:core" as core;
+
+import "org-dartlang-testcase:///issue41496b.dart";
+
+class C extends core::Object {
+  static field () → void f2 = null;
+  synthetic constructor •() → iss::C
+    : super core::Object::•()
+    ;
+}
+static field () → void f1;
+static method main() → dynamic {
+  new iss::C::•();
+}
diff --git a/pkg/front_end/testcases/nnbd/issue41496b.dart.weak.transformed.expect b/pkg/front_end/testcases/nnbd/issue41496b.dart.weak.transformed.expect
new file mode 100644
index 0000000..b70a566
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/issue41496b.dart.weak.transformed.expect
@@ -0,0 +1,39 @@
+library opted_out_lib;
+import self as self;
+import "issue41496b_lib.dart" as iss;
+
+import "org-dartlang-testcase:///issue41496b_lib.dart" as opt_in;
+
+typedef LegacyFoo = () →* void;
+static method test(() →* void f) → dynamic {}
+static method main() → dynamic {
+  iss::main();
+}
+
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/nnbd/issue41496b_lib.dart:7:11: Error: Field 'f1' should be initialized because its type 'void Function()' doesn't allow null.
+// LegacyFoo f1;
+//           ^^
+//
+// pkg/front_end/testcases/nnbd/issue41496b_lib.dart:10:20: Error: Field 'f2' should be initialized because its type 'void Function()' doesn't allow null.
+//   static LegacyFoo f2;
+//                    ^^
+//
+import self as iss;
+import "dart:core" as core;
+
+import "org-dartlang-testcase:///issue41496b.dart";
+
+class C extends core::Object {
+  static field () → void f2 = null;
+  synthetic constructor •() → iss::C
+    : super core::Object::•()
+    ;
+}
+static field () → void f1;
+static method main() → dynamic {
+  new iss::C::•();
+}
diff --git a/pkg/front_end/testcases/nnbd/issue41496b_lib.dart b/pkg/front_end/testcases/nnbd/issue41496b_lib.dart
new file mode 100644
index 0000000..06bf01a
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/issue41496b_lib.dart
@@ -0,0 +1,15 @@
+// Copyright (c) 2020, 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.
+
+import "issue41496b.dart";
+
+LegacyFoo f1;
+
+class C {
+  static LegacyFoo f2;
+}
+
+main() {
+  new C();
+}
diff --git a/pkg/front_end/testcases/nnbd/issue41498.dart b/pkg/front_end/testcases/nnbd/issue41498.dart
new file mode 100644
index 0000000..e6c1130
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/issue41498.dart
@@ -0,0 +1,35 @@
+// Copyright (c) 2020, 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.
+
+import "issue41498_lib.dart";
+
+class C {
+  static void test() {
+    LegacyFoo f;
+
+    f.toString(); // error
+  }
+
+  void test2() {
+    LegacyFoo f;
+
+    f.toString(); // error
+  }
+}
+
+test() {
+  LegacyFoo f;
+
+  f.toString(); // error
+
+  Function foo = () {
+    LegacyFoo f;
+
+    f.toString(); // error
+  };
+  C.test();
+  new C().test2();
+}
+
+main() {}
diff --git a/pkg/front_end/testcases/nnbd/issue41498.dart.outline.expect b/pkg/front_end/testcases/nnbd/issue41498.dart.outline.expect
new file mode 100644
index 0000000..b4fdb09
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/issue41498.dart.outline.expect
@@ -0,0 +1,34 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "dart:core" as core;
+
+import "org-dartlang-testcase:///issue41498_lib.dart";
+
+class C extends core::Object {
+  synthetic constructor •() → self::C
+    ;
+  static method test() → void
+    ;
+  method test2() → void
+    ;
+}
+static method test() → dynamic
+  ;
+static method main() → dynamic
+  ;
+
+library opted_out_lib;
+import self as self2;
+import "dart:core" as core;
+
+typedef LegacyFoo = () →* void;
+class C extends core::Object {
+  synthetic constructor •() → self2::C*
+    ;
+  static method test() → void
+    ;
+  method test2() → void
+    ;
+}
+static method test() → dynamic
+  ;
diff --git a/pkg/front_end/testcases/nnbd/issue41498.dart.strong.expect b/pkg/front_end/testcases/nnbd/issue41498.dart.strong.expect
new file mode 100644
index 0000000..f2f0faa
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/issue41498.dart.strong.expect
@@ -0,0 +1,86 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/nnbd/issue41498.dart:11:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+//     f.toString(); // error
+//     ^
+//
+// pkg/front_end/testcases/nnbd/issue41498.dart:17:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+//     f.toString(); // error
+//     ^
+//
+// pkg/front_end/testcases/nnbd/issue41498.dart:24:3: Error: Non-nullable variable 'f' must be assigned before it can be used.
+//   f.toString(); // error
+//   ^
+//
+// pkg/front_end/testcases/nnbd/issue41498.dart:29:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+//     f.toString(); // error
+//     ^
+//
+import self as self;
+import "dart:core" as core;
+
+import "org-dartlang-testcase:///issue41498_lib.dart";
+
+class C extends core::Object {
+  synthetic constructor •() → self::C
+    : super core::Object::•()
+    ;
+  static method test() → void {
+    () → void f;
+    (let final<BottomType> #t1 = invalid-expression "pkg/front_end/testcases/nnbd/issue41498.dart:11:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+    f.toString(); // error
+    ^" in f).{core::Object::toString}();
+  }
+  method test2() → void {
+    () → void f;
+    (let final<BottomType> #t2 = invalid-expression "pkg/front_end/testcases/nnbd/issue41498.dart:17:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+    f.toString(); // error
+    ^" in f).{core::Object::toString}();
+  }
+}
+static method test() → dynamic {
+  () → void f;
+  (let final<BottomType> #t3 = invalid-expression "pkg/front_end/testcases/nnbd/issue41498.dart:24:3: Error: Non-nullable variable 'f' must be assigned before it can be used.
+  f.toString(); // error
+  ^" in f).{core::Object::toString}();
+  core::Function foo = () → core::Null? {
+    () → void f;
+    (let final<BottomType> #t4 = invalid-expression "pkg/front_end/testcases/nnbd/issue41498.dart:29:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+    f.toString(); // error
+    ^" in f).{core::Object::toString}();
+  };
+  self::C::test();
+  new self::C::•().{self::C::test2}();
+}
+static method main() → dynamic {}
+
+library opted_out_lib;
+import self as self2;
+import "dart:core" as core;
+
+typedef LegacyFoo = () →* void;
+class C extends core::Object {
+  synthetic constructor •() → self2::C*
+    : super core::Object::•()
+    ;
+  static method test() → void {
+    () →* void f;
+    f.{core::Object::toString}();
+  }
+  method test2() → void {
+    () →* void f;
+    f.{core::Object::toString}();
+  }
+}
+static method test() → dynamic {
+  () →* void f;
+  f.{core::Object::toString}();
+  core::Function* foo = () → core::Null? {
+    () →* void f;
+    f.{core::Object::toString}();
+  };
+  self2::C::test();
+  new self2::C::•().{self2::C::test2}();
+}
diff --git a/pkg/front_end/testcases/nnbd/issue41498.dart.strong.transformed.expect b/pkg/front_end/testcases/nnbd/issue41498.dart.strong.transformed.expect
new file mode 100644
index 0000000..f2f0faa
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/issue41498.dart.strong.transformed.expect
@@ -0,0 +1,86 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/nnbd/issue41498.dart:11:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+//     f.toString(); // error
+//     ^
+//
+// pkg/front_end/testcases/nnbd/issue41498.dart:17:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+//     f.toString(); // error
+//     ^
+//
+// pkg/front_end/testcases/nnbd/issue41498.dart:24:3: Error: Non-nullable variable 'f' must be assigned before it can be used.
+//   f.toString(); // error
+//   ^
+//
+// pkg/front_end/testcases/nnbd/issue41498.dart:29:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+//     f.toString(); // error
+//     ^
+//
+import self as self;
+import "dart:core" as core;
+
+import "org-dartlang-testcase:///issue41498_lib.dart";
+
+class C extends core::Object {
+  synthetic constructor •() → self::C
+    : super core::Object::•()
+    ;
+  static method test() → void {
+    () → void f;
+    (let final<BottomType> #t1 = invalid-expression "pkg/front_end/testcases/nnbd/issue41498.dart:11:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+    f.toString(); // error
+    ^" in f).{core::Object::toString}();
+  }
+  method test2() → void {
+    () → void f;
+    (let final<BottomType> #t2 = invalid-expression "pkg/front_end/testcases/nnbd/issue41498.dart:17:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+    f.toString(); // error
+    ^" in f).{core::Object::toString}();
+  }
+}
+static method test() → dynamic {
+  () → void f;
+  (let final<BottomType> #t3 = invalid-expression "pkg/front_end/testcases/nnbd/issue41498.dart:24:3: Error: Non-nullable variable 'f' must be assigned before it can be used.
+  f.toString(); // error
+  ^" in f).{core::Object::toString}();
+  core::Function foo = () → core::Null? {
+    () → void f;
+    (let final<BottomType> #t4 = invalid-expression "pkg/front_end/testcases/nnbd/issue41498.dart:29:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+    f.toString(); // error
+    ^" in f).{core::Object::toString}();
+  };
+  self::C::test();
+  new self::C::•().{self::C::test2}();
+}
+static method main() → dynamic {}
+
+library opted_out_lib;
+import self as self2;
+import "dart:core" as core;
+
+typedef LegacyFoo = () →* void;
+class C extends core::Object {
+  synthetic constructor •() → self2::C*
+    : super core::Object::•()
+    ;
+  static method test() → void {
+    () →* void f;
+    f.{core::Object::toString}();
+  }
+  method test2() → void {
+    () →* void f;
+    f.{core::Object::toString}();
+  }
+}
+static method test() → dynamic {
+  () →* void f;
+  f.{core::Object::toString}();
+  core::Function* foo = () → core::Null? {
+    () →* void f;
+    f.{core::Object::toString}();
+  };
+  self2::C::test();
+  new self2::C::•().{self2::C::test2}();
+}
diff --git a/pkg/front_end/testcases/nnbd/issue41498.dart.weak.expect b/pkg/front_end/testcases/nnbd/issue41498.dart.weak.expect
new file mode 100644
index 0000000..f2f0faa
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/issue41498.dart.weak.expect
@@ -0,0 +1,86 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/nnbd/issue41498.dart:11:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+//     f.toString(); // error
+//     ^
+//
+// pkg/front_end/testcases/nnbd/issue41498.dart:17:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+//     f.toString(); // error
+//     ^
+//
+// pkg/front_end/testcases/nnbd/issue41498.dart:24:3: Error: Non-nullable variable 'f' must be assigned before it can be used.
+//   f.toString(); // error
+//   ^
+//
+// pkg/front_end/testcases/nnbd/issue41498.dart:29:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+//     f.toString(); // error
+//     ^
+//
+import self as self;
+import "dart:core" as core;
+
+import "org-dartlang-testcase:///issue41498_lib.dart";
+
+class C extends core::Object {
+  synthetic constructor •() → self::C
+    : super core::Object::•()
+    ;
+  static method test() → void {
+    () → void f;
+    (let final<BottomType> #t1 = invalid-expression "pkg/front_end/testcases/nnbd/issue41498.dart:11:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+    f.toString(); // error
+    ^" in f).{core::Object::toString}();
+  }
+  method test2() → void {
+    () → void f;
+    (let final<BottomType> #t2 = invalid-expression "pkg/front_end/testcases/nnbd/issue41498.dart:17:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+    f.toString(); // error
+    ^" in f).{core::Object::toString}();
+  }
+}
+static method test() → dynamic {
+  () → void f;
+  (let final<BottomType> #t3 = invalid-expression "pkg/front_end/testcases/nnbd/issue41498.dart:24:3: Error: Non-nullable variable 'f' must be assigned before it can be used.
+  f.toString(); // error
+  ^" in f).{core::Object::toString}();
+  core::Function foo = () → core::Null? {
+    () → void f;
+    (let final<BottomType> #t4 = invalid-expression "pkg/front_end/testcases/nnbd/issue41498.dart:29:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+    f.toString(); // error
+    ^" in f).{core::Object::toString}();
+  };
+  self::C::test();
+  new self::C::•().{self::C::test2}();
+}
+static method main() → dynamic {}
+
+library opted_out_lib;
+import self as self2;
+import "dart:core" as core;
+
+typedef LegacyFoo = () →* void;
+class C extends core::Object {
+  synthetic constructor •() → self2::C*
+    : super core::Object::•()
+    ;
+  static method test() → void {
+    () →* void f;
+    f.{core::Object::toString}();
+  }
+  method test2() → void {
+    () →* void f;
+    f.{core::Object::toString}();
+  }
+}
+static method test() → dynamic {
+  () →* void f;
+  f.{core::Object::toString}();
+  core::Function* foo = () → core::Null? {
+    () →* void f;
+    f.{core::Object::toString}();
+  };
+  self2::C::test();
+  new self2::C::•().{self2::C::test2}();
+}
diff --git a/pkg/front_end/testcases/nnbd/issue41498.dart.weak.transformed.expect b/pkg/front_end/testcases/nnbd/issue41498.dart.weak.transformed.expect
new file mode 100644
index 0000000..f2f0faa
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/issue41498.dart.weak.transformed.expect
@@ -0,0 +1,86 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/nnbd/issue41498.dart:11:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+//     f.toString(); // error
+//     ^
+//
+// pkg/front_end/testcases/nnbd/issue41498.dart:17:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+//     f.toString(); // error
+//     ^
+//
+// pkg/front_end/testcases/nnbd/issue41498.dart:24:3: Error: Non-nullable variable 'f' must be assigned before it can be used.
+//   f.toString(); // error
+//   ^
+//
+// pkg/front_end/testcases/nnbd/issue41498.dart:29:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+//     f.toString(); // error
+//     ^
+//
+import self as self;
+import "dart:core" as core;
+
+import "org-dartlang-testcase:///issue41498_lib.dart";
+
+class C extends core::Object {
+  synthetic constructor •() → self::C
+    : super core::Object::•()
+    ;
+  static method test() → void {
+    () → void f;
+    (let final<BottomType> #t1 = invalid-expression "pkg/front_end/testcases/nnbd/issue41498.dart:11:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+    f.toString(); // error
+    ^" in f).{core::Object::toString}();
+  }
+  method test2() → void {
+    () → void f;
+    (let final<BottomType> #t2 = invalid-expression "pkg/front_end/testcases/nnbd/issue41498.dart:17:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+    f.toString(); // error
+    ^" in f).{core::Object::toString}();
+  }
+}
+static method test() → dynamic {
+  () → void f;
+  (let final<BottomType> #t3 = invalid-expression "pkg/front_end/testcases/nnbd/issue41498.dart:24:3: Error: Non-nullable variable 'f' must be assigned before it can be used.
+  f.toString(); // error
+  ^" in f).{core::Object::toString}();
+  core::Function foo = () → core::Null? {
+    () → void f;
+    (let final<BottomType> #t4 = invalid-expression "pkg/front_end/testcases/nnbd/issue41498.dart:29:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+    f.toString(); // error
+    ^" in f).{core::Object::toString}();
+  };
+  self::C::test();
+  new self::C::•().{self::C::test2}();
+}
+static method main() → dynamic {}
+
+library opted_out_lib;
+import self as self2;
+import "dart:core" as core;
+
+typedef LegacyFoo = () →* void;
+class C extends core::Object {
+  synthetic constructor •() → self2::C*
+    : super core::Object::•()
+    ;
+  static method test() → void {
+    () →* void f;
+    f.{core::Object::toString}();
+  }
+  method test2() → void {
+    () →* void f;
+    f.{core::Object::toString}();
+  }
+}
+static method test() → dynamic {
+  () →* void f;
+  f.{core::Object::toString}();
+  core::Function* foo = () → core::Null? {
+    () →* void f;
+    f.{core::Object::toString}();
+  };
+  self2::C::test();
+  new self2::C::•().{self2::C::test2}();
+}
diff --git a/pkg/front_end/testcases/nnbd/issue41498_lib.dart b/pkg/front_end/testcases/nnbd/issue41498_lib.dart
new file mode 100644
index 0000000..9d4a423
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/issue41498_lib.dart
@@ -0,0 +1,36 @@
+// Copyright (c) 2020, 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.
+
+// @dart=2.6
+library opted_out_lib;
+
+typedef void LegacyFoo();
+
+class C {
+  static void test() {
+    LegacyFoo f;
+
+    f.toString(); // ok
+  }
+
+  void test2() {
+    LegacyFoo f;
+
+    f.toString(); // ok
+  }
+}
+
+test() {
+  LegacyFoo f;
+
+  f.toString(); // ok
+
+  Function foo = () {
+    LegacyFoo f;
+
+    f.toString(); // ok
+  };
+  C.test();
+  new C().test2();
+}
diff --git a/pkg/front_end/testcases/nnbd/issue41498b.dart b/pkg/front_end/testcases/nnbd/issue41498b.dart
new file mode 100644
index 0000000..4a6a49c
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/issue41498b.dart
@@ -0,0 +1,42 @@
+// Copyright (c) 2020, 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.
+
+// @dart=2.6
+library opted_out_lib;
+
+import 'issue41498b_lib.dart' as opt_in;
+
+typedef void LegacyFoo();
+
+class C {
+  static void test() {
+    LegacyFoo f;
+
+    f.toString(); // ok
+  }
+
+  void test2() {
+    LegacyFoo f;
+
+    f.toString(); // ok
+  }
+}
+
+test() {
+  LegacyFoo f;
+
+  f.toString(); // ok
+
+  Function foo = () {
+    LegacyFoo f;
+
+    f.toString(); // ok
+  };
+  C.test();
+  new C().test2();
+}
+
+main() {
+  opt_in.main();
+}
diff --git a/pkg/front_end/testcases/nnbd/issue41498b.dart.outline.expect b/pkg/front_end/testcases/nnbd/issue41498b.dart.outline.expect
new file mode 100644
index 0000000..86599c8
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/issue41498b.dart.outline.expect
@@ -0,0 +1,38 @@
+library opted_out_lib;
+import self as self;
+import "dart:core" as core;
+
+import "org-dartlang-testcase:///issue41498b_lib.dart" as opt_in;
+
+typedef LegacyFoo = () →* void;
+class C extends core::Object {
+  synthetic constructor •() → self::C*
+    ;
+  static method test() → void
+    ;
+  method test2() → void
+    ;
+}
+static method test() → dynamic
+  ;
+static method main() → dynamic
+  ;
+
+library /*isNonNullableByDefault*/;
+import self as self2;
+import "dart:core" as core;
+
+import "org-dartlang-testcase:///issue41498b.dart";
+
+class C extends core::Object {
+  synthetic constructor •() → self2::C
+    ;
+  static method test() → void
+    ;
+  method test2() → void
+    ;
+}
+static method test() → dynamic
+  ;
+static method main() → dynamic
+  ;
diff --git a/pkg/front_end/testcases/nnbd/issue41498b.dart.strong.expect b/pkg/front_end/testcases/nnbd/issue41498b.dart.strong.expect
new file mode 100644
index 0000000..6d86cf5
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/issue41498b.dart.strong.expect
@@ -0,0 +1,92 @@
+library opted_out_lib;
+import self as self;
+import "dart:core" as core;
+import "issue41498b_lib.dart" as iss;
+
+import "org-dartlang-testcase:///issue41498b_lib.dart" as opt_in;
+
+typedef LegacyFoo = () →* void;
+class C extends core::Object {
+  synthetic constructor •() → self::C*
+    : super core::Object::•()
+    ;
+  static method test() → void {
+    () →* void f;
+    f.{core::Object::toString}();
+  }
+  method test2() → void {
+    () →* void f;
+    f.{core::Object::toString}();
+  }
+}
+static method test() → dynamic {
+  () →* void f;
+  f.{core::Object::toString}();
+  core::Function* foo = () → core::Null? {
+    () →* void f;
+    f.{core::Object::toString}();
+  };
+  self::C::test();
+  new self::C::•().{self::C::test2}();
+}
+static method main() → dynamic {
+  iss::main();
+}
+
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/nnbd/issue41498b_lib.dart:11:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+//     f.toString(); // error
+//     ^
+//
+// pkg/front_end/testcases/nnbd/issue41498b_lib.dart:17:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+//     f.toString(); // error
+//     ^
+//
+// pkg/front_end/testcases/nnbd/issue41498b_lib.dart:24:3: Error: Non-nullable variable 'f' must be assigned before it can be used.
+//   f.toString(); // error
+//   ^
+//
+// pkg/front_end/testcases/nnbd/issue41498b_lib.dart:29:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+//     f.toString(); // error
+//     ^
+//
+import self as iss;
+import "dart:core" as core;
+
+import "org-dartlang-testcase:///issue41498b.dart";
+
+class C extends core::Object {
+  synthetic constructor •() → iss::C
+    : super core::Object::•()
+    ;
+  static method test() → void {
+    () → void f;
+    (let final<BottomType> #t1 = invalid-expression "pkg/front_end/testcases/nnbd/issue41498b_lib.dart:11:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+    f.toString(); // error
+    ^" in f).{core::Object::toString}();
+  }
+  method test2() → void {
+    () → void f;
+    (let final<BottomType> #t2 = invalid-expression "pkg/front_end/testcases/nnbd/issue41498b_lib.dart:17:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+    f.toString(); // error
+    ^" in f).{core::Object::toString}();
+  }
+}
+static method test() → dynamic {
+  () → void f;
+  (let final<BottomType> #t3 = invalid-expression "pkg/front_end/testcases/nnbd/issue41498b_lib.dart:24:3: Error: Non-nullable variable 'f' must be assigned before it can be used.
+  f.toString(); // error
+  ^" in f).{core::Object::toString}();
+  core::Function foo = () → core::Null? {
+    () → void f;
+    (let final<BottomType> #t4 = invalid-expression "pkg/front_end/testcases/nnbd/issue41498b_lib.dart:29:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+    f.toString(); // error
+    ^" in f).{core::Object::toString}();
+  };
+  iss::C::test();
+  new iss::C::•().{iss::C::test2}();
+}
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/nnbd/issue41498b.dart.strong.transformed.expect b/pkg/front_end/testcases/nnbd/issue41498b.dart.strong.transformed.expect
new file mode 100644
index 0000000..6d86cf5
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/issue41498b.dart.strong.transformed.expect
@@ -0,0 +1,92 @@
+library opted_out_lib;
+import self as self;
+import "dart:core" as core;
+import "issue41498b_lib.dart" as iss;
+
+import "org-dartlang-testcase:///issue41498b_lib.dart" as opt_in;
+
+typedef LegacyFoo = () →* void;
+class C extends core::Object {
+  synthetic constructor •() → self::C*
+    : super core::Object::•()
+    ;
+  static method test() → void {
+    () →* void f;
+    f.{core::Object::toString}();
+  }
+  method test2() → void {
+    () →* void f;
+    f.{core::Object::toString}();
+  }
+}
+static method test() → dynamic {
+  () →* void f;
+  f.{core::Object::toString}();
+  core::Function* foo = () → core::Null? {
+    () →* void f;
+    f.{core::Object::toString}();
+  };
+  self::C::test();
+  new self::C::•().{self::C::test2}();
+}
+static method main() → dynamic {
+  iss::main();
+}
+
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/nnbd/issue41498b_lib.dart:11:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+//     f.toString(); // error
+//     ^
+//
+// pkg/front_end/testcases/nnbd/issue41498b_lib.dart:17:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+//     f.toString(); // error
+//     ^
+//
+// pkg/front_end/testcases/nnbd/issue41498b_lib.dart:24:3: Error: Non-nullable variable 'f' must be assigned before it can be used.
+//   f.toString(); // error
+//   ^
+//
+// pkg/front_end/testcases/nnbd/issue41498b_lib.dart:29:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+//     f.toString(); // error
+//     ^
+//
+import self as iss;
+import "dart:core" as core;
+
+import "org-dartlang-testcase:///issue41498b.dart";
+
+class C extends core::Object {
+  synthetic constructor •() → iss::C
+    : super core::Object::•()
+    ;
+  static method test() → void {
+    () → void f;
+    (let final<BottomType> #t1 = invalid-expression "pkg/front_end/testcases/nnbd/issue41498b_lib.dart:11:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+    f.toString(); // error
+    ^" in f).{core::Object::toString}();
+  }
+  method test2() → void {
+    () → void f;
+    (let final<BottomType> #t2 = invalid-expression "pkg/front_end/testcases/nnbd/issue41498b_lib.dart:17:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+    f.toString(); // error
+    ^" in f).{core::Object::toString}();
+  }
+}
+static method test() → dynamic {
+  () → void f;
+  (let final<BottomType> #t3 = invalid-expression "pkg/front_end/testcases/nnbd/issue41498b_lib.dart:24:3: Error: Non-nullable variable 'f' must be assigned before it can be used.
+  f.toString(); // error
+  ^" in f).{core::Object::toString}();
+  core::Function foo = () → core::Null? {
+    () → void f;
+    (let final<BottomType> #t4 = invalid-expression "pkg/front_end/testcases/nnbd/issue41498b_lib.dart:29:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+    f.toString(); // error
+    ^" in f).{core::Object::toString}();
+  };
+  iss::C::test();
+  new iss::C::•().{iss::C::test2}();
+}
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/nnbd/issue41498b.dart.weak.expect b/pkg/front_end/testcases/nnbd/issue41498b.dart.weak.expect
new file mode 100644
index 0000000..6d86cf5
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/issue41498b.dart.weak.expect
@@ -0,0 +1,92 @@
+library opted_out_lib;
+import self as self;
+import "dart:core" as core;
+import "issue41498b_lib.dart" as iss;
+
+import "org-dartlang-testcase:///issue41498b_lib.dart" as opt_in;
+
+typedef LegacyFoo = () →* void;
+class C extends core::Object {
+  synthetic constructor •() → self::C*
+    : super core::Object::•()
+    ;
+  static method test() → void {
+    () →* void f;
+    f.{core::Object::toString}();
+  }
+  method test2() → void {
+    () →* void f;
+    f.{core::Object::toString}();
+  }
+}
+static method test() → dynamic {
+  () →* void f;
+  f.{core::Object::toString}();
+  core::Function* foo = () → core::Null? {
+    () →* void f;
+    f.{core::Object::toString}();
+  };
+  self::C::test();
+  new self::C::•().{self::C::test2}();
+}
+static method main() → dynamic {
+  iss::main();
+}
+
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/nnbd/issue41498b_lib.dart:11:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+//     f.toString(); // error
+//     ^
+//
+// pkg/front_end/testcases/nnbd/issue41498b_lib.dart:17:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+//     f.toString(); // error
+//     ^
+//
+// pkg/front_end/testcases/nnbd/issue41498b_lib.dart:24:3: Error: Non-nullable variable 'f' must be assigned before it can be used.
+//   f.toString(); // error
+//   ^
+//
+// pkg/front_end/testcases/nnbd/issue41498b_lib.dart:29:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+//     f.toString(); // error
+//     ^
+//
+import self as iss;
+import "dart:core" as core;
+
+import "org-dartlang-testcase:///issue41498b.dart";
+
+class C extends core::Object {
+  synthetic constructor •() → iss::C
+    : super core::Object::•()
+    ;
+  static method test() → void {
+    () → void f;
+    (let final<BottomType> #t1 = invalid-expression "pkg/front_end/testcases/nnbd/issue41498b_lib.dart:11:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+    f.toString(); // error
+    ^" in f).{core::Object::toString}();
+  }
+  method test2() → void {
+    () → void f;
+    (let final<BottomType> #t2 = invalid-expression "pkg/front_end/testcases/nnbd/issue41498b_lib.dart:17:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+    f.toString(); // error
+    ^" in f).{core::Object::toString}();
+  }
+}
+static method test() → dynamic {
+  () → void f;
+  (let final<BottomType> #t3 = invalid-expression "pkg/front_end/testcases/nnbd/issue41498b_lib.dart:24:3: Error: Non-nullable variable 'f' must be assigned before it can be used.
+  f.toString(); // error
+  ^" in f).{core::Object::toString}();
+  core::Function foo = () → core::Null? {
+    () → void f;
+    (let final<BottomType> #t4 = invalid-expression "pkg/front_end/testcases/nnbd/issue41498b_lib.dart:29:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+    f.toString(); // error
+    ^" in f).{core::Object::toString}();
+  };
+  iss::C::test();
+  new iss::C::•().{iss::C::test2}();
+}
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/nnbd/issue41498b.dart.weak.transformed.expect b/pkg/front_end/testcases/nnbd/issue41498b.dart.weak.transformed.expect
new file mode 100644
index 0000000..6d86cf5
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/issue41498b.dart.weak.transformed.expect
@@ -0,0 +1,92 @@
+library opted_out_lib;
+import self as self;
+import "dart:core" as core;
+import "issue41498b_lib.dart" as iss;
+
+import "org-dartlang-testcase:///issue41498b_lib.dart" as opt_in;
+
+typedef LegacyFoo = () →* void;
+class C extends core::Object {
+  synthetic constructor •() → self::C*
+    : super core::Object::•()
+    ;
+  static method test() → void {
+    () →* void f;
+    f.{core::Object::toString}();
+  }
+  method test2() → void {
+    () →* void f;
+    f.{core::Object::toString}();
+  }
+}
+static method test() → dynamic {
+  () →* void f;
+  f.{core::Object::toString}();
+  core::Function* foo = () → core::Null? {
+    () →* void f;
+    f.{core::Object::toString}();
+  };
+  self::C::test();
+  new self::C::•().{self::C::test2}();
+}
+static method main() → dynamic {
+  iss::main();
+}
+
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/nnbd/issue41498b_lib.dart:11:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+//     f.toString(); // error
+//     ^
+//
+// pkg/front_end/testcases/nnbd/issue41498b_lib.dart:17:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+//     f.toString(); // error
+//     ^
+//
+// pkg/front_end/testcases/nnbd/issue41498b_lib.dart:24:3: Error: Non-nullable variable 'f' must be assigned before it can be used.
+//   f.toString(); // error
+//   ^
+//
+// pkg/front_end/testcases/nnbd/issue41498b_lib.dart:29:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+//     f.toString(); // error
+//     ^
+//
+import self as iss;
+import "dart:core" as core;
+
+import "org-dartlang-testcase:///issue41498b.dart";
+
+class C extends core::Object {
+  synthetic constructor •() → iss::C
+    : super core::Object::•()
+    ;
+  static method test() → void {
+    () → void f;
+    (let final<BottomType> #t1 = invalid-expression "pkg/front_end/testcases/nnbd/issue41498b_lib.dart:11:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+    f.toString(); // error
+    ^" in f).{core::Object::toString}();
+  }
+  method test2() → void {
+    () → void f;
+    (let final<BottomType> #t2 = invalid-expression "pkg/front_end/testcases/nnbd/issue41498b_lib.dart:17:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+    f.toString(); // error
+    ^" in f).{core::Object::toString}();
+  }
+}
+static method test() → dynamic {
+  () → void f;
+  (let final<BottomType> #t3 = invalid-expression "pkg/front_end/testcases/nnbd/issue41498b_lib.dart:24:3: Error: Non-nullable variable 'f' must be assigned before it can be used.
+  f.toString(); // error
+  ^" in f).{core::Object::toString}();
+  core::Function foo = () → core::Null? {
+    () → void f;
+    (let final<BottomType> #t4 = invalid-expression "pkg/front_end/testcases/nnbd/issue41498b_lib.dart:29:5: Error: Non-nullable variable 'f' must be assigned before it can be used.
+    f.toString(); // error
+    ^" in f).{core::Object::toString}();
+  };
+  iss::C::test();
+  new iss::C::•().{iss::C::test2}();
+}
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/nnbd/issue41498b_lib.dart b/pkg/front_end/testcases/nnbd/issue41498b_lib.dart
new file mode 100644
index 0000000..ba3e746
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/issue41498b_lib.dart
@@ -0,0 +1,35 @@
+// Copyright (c) 2020, 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.
+
+import "issue41498b.dart";
+
+class C {
+  static void test() {
+    LegacyFoo f;
+
+    f.toString(); // error
+  }
+
+  void test2() {
+    LegacyFoo f;
+
+    f.toString(); // error
+  }
+}
+
+test() {
+  LegacyFoo f;
+
+  f.toString(); // error
+
+  Function foo = () {
+    LegacyFoo f;
+
+    f.toString(); // error
+  };
+  C.test();
+  new C().test2();
+}
+
+main() {}
diff --git a/pkg/front_end/testcases/nnbd/issue41499.dart b/pkg/front_end/testcases/nnbd/issue41499.dart
new file mode 100644
index 0000000..60fac65
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/issue41499.dart
@@ -0,0 +1,17 @@
+// Copyright (c) 2020, 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.
+
+import "issue41499_lib.dart";
+
+class C {
+  static LegacyFoo sTest() {}
+
+  LegacyFoo mTest() {}
+
+  LegacyFoo get gTest {}
+}
+
+LegacyFoo test() {}
+
+main() {}
diff --git a/pkg/front_end/testcases/nnbd/issue41499.dart.outline.expect b/pkg/front_end/testcases/nnbd/issue41499.dart.outline.expect
new file mode 100644
index 0000000..4b8ad7d
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/issue41499.dart.outline.expect
@@ -0,0 +1,27 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "dart:core" as core;
+
+import "org-dartlang-testcase:///issue41499_lib.dart";
+
+class C extends core::Object {
+  synthetic constructor •() → self::C
+    ;
+  static method sTest() → () → void
+    ;
+  method mTest() → () → void
+    ;
+  get gTest() → () → void
+    ;
+}
+static method test() → () → void
+  ;
+static method main() → dynamic
+  ;
+
+library;
+import self as self2;
+
+typedef LegacyFoo = () →* void;
+static method test(() →* void f) → dynamic
+  ;
diff --git a/pkg/front_end/testcases/nnbd/issue41499.dart.strong.expect b/pkg/front_end/testcases/nnbd/issue41499.dart.strong.expect
new file mode 100644
index 0000000..e55976c
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/issue41499.dart.strong.expect
@@ -0,0 +1,57 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/nnbd/issue41499.dart:8:20: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+//   static LegacyFoo sTest() {}
+//                    ^
+//
+// pkg/front_end/testcases/nnbd/issue41499.dart:10:13: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+//   LegacyFoo mTest() {}
+//             ^
+//
+// pkg/front_end/testcases/nnbd/issue41499.dart:12:17: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+//   LegacyFoo get gTest {}
+//                 ^
+//
+// pkg/front_end/testcases/nnbd/issue41499.dart:15:11: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+// LegacyFoo test() {}
+//           ^
+//
+import self as self;
+import "dart:core" as core;
+
+import "org-dartlang-testcase:///issue41499_lib.dart";
+
+class C extends core::Object {
+  synthetic constructor •() → self::C
+    : super core::Object::•()
+    ;
+  static method sTest() → () → void {
+    return let final<BottomType> #t1 = invalid-expression "pkg/front_end/testcases/nnbd/issue41499.dart:8:20: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+  static LegacyFoo sTest() {}
+                   ^" in null;
+  }
+  method mTest() → () → void {
+    return let final<BottomType> #t2 = invalid-expression "pkg/front_end/testcases/nnbd/issue41499.dart:10:13: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+  LegacyFoo mTest() {}
+            ^" in null;
+  }
+  get gTest() → () → void {
+    return let final<BottomType> #t3 = invalid-expression "pkg/front_end/testcases/nnbd/issue41499.dart:12:17: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+  LegacyFoo get gTest {}
+                ^" in null;
+  }
+}
+static method test() → () → void {
+  return let final<BottomType> #t4 = invalid-expression "pkg/front_end/testcases/nnbd/issue41499.dart:15:11: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+LegacyFoo test() {}
+          ^" in null;
+}
+static method main() → dynamic {}
+
+library;
+import self as self2;
+
+typedef LegacyFoo = () →* void;
+static method test(() →* void f) → dynamic {}
diff --git a/pkg/front_end/testcases/nnbd/issue41499.dart.strong.transformed.expect b/pkg/front_end/testcases/nnbd/issue41499.dart.strong.transformed.expect
new file mode 100644
index 0000000..e55976c
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/issue41499.dart.strong.transformed.expect
@@ -0,0 +1,57 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/nnbd/issue41499.dart:8:20: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+//   static LegacyFoo sTest() {}
+//                    ^
+//
+// pkg/front_end/testcases/nnbd/issue41499.dart:10:13: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+//   LegacyFoo mTest() {}
+//             ^
+//
+// pkg/front_end/testcases/nnbd/issue41499.dart:12:17: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+//   LegacyFoo get gTest {}
+//                 ^
+//
+// pkg/front_end/testcases/nnbd/issue41499.dart:15:11: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+// LegacyFoo test() {}
+//           ^
+//
+import self as self;
+import "dart:core" as core;
+
+import "org-dartlang-testcase:///issue41499_lib.dart";
+
+class C extends core::Object {
+  synthetic constructor •() → self::C
+    : super core::Object::•()
+    ;
+  static method sTest() → () → void {
+    return let final<BottomType> #t1 = invalid-expression "pkg/front_end/testcases/nnbd/issue41499.dart:8:20: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+  static LegacyFoo sTest() {}
+                   ^" in null;
+  }
+  method mTest() → () → void {
+    return let final<BottomType> #t2 = invalid-expression "pkg/front_end/testcases/nnbd/issue41499.dart:10:13: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+  LegacyFoo mTest() {}
+            ^" in null;
+  }
+  get gTest() → () → void {
+    return let final<BottomType> #t3 = invalid-expression "pkg/front_end/testcases/nnbd/issue41499.dart:12:17: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+  LegacyFoo get gTest {}
+                ^" in null;
+  }
+}
+static method test() → () → void {
+  return let final<BottomType> #t4 = invalid-expression "pkg/front_end/testcases/nnbd/issue41499.dart:15:11: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+LegacyFoo test() {}
+          ^" in null;
+}
+static method main() → dynamic {}
+
+library;
+import self as self2;
+
+typedef LegacyFoo = () →* void;
+static method test(() →* void f) → dynamic {}
diff --git a/pkg/front_end/testcases/nnbd/issue41499.dart.weak.expect b/pkg/front_end/testcases/nnbd/issue41499.dart.weak.expect
new file mode 100644
index 0000000..e55976c
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/issue41499.dart.weak.expect
@@ -0,0 +1,57 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/nnbd/issue41499.dart:8:20: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+//   static LegacyFoo sTest() {}
+//                    ^
+//
+// pkg/front_end/testcases/nnbd/issue41499.dart:10:13: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+//   LegacyFoo mTest() {}
+//             ^
+//
+// pkg/front_end/testcases/nnbd/issue41499.dart:12:17: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+//   LegacyFoo get gTest {}
+//                 ^
+//
+// pkg/front_end/testcases/nnbd/issue41499.dart:15:11: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+// LegacyFoo test() {}
+//           ^
+//
+import self as self;
+import "dart:core" as core;
+
+import "org-dartlang-testcase:///issue41499_lib.dart";
+
+class C extends core::Object {
+  synthetic constructor •() → self::C
+    : super core::Object::•()
+    ;
+  static method sTest() → () → void {
+    return let final<BottomType> #t1 = invalid-expression "pkg/front_end/testcases/nnbd/issue41499.dart:8:20: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+  static LegacyFoo sTest() {}
+                   ^" in null;
+  }
+  method mTest() → () → void {
+    return let final<BottomType> #t2 = invalid-expression "pkg/front_end/testcases/nnbd/issue41499.dart:10:13: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+  LegacyFoo mTest() {}
+            ^" in null;
+  }
+  get gTest() → () → void {
+    return let final<BottomType> #t3 = invalid-expression "pkg/front_end/testcases/nnbd/issue41499.dart:12:17: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+  LegacyFoo get gTest {}
+                ^" in null;
+  }
+}
+static method test() → () → void {
+  return let final<BottomType> #t4 = invalid-expression "pkg/front_end/testcases/nnbd/issue41499.dart:15:11: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+LegacyFoo test() {}
+          ^" in null;
+}
+static method main() → dynamic {}
+
+library;
+import self as self2;
+
+typedef LegacyFoo = () →* void;
+static method test(() →* void f) → dynamic {}
diff --git a/pkg/front_end/testcases/nnbd/issue41499.dart.weak.transformed.expect b/pkg/front_end/testcases/nnbd/issue41499.dart.weak.transformed.expect
new file mode 100644
index 0000000..e55976c
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/issue41499.dart.weak.transformed.expect
@@ -0,0 +1,57 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/nnbd/issue41499.dart:8:20: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+//   static LegacyFoo sTest() {}
+//                    ^
+//
+// pkg/front_end/testcases/nnbd/issue41499.dart:10:13: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+//   LegacyFoo mTest() {}
+//             ^
+//
+// pkg/front_end/testcases/nnbd/issue41499.dart:12:17: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+//   LegacyFoo get gTest {}
+//                 ^
+//
+// pkg/front_end/testcases/nnbd/issue41499.dart:15:11: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+// LegacyFoo test() {}
+//           ^
+//
+import self as self;
+import "dart:core" as core;
+
+import "org-dartlang-testcase:///issue41499_lib.dart";
+
+class C extends core::Object {
+  synthetic constructor •() → self::C
+    : super core::Object::•()
+    ;
+  static method sTest() → () → void {
+    return let final<BottomType> #t1 = invalid-expression "pkg/front_end/testcases/nnbd/issue41499.dart:8:20: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+  static LegacyFoo sTest() {}
+                   ^" in null;
+  }
+  method mTest() → () → void {
+    return let final<BottomType> #t2 = invalid-expression "pkg/front_end/testcases/nnbd/issue41499.dart:10:13: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+  LegacyFoo mTest() {}
+            ^" in null;
+  }
+  get gTest() → () → void {
+    return let final<BottomType> #t3 = invalid-expression "pkg/front_end/testcases/nnbd/issue41499.dart:12:17: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+  LegacyFoo get gTest {}
+                ^" in null;
+  }
+}
+static method test() → () → void {
+  return let final<BottomType> #t4 = invalid-expression "pkg/front_end/testcases/nnbd/issue41499.dart:15:11: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+LegacyFoo test() {}
+          ^" in null;
+}
+static method main() → dynamic {}
+
+library;
+import self as self2;
+
+typedef LegacyFoo = () →* void;
+static method test(() →* void f) → dynamic {}
diff --git a/pkg/front_end/testcases/nnbd/issue41499_lib.dart b/pkg/front_end/testcases/nnbd/issue41499_lib.dart
new file mode 100644
index 0000000..ae38a19
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/issue41499_lib.dart
@@ -0,0 +1,8 @@
+// Copyright (c) 2020, 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.
+
+// @dart=2.6
+typedef void LegacyFoo();
+
+test(LegacyFoo f) {}
diff --git a/pkg/front_end/testcases/nnbd/issue41499b.dart b/pkg/front_end/testcases/nnbd/issue41499b.dart
new file mode 100644
index 0000000..e03840c
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/issue41499b.dart
@@ -0,0 +1,13 @@
+// Copyright (c) 2020, 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.
+
+// @dart=2.6
+
+import 'issue41499b_lib.dart' as opt_in;
+
+typedef void LegacyFoo();
+
+test(LegacyFoo f) {}
+
+main() {}
diff --git a/pkg/front_end/testcases/nnbd/issue41499b.dart.outline.expect b/pkg/front_end/testcases/nnbd/issue41499b.dart.outline.expect
new file mode 100644
index 0000000..dd70ad6
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/issue41499b.dart.outline.expect
@@ -0,0 +1,29 @@
+library;
+import self as self;
+
+import "org-dartlang-testcase:///issue41499b_lib.dart" as opt_in;
+
+typedef LegacyFoo = () →* void;
+static method test(() →* void f) → dynamic
+  ;
+static method main() → dynamic
+  ;
+
+library /*isNonNullableByDefault*/;
+import self as self2;
+import "dart:core" as core;
+
+import "org-dartlang-testcase:///issue41499b.dart";
+
+class C extends core::Object {
+  synthetic constructor •() → self2::C
+    ;
+  static method sTest() → () → void
+    ;
+  method mTest() → () → void
+    ;
+  get gTest() → () → void
+    ;
+}
+static method test() → () → void
+  ;
diff --git a/pkg/front_end/testcases/nnbd/issue41499b.dart.strong.expect b/pkg/front_end/testcases/nnbd/issue41499b.dart.strong.expect
new file mode 100644
index 0000000..06d4715
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/issue41499b.dart.strong.expect
@@ -0,0 +1,59 @@
+library;
+import self as self;
+
+import "org-dartlang-testcase:///issue41499b_lib.dart" as opt_in;
+
+typedef LegacyFoo = () →* void;
+static method test(() →* void f) → dynamic {}
+static method main() → dynamic {}
+
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/nnbd/issue41499b_lib.dart:8:20: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+//   static LegacyFoo sTest() {}
+//                    ^
+//
+// pkg/front_end/testcases/nnbd/issue41499b_lib.dart:10:13: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+//   LegacyFoo mTest() {}
+//             ^
+//
+// pkg/front_end/testcases/nnbd/issue41499b_lib.dart:12:17: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+//   LegacyFoo get gTest {}
+//                 ^
+//
+// pkg/front_end/testcases/nnbd/issue41499b_lib.dart:15:11: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+// LegacyFoo test() {}
+//           ^
+//
+import self as self2;
+import "dart:core" as core;
+
+import "org-dartlang-testcase:///issue41499b.dart";
+
+class C extends core::Object {
+  synthetic constructor •() → self2::C
+    : super core::Object::•()
+    ;
+  static method sTest() → () → void {
+    return let final<BottomType> #t1 = invalid-expression "pkg/front_end/testcases/nnbd/issue41499b_lib.dart:8:20: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+  static LegacyFoo sTest() {}
+                   ^" in null;
+  }
+  method mTest() → () → void {
+    return let final<BottomType> #t2 = invalid-expression "pkg/front_end/testcases/nnbd/issue41499b_lib.dart:10:13: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+  LegacyFoo mTest() {}
+            ^" in null;
+  }
+  get gTest() → () → void {
+    return let final<BottomType> #t3 = invalid-expression "pkg/front_end/testcases/nnbd/issue41499b_lib.dart:12:17: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+  LegacyFoo get gTest {}
+                ^" in null;
+  }
+}
+static method test() → () → void {
+  return let final<BottomType> #t4 = invalid-expression "pkg/front_end/testcases/nnbd/issue41499b_lib.dart:15:11: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+LegacyFoo test() {}
+          ^" in null;
+}
diff --git a/pkg/front_end/testcases/nnbd/issue41499b.dart.strong.transformed.expect b/pkg/front_end/testcases/nnbd/issue41499b.dart.strong.transformed.expect
new file mode 100644
index 0000000..06d4715
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/issue41499b.dart.strong.transformed.expect
@@ -0,0 +1,59 @@
+library;
+import self as self;
+
+import "org-dartlang-testcase:///issue41499b_lib.dart" as opt_in;
+
+typedef LegacyFoo = () →* void;
+static method test(() →* void f) → dynamic {}
+static method main() → dynamic {}
+
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/nnbd/issue41499b_lib.dart:8:20: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+//   static LegacyFoo sTest() {}
+//                    ^
+//
+// pkg/front_end/testcases/nnbd/issue41499b_lib.dart:10:13: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+//   LegacyFoo mTest() {}
+//             ^
+//
+// pkg/front_end/testcases/nnbd/issue41499b_lib.dart:12:17: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+//   LegacyFoo get gTest {}
+//                 ^
+//
+// pkg/front_end/testcases/nnbd/issue41499b_lib.dart:15:11: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+// LegacyFoo test() {}
+//           ^
+//
+import self as self2;
+import "dart:core" as core;
+
+import "org-dartlang-testcase:///issue41499b.dart";
+
+class C extends core::Object {
+  synthetic constructor •() → self2::C
+    : super core::Object::•()
+    ;
+  static method sTest() → () → void {
+    return let final<BottomType> #t1 = invalid-expression "pkg/front_end/testcases/nnbd/issue41499b_lib.dart:8:20: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+  static LegacyFoo sTest() {}
+                   ^" in null;
+  }
+  method mTest() → () → void {
+    return let final<BottomType> #t2 = invalid-expression "pkg/front_end/testcases/nnbd/issue41499b_lib.dart:10:13: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+  LegacyFoo mTest() {}
+            ^" in null;
+  }
+  get gTest() → () → void {
+    return let final<BottomType> #t3 = invalid-expression "pkg/front_end/testcases/nnbd/issue41499b_lib.dart:12:17: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+  LegacyFoo get gTest {}
+                ^" in null;
+  }
+}
+static method test() → () → void {
+  return let final<BottomType> #t4 = invalid-expression "pkg/front_end/testcases/nnbd/issue41499b_lib.dart:15:11: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+LegacyFoo test() {}
+          ^" in null;
+}
diff --git a/pkg/front_end/testcases/nnbd/issue41499b.dart.weak.expect b/pkg/front_end/testcases/nnbd/issue41499b.dart.weak.expect
new file mode 100644
index 0000000..06d4715
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/issue41499b.dart.weak.expect
@@ -0,0 +1,59 @@
+library;
+import self as self;
+
+import "org-dartlang-testcase:///issue41499b_lib.dart" as opt_in;
+
+typedef LegacyFoo = () →* void;
+static method test(() →* void f) → dynamic {}
+static method main() → dynamic {}
+
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/nnbd/issue41499b_lib.dart:8:20: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+//   static LegacyFoo sTest() {}
+//                    ^
+//
+// pkg/front_end/testcases/nnbd/issue41499b_lib.dart:10:13: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+//   LegacyFoo mTest() {}
+//             ^
+//
+// pkg/front_end/testcases/nnbd/issue41499b_lib.dart:12:17: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+//   LegacyFoo get gTest {}
+//                 ^
+//
+// pkg/front_end/testcases/nnbd/issue41499b_lib.dart:15:11: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+// LegacyFoo test() {}
+//           ^
+//
+import self as self2;
+import "dart:core" as core;
+
+import "org-dartlang-testcase:///issue41499b.dart";
+
+class C extends core::Object {
+  synthetic constructor •() → self2::C
+    : super core::Object::•()
+    ;
+  static method sTest() → () → void {
+    return let final<BottomType> #t1 = invalid-expression "pkg/front_end/testcases/nnbd/issue41499b_lib.dart:8:20: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+  static LegacyFoo sTest() {}
+                   ^" in null;
+  }
+  method mTest() → () → void {
+    return let final<BottomType> #t2 = invalid-expression "pkg/front_end/testcases/nnbd/issue41499b_lib.dart:10:13: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+  LegacyFoo mTest() {}
+            ^" in null;
+  }
+  get gTest() → () → void {
+    return let final<BottomType> #t3 = invalid-expression "pkg/front_end/testcases/nnbd/issue41499b_lib.dart:12:17: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+  LegacyFoo get gTest {}
+                ^" in null;
+  }
+}
+static method test() → () → void {
+  return let final<BottomType> #t4 = invalid-expression "pkg/front_end/testcases/nnbd/issue41499b_lib.dart:15:11: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+LegacyFoo test() {}
+          ^" in null;
+}
diff --git a/pkg/front_end/testcases/nnbd/issue41499b.dart.weak.transformed.expect b/pkg/front_end/testcases/nnbd/issue41499b.dart.weak.transformed.expect
new file mode 100644
index 0000000..06d4715
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/issue41499b.dart.weak.transformed.expect
@@ -0,0 +1,59 @@
+library;
+import self as self;
+
+import "org-dartlang-testcase:///issue41499b_lib.dart" as opt_in;
+
+typedef LegacyFoo = () →* void;
+static method test(() →* void f) → dynamic {}
+static method main() → dynamic {}
+
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/nnbd/issue41499b_lib.dart:8:20: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+//   static LegacyFoo sTest() {}
+//                    ^
+//
+// pkg/front_end/testcases/nnbd/issue41499b_lib.dart:10:13: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+//   LegacyFoo mTest() {}
+//             ^
+//
+// pkg/front_end/testcases/nnbd/issue41499b_lib.dart:12:17: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+//   LegacyFoo get gTest {}
+//                 ^
+//
+// pkg/front_end/testcases/nnbd/issue41499b_lib.dart:15:11: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+// LegacyFoo test() {}
+//           ^
+//
+import self as self2;
+import "dart:core" as core;
+
+import "org-dartlang-testcase:///issue41499b.dart";
+
+class C extends core::Object {
+  synthetic constructor •() → self2::C
+    : super core::Object::•()
+    ;
+  static method sTest() → () → void {
+    return let final<BottomType> #t1 = invalid-expression "pkg/front_end/testcases/nnbd/issue41499b_lib.dart:8:20: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+  static LegacyFoo sTest() {}
+                   ^" in null;
+  }
+  method mTest() → () → void {
+    return let final<BottomType> #t2 = invalid-expression "pkg/front_end/testcases/nnbd/issue41499b_lib.dart:10:13: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+  LegacyFoo mTest() {}
+            ^" in null;
+  }
+  get gTest() → () → void {
+    return let final<BottomType> #t3 = invalid-expression "pkg/front_end/testcases/nnbd/issue41499b_lib.dart:12:17: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+  LegacyFoo get gTest {}
+                ^" in null;
+  }
+}
+static method test() → () → void {
+  return let final<BottomType> #t4 = invalid-expression "pkg/front_end/testcases/nnbd/issue41499b_lib.dart:15:11: Error: A non-null value must be returned since the return type 'void Function()' doesn't allow null.
+LegacyFoo test() {}
+          ^" in null;
+}
diff --git a/pkg/front_end/testcases/nnbd/issue41499b_lib.dart b/pkg/front_end/testcases/nnbd/issue41499b_lib.dart
new file mode 100644
index 0000000..0e205c2
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/issue41499b_lib.dart
@@ -0,0 +1,15 @@
+// Copyright (c) 2020, 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.
+
+import "issue41499b.dart";
+
+class C {
+  static LegacyFoo sTest() {}
+
+  LegacyFoo mTest() {}
+
+  LegacyFoo get gTest {}
+}
+
+LegacyFoo test() {}
diff --git a/pkg/front_end/testcases/nonfunction_type_aliases/issue41501.dart b/pkg/front_end/testcases/nonfunction_type_aliases/issue41501.dart
new file mode 100644
index 0000000..0b00978
--- /dev/null
+++ b/pkg/front_end/testcases/nonfunction_type_aliases/issue41501.dart
@@ -0,0 +1,21 @@
+// Copyright (c) 2020, 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.
+
+import 'dart:async';
+import 'issue41501_lib.dart';
+
+typedef AAliasNonNullable = A;
+
+typedef AAliasNullable = A?;
+
+test() {
+  FutureOr<AAlias> foLegacyNonNullable = null; // error
+  FutureOr<AAlias?> foLegacyNullable = null; // ok
+  FutureOr<AAliasNonNullable> foNonNullable = null; // error
+  FutureOr<AAliasNullable> foNullable = null; // ok
+  FutureOr<AAliasNonNullable?> foNonNullableNullable = null; // ok
+  FutureOr<AAliasNullable?> foNullableNullable = null; // ok
+}
+
+main() {}
\ No newline at end of file
diff --git a/pkg/front_end/testcases/nonfunction_type_aliases/issue41501.dart.outline.expect b/pkg/front_end/testcases/nonfunction_type_aliases/issue41501.dart.outline.expect
new file mode 100644
index 0000000..7f9a293
--- /dev/null
+++ b/pkg/front_end/testcases/nonfunction_type_aliases/issue41501.dart.outline.expect
@@ -0,0 +1,28 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "issue41501_lib.dart" as opt;
+
+import "dart:async";
+import "org-dartlang-testcase:///issue41501_lib.dart";
+
+typedef AAliasNonNullable = opt::A;
+typedef AAliasNullable = opt::A?;
+static method test() → dynamic
+  ;
+static method main() → dynamic
+  ;
+
+library opted_out_lib;
+import self as opt;
+import "dart:core" as core;
+
+import "dart:async";
+import "org-dartlang-testcase:///issue41501.dart";
+
+typedef AAlias = opt::A*;
+class A extends core::Object {
+  synthetic constructor •() → opt::A*
+    ;
+}
+static method test() → dynamic
+  ;
diff --git a/pkg/front_end/testcases/nonfunction_type_aliases/issue41501.dart.strong.expect b/pkg/front_end/testcases/nonfunction_type_aliases/issue41501.dart.strong.expect
new file mode 100644
index 0000000..6d57a3c
--- /dev/null
+++ b/pkg/front_end/testcases/nonfunction_type_aliases/issue41501.dart.strong.expect
@@ -0,0 +1,62 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/nonfunction_type_aliases/issue41501.dart:13:42: Error: A value of type 'Null?' can't be assigned to a variable of type 'FutureOr<A>'.
+//  - 'FutureOr' is from 'dart:async'.
+//  - 'A' is from 'pkg/front_end/testcases/nonfunction_type_aliases/issue41501_lib.dart'.
+//   FutureOr<AAlias> foLegacyNonNullable = null; // error
+//                                          ^
+//
+// pkg/front_end/testcases/nonfunction_type_aliases/issue41501.dart:15:47: Error: A value of type 'Null?' can't be assigned to a variable of type 'FutureOr<A>'.
+//  - 'FutureOr' is from 'dart:async'.
+//  - 'A' is from 'pkg/front_end/testcases/nonfunction_type_aliases/issue41501_lib.dart'.
+//   FutureOr<AAliasNonNullable> foNonNullable = null; // error
+//                                               ^
+//
+import self as self;
+import "issue41501_lib.dart" as opt;
+import "dart:async" as asy;
+
+import "dart:async";
+import "org-dartlang-testcase:///issue41501_lib.dart";
+
+typedef AAliasNonNullable = opt::A;
+typedef AAliasNullable = opt::A?;
+static method test() → dynamic {
+  asy::FutureOr<opt::A> foLegacyNonNullable = let final<BottomType> #t1 = invalid-expression "pkg/front_end/testcases/nonfunction_type_aliases/issue41501.dart:13:42: Error: A value of type 'Null?' can't be assigned to a variable of type 'FutureOr<A>'.
+ - 'FutureOr' is from 'dart:async'.
+ - 'A' is from 'pkg/front_end/testcases/nonfunction_type_aliases/issue41501_lib.dart'.
+  FutureOr<AAlias> foLegacyNonNullable = null; // error
+                                         ^" in null as{TypeError,ForNonNullableByDefault} asy::FutureOr<opt::A>;
+  asy::FutureOr<opt::A?> foLegacyNullable = null;
+  asy::FutureOr<opt::A> foNonNullable = let final<BottomType> #t2 = invalid-expression "pkg/front_end/testcases/nonfunction_type_aliases/issue41501.dart:15:47: Error: A value of type 'Null?' can't be assigned to a variable of type 'FutureOr<A>'.
+ - 'FutureOr' is from 'dart:async'.
+ - 'A' is from 'pkg/front_end/testcases/nonfunction_type_aliases/issue41501_lib.dart'.
+  FutureOr<AAliasNonNullable> foNonNullable = null; // error
+                                              ^" in null as{TypeError,ForNonNullableByDefault} asy::FutureOr<opt::A>;
+  asy::FutureOr<opt::A?> foNullable = null;
+  asy::FutureOr<opt::A?> foNonNullableNullable = null;
+  asy::FutureOr<opt::A?> foNullableNullable = null;
+}
+static method main() → dynamic {}
+
+library opted_out_lib;
+import self as opt;
+import "dart:core" as core;
+import "dart:async" as asy;
+
+import "dart:async";
+import "org-dartlang-testcase:///issue41501.dart";
+
+typedef AAlias = opt::A*;
+class A extends core::Object {
+  synthetic constructor •() → opt::A*
+    : super core::Object::•()
+    ;
+}
+static method test() → dynamic {
+  asy::FutureOr<opt::A*>* foLegacy = null;
+  asy::FutureOr<opt::A*>* foNonNullable = null;
+  asy::FutureOr<opt::A*>* foNullable = null;
+}
diff --git a/pkg/front_end/testcases/nonfunction_type_aliases/issue41501.dart.strong.transformed.expect b/pkg/front_end/testcases/nonfunction_type_aliases/issue41501.dart.strong.transformed.expect
new file mode 100644
index 0000000..6d57a3c
--- /dev/null
+++ b/pkg/front_end/testcases/nonfunction_type_aliases/issue41501.dart.strong.transformed.expect
@@ -0,0 +1,62 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/nonfunction_type_aliases/issue41501.dart:13:42: Error: A value of type 'Null?' can't be assigned to a variable of type 'FutureOr<A>'.
+//  - 'FutureOr' is from 'dart:async'.
+//  - 'A' is from 'pkg/front_end/testcases/nonfunction_type_aliases/issue41501_lib.dart'.
+//   FutureOr<AAlias> foLegacyNonNullable = null; // error
+//                                          ^
+//
+// pkg/front_end/testcases/nonfunction_type_aliases/issue41501.dart:15:47: Error: A value of type 'Null?' can't be assigned to a variable of type 'FutureOr<A>'.
+//  - 'FutureOr' is from 'dart:async'.
+//  - 'A' is from 'pkg/front_end/testcases/nonfunction_type_aliases/issue41501_lib.dart'.
+//   FutureOr<AAliasNonNullable> foNonNullable = null; // error
+//                                               ^
+//
+import self as self;
+import "issue41501_lib.dart" as opt;
+import "dart:async" as asy;
+
+import "dart:async";
+import "org-dartlang-testcase:///issue41501_lib.dart";
+
+typedef AAliasNonNullable = opt::A;
+typedef AAliasNullable = opt::A?;
+static method test() → dynamic {
+  asy::FutureOr<opt::A> foLegacyNonNullable = let final<BottomType> #t1 = invalid-expression "pkg/front_end/testcases/nonfunction_type_aliases/issue41501.dart:13:42: Error: A value of type 'Null?' can't be assigned to a variable of type 'FutureOr<A>'.
+ - 'FutureOr' is from 'dart:async'.
+ - 'A' is from 'pkg/front_end/testcases/nonfunction_type_aliases/issue41501_lib.dart'.
+  FutureOr<AAlias> foLegacyNonNullable = null; // error
+                                         ^" in null as{TypeError,ForNonNullableByDefault} asy::FutureOr<opt::A>;
+  asy::FutureOr<opt::A?> foLegacyNullable = null;
+  asy::FutureOr<opt::A> foNonNullable = let final<BottomType> #t2 = invalid-expression "pkg/front_end/testcases/nonfunction_type_aliases/issue41501.dart:15:47: Error: A value of type 'Null?' can't be assigned to a variable of type 'FutureOr<A>'.
+ - 'FutureOr' is from 'dart:async'.
+ - 'A' is from 'pkg/front_end/testcases/nonfunction_type_aliases/issue41501_lib.dart'.
+  FutureOr<AAliasNonNullable> foNonNullable = null; // error
+                                              ^" in null as{TypeError,ForNonNullableByDefault} asy::FutureOr<opt::A>;
+  asy::FutureOr<opt::A?> foNullable = null;
+  asy::FutureOr<opt::A?> foNonNullableNullable = null;
+  asy::FutureOr<opt::A?> foNullableNullable = null;
+}
+static method main() → dynamic {}
+
+library opted_out_lib;
+import self as opt;
+import "dart:core" as core;
+import "dart:async" as asy;
+
+import "dart:async";
+import "org-dartlang-testcase:///issue41501.dart";
+
+typedef AAlias = opt::A*;
+class A extends core::Object {
+  synthetic constructor •() → opt::A*
+    : super core::Object::•()
+    ;
+}
+static method test() → dynamic {
+  asy::FutureOr<opt::A*>* foLegacy = null;
+  asy::FutureOr<opt::A*>* foNonNullable = null;
+  asy::FutureOr<opt::A*>* foNullable = null;
+}
diff --git a/pkg/front_end/testcases/nonfunction_type_aliases/issue41501.dart.weak.expect b/pkg/front_end/testcases/nonfunction_type_aliases/issue41501.dart.weak.expect
new file mode 100644
index 0000000..6d57a3c
--- /dev/null
+++ b/pkg/front_end/testcases/nonfunction_type_aliases/issue41501.dart.weak.expect
@@ -0,0 +1,62 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/nonfunction_type_aliases/issue41501.dart:13:42: Error: A value of type 'Null?' can't be assigned to a variable of type 'FutureOr<A>'.
+//  - 'FutureOr' is from 'dart:async'.
+//  - 'A' is from 'pkg/front_end/testcases/nonfunction_type_aliases/issue41501_lib.dart'.
+//   FutureOr<AAlias> foLegacyNonNullable = null; // error
+//                                          ^
+//
+// pkg/front_end/testcases/nonfunction_type_aliases/issue41501.dart:15:47: Error: A value of type 'Null?' can't be assigned to a variable of type 'FutureOr<A>'.
+//  - 'FutureOr' is from 'dart:async'.
+//  - 'A' is from 'pkg/front_end/testcases/nonfunction_type_aliases/issue41501_lib.dart'.
+//   FutureOr<AAliasNonNullable> foNonNullable = null; // error
+//                                               ^
+//
+import self as self;
+import "issue41501_lib.dart" as opt;
+import "dart:async" as asy;
+
+import "dart:async";
+import "org-dartlang-testcase:///issue41501_lib.dart";
+
+typedef AAliasNonNullable = opt::A;
+typedef AAliasNullable = opt::A?;
+static method test() → dynamic {
+  asy::FutureOr<opt::A> foLegacyNonNullable = let final<BottomType> #t1 = invalid-expression "pkg/front_end/testcases/nonfunction_type_aliases/issue41501.dart:13:42: Error: A value of type 'Null?' can't be assigned to a variable of type 'FutureOr<A>'.
+ - 'FutureOr' is from 'dart:async'.
+ - 'A' is from 'pkg/front_end/testcases/nonfunction_type_aliases/issue41501_lib.dart'.
+  FutureOr<AAlias> foLegacyNonNullable = null; // error
+                                         ^" in null as{TypeError,ForNonNullableByDefault} asy::FutureOr<opt::A>;
+  asy::FutureOr<opt::A?> foLegacyNullable = null;
+  asy::FutureOr<opt::A> foNonNullable = let final<BottomType> #t2 = invalid-expression "pkg/front_end/testcases/nonfunction_type_aliases/issue41501.dart:15:47: Error: A value of type 'Null?' can't be assigned to a variable of type 'FutureOr<A>'.
+ - 'FutureOr' is from 'dart:async'.
+ - 'A' is from 'pkg/front_end/testcases/nonfunction_type_aliases/issue41501_lib.dart'.
+  FutureOr<AAliasNonNullable> foNonNullable = null; // error
+                                              ^" in null as{TypeError,ForNonNullableByDefault} asy::FutureOr<opt::A>;
+  asy::FutureOr<opt::A?> foNullable = null;
+  asy::FutureOr<opt::A?> foNonNullableNullable = null;
+  asy::FutureOr<opt::A?> foNullableNullable = null;
+}
+static method main() → dynamic {}
+
+library opted_out_lib;
+import self as opt;
+import "dart:core" as core;
+import "dart:async" as asy;
+
+import "dart:async";
+import "org-dartlang-testcase:///issue41501.dart";
+
+typedef AAlias = opt::A*;
+class A extends core::Object {
+  synthetic constructor •() → opt::A*
+    : super core::Object::•()
+    ;
+}
+static method test() → dynamic {
+  asy::FutureOr<opt::A*>* foLegacy = null;
+  asy::FutureOr<opt::A*>* foNonNullable = null;
+  asy::FutureOr<opt::A*>* foNullable = null;
+}
diff --git a/pkg/front_end/testcases/nonfunction_type_aliases/issue41501.dart.weak.transformed.expect b/pkg/front_end/testcases/nonfunction_type_aliases/issue41501.dart.weak.transformed.expect
new file mode 100644
index 0000000..6d57a3c
--- /dev/null
+++ b/pkg/front_end/testcases/nonfunction_type_aliases/issue41501.dart.weak.transformed.expect
@@ -0,0 +1,62 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/nonfunction_type_aliases/issue41501.dart:13:42: Error: A value of type 'Null?' can't be assigned to a variable of type 'FutureOr<A>'.
+//  - 'FutureOr' is from 'dart:async'.
+//  - 'A' is from 'pkg/front_end/testcases/nonfunction_type_aliases/issue41501_lib.dart'.
+//   FutureOr<AAlias> foLegacyNonNullable = null; // error
+//                                          ^
+//
+// pkg/front_end/testcases/nonfunction_type_aliases/issue41501.dart:15:47: Error: A value of type 'Null?' can't be assigned to a variable of type 'FutureOr<A>'.
+//  - 'FutureOr' is from 'dart:async'.
+//  - 'A' is from 'pkg/front_end/testcases/nonfunction_type_aliases/issue41501_lib.dart'.
+//   FutureOr<AAliasNonNullable> foNonNullable = null; // error
+//                                               ^
+//
+import self as self;
+import "issue41501_lib.dart" as opt;
+import "dart:async" as asy;
+
+import "dart:async";
+import "org-dartlang-testcase:///issue41501_lib.dart";
+
+typedef AAliasNonNullable = opt::A;
+typedef AAliasNullable = opt::A?;
+static method test() → dynamic {
+  asy::FutureOr<opt::A> foLegacyNonNullable = let final<BottomType> #t1 = invalid-expression "pkg/front_end/testcases/nonfunction_type_aliases/issue41501.dart:13:42: Error: A value of type 'Null?' can't be assigned to a variable of type 'FutureOr<A>'.
+ - 'FutureOr' is from 'dart:async'.
+ - 'A' is from 'pkg/front_end/testcases/nonfunction_type_aliases/issue41501_lib.dart'.
+  FutureOr<AAlias> foLegacyNonNullable = null; // error
+                                         ^" in null as{TypeError,ForNonNullableByDefault} asy::FutureOr<opt::A>;
+  asy::FutureOr<opt::A?> foLegacyNullable = null;
+  asy::FutureOr<opt::A> foNonNullable = let final<BottomType> #t2 = invalid-expression "pkg/front_end/testcases/nonfunction_type_aliases/issue41501.dart:15:47: Error: A value of type 'Null?' can't be assigned to a variable of type 'FutureOr<A>'.
+ - 'FutureOr' is from 'dart:async'.
+ - 'A' is from 'pkg/front_end/testcases/nonfunction_type_aliases/issue41501_lib.dart'.
+  FutureOr<AAliasNonNullable> foNonNullable = null; // error
+                                              ^" in null as{TypeError,ForNonNullableByDefault} asy::FutureOr<opt::A>;
+  asy::FutureOr<opt::A?> foNullable = null;
+  asy::FutureOr<opt::A?> foNonNullableNullable = null;
+  asy::FutureOr<opt::A?> foNullableNullable = null;
+}
+static method main() → dynamic {}
+
+library opted_out_lib;
+import self as opt;
+import "dart:core" as core;
+import "dart:async" as asy;
+
+import "dart:async";
+import "org-dartlang-testcase:///issue41501.dart";
+
+typedef AAlias = opt::A*;
+class A extends core::Object {
+  synthetic constructor •() → opt::A*
+    : super core::Object::•()
+    ;
+}
+static method test() → dynamic {
+  asy::FutureOr<opt::A*>* foLegacy = null;
+  asy::FutureOr<opt::A*>* foNonNullable = null;
+  asy::FutureOr<opt::A*>* foNullable = null;
+}
diff --git a/pkg/front_end/testcases/nonfunction_type_aliases/issue41501_lib.dart b/pkg/front_end/testcases/nonfunction_type_aliases/issue41501_lib.dart
new file mode 100644
index 0000000..09e20d1
--- /dev/null
+++ b/pkg/front_end/testcases/nonfunction_type_aliases/issue41501_lib.dart
@@ -0,0 +1,21 @@
+// Copyright (c) 2020, 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.
+
+// @dart=2.6
+
+library opted_out_lib;
+
+import 'dart:async';
+import 'issue41501.dart';
+
+class A {}
+
+typedef AAlias = A;
+
+test() {
+  FutureOr<AAlias> foLegacy = null; // ok
+  FutureOr<AAliasNonNullable> foNonNullable = null; // ok
+  FutureOr<AAliasNullable> foNullable = null; // ok
+}
+
diff --git a/pkg/front_end/testcases/nonfunction_type_aliases/test.options b/pkg/front_end/testcases/nonfunction_type_aliases/test.options
new file mode 100644
index 0000000..e7c1048
--- /dev/null
+++ b/pkg/front_end/testcases/nonfunction_type_aliases/test.options
@@ -0,0 +1 @@
+--enable-experiment=non-nullable,nonfunction-type-aliases
\ No newline at end of file
diff --git a/pkg/front_end/testcases/text_serialization.status b/pkg/front_end/testcases/text_serialization.status
index 69a3a5d..64d249d 100644
--- a/pkg/front_end/testcases/text_serialization.status
+++ b/pkg/front_end/testcases/text_serialization.status
@@ -1310,6 +1310,12 @@
 nnbd/issue41210a/issue41210: TextSerializationFailure
 nnbd/issue41210b: TextSerializationFailure
 nnbd/issue41273: TextSerializationFailure
+nnbd/issue41496: TextSerializationFailure
+nnbd/issue41496b: TextSerializationFailure
+nnbd/issue41498: TextSerializationFailure
+nnbd/issue41498b: TextSerializationFailure
+nnbd/issue41499: TextSerializationFailure
+nnbd/issue41499b: TextSerializationFailure
 nnbd/issue_39286: TextSerializationFailure
 nnbd/issue_39286_2: TextSerializationFailure
 nnbd/late: TextSerializationFailure
@@ -1403,6 +1409,7 @@
 no_such_method_forwarders/same: TextSerializationFailure # Was: Pass
 no_such_method_forwarders/setter_not_shadowed_by_method: TextSerializationFailure # Was: Pass
 no_such_method_forwarders/subst_on_forwarder: TextSerializationFailure # Was: Pass
+nonfunction_type_aliases/issue41501: TextSerializationFailure
 rasta/abstract_constructor: TextSerializationFailure # Was: RuntimeError
 rasta/bad_constructor_redirection: TextSerializationFailure # Was: RuntimeError
 rasta/bad_continue: TextSerializationFailure # Was: RuntimeError
diff --git a/tools/generate_package_config.dart b/tools/generate_package_config.dart
index 3d415c3..19e9c94 100755
--- a/tools/generate_package_config.dart
+++ b/tools/generate_package_config.dart
@@ -34,6 +34,7 @@
     packageDirectory('pkg/front_end/testcases/general_nnbd_opt_out/'),
     packageDirectory('pkg/front_end/testcases/late_lowering/'),
     packageDirectory('pkg/front_end/testcases/nnbd/'),
+    packageDirectory('pkg/front_end/testcases/nonfunction_type_aliases/'),
   ];
 
   var packages = [