[cfe] Include more implicit cast in lowering

This adds the implicit casts to the result of relational pattern
matching and guards in if-case elements/map entries.

Closes #51724

Change-Id: I368528534341194555f091174151d8510b136358
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291221
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
diff --git a/pkg/front_end/lib/src/fasta/kernel/constant_evaluator.dart b/pkg/front_end/lib/src/fasta/kernel/constant_evaluator.dart
index bab812d..0b4a057 100644
--- a/pkg/front_end/lib/src/fasta/kernel/constant_evaluator.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/constant_evaluator.dart
@@ -1222,7 +1222,8 @@
 
       MatchingCache matchingCache = createMatchingCache();
       MatchingExpressionVisitor matchingExpressionVisitor =
-          new MatchingExpressionVisitor(matchingCache);
+          new MatchingExpressionVisitor(
+              matchingCache, typeEnvironment.coreTypes);
       CacheableExpression matchedExpression =
           matchingCache.createRootExpression(node.expression, scrutineeType);
       // This expression is used, even if no case reads it.
@@ -1596,7 +1597,7 @@
 
     MatchingCache matchingCache = createMatchingCache();
     MatchingExpressionVisitor matchingExpressionVisitor =
-        new MatchingExpressionVisitor(matchingCache);
+        new MatchingExpressionVisitor(matchingCache, typeEnvironment.coreTypes);
     CacheableExpression matchedExpression = matchingCache.createRootExpression(
         node.expression, node.matchedValueType!);
     // This expression is used, even if the matching expression doesn't read it.
@@ -1644,7 +1645,7 @@
 
     MatchingCache matchingCache = createMatchingCache();
     MatchingExpressionVisitor matchingExpressionVisitor =
-        new MatchingExpressionVisitor(matchingCache);
+        new MatchingExpressionVisitor(matchingCache, typeEnvironment.coreTypes);
     // TODO(cstefantsova): Do we need a more precise type for the variable?
     DartType matchedType = const DynamicType();
     CacheableExpression matchedExpression =
@@ -1706,7 +1707,7 @@
 
     MatchingCache matchingCache = createMatchingCache();
     MatchingExpressionVisitor matchingExpressionVisitor =
-        new MatchingExpressionVisitor(matchingCache);
+        new MatchingExpressionVisitor(matchingCache, typeEnvironment.coreTypes);
     // TODO(cstefantsova): Do we need a more precise type for the variable?
     DartType matchedType = const DynamicType();
     CacheableExpression matchedExpression =
@@ -1896,7 +1897,8 @@
     } else {
       MatchingCache matchingCache = createMatchingCache();
       MatchingExpressionVisitor matchingExpressionVisitor =
-          new MatchingExpressionVisitor(matchingCache);
+          new MatchingExpressionVisitor(
+              matchingCache, typeEnvironment.coreTypes);
       CacheableExpression matchedExpression =
           matchingCache.createRootExpression(node.expression, scrutineeType);
       // This expression is used, even if no case reads it.
diff --git a/pkg/front_end/lib/src/fasta/type_inference/inference_visitor.dart b/pkg/front_end/lib/src/fasta/type_inference/inference_visitor.dart
index 956c99b..001a4ee 100644
--- a/pkg/front_end/lib/src/fasta/type_inference/inference_visitor.dart
+++ b/pkg/front_end/lib/src/fasta/type_inference/inference_visitor.dart
@@ -2300,8 +2300,15 @@
     InvalidExpression? guardError = analysisResult.nonBooleanGuardError;
     if (guardError != null) {
       patternGuard.guard = guardError..parent = patternGuard;
-    } else if (!identical(patternGuard.guard, rewrite)) {
-      patternGuard.guard = (rewrite as Expression?)?..parent = patternGuard;
+    } else {
+      if (!identical(patternGuard.guard, rewrite)) {
+        patternGuard.guard = (rewrite as Expression?)?..parent = patternGuard;
+      }
+      if (analysisResult.guardType is DynamicType) {
+        patternGuard.guard = _createImplicitAs(patternGuard.guard!.fileOffset,
+            patternGuard.guard!, coreTypes.boolNonNullableRawType)
+          ..parent = patternGuard;
+      }
     }
 
     rewrite = popRewrite();
@@ -4217,8 +4224,15 @@
     InvalidExpression? guardError = analysisResult.nonBooleanGuardError;
     if (guardError != null) {
       patternGuard.guard = guardError..parent = patternGuard;
-    } else if (!identical(patternGuard.guard, rewrite)) {
-      patternGuard.guard = (rewrite as Expression?)?..parent = patternGuard;
+    } else {
+      if (!identical(patternGuard.guard, rewrite)) {
+        patternGuard.guard = (rewrite as Expression?)?..parent = patternGuard;
+      }
+      if (analysisResult.guardType is DynamicType) {
+        patternGuard.guard = _createImplicitAs(patternGuard.guard!.fileOffset,
+            patternGuard.guard!, coreTypes.boolNonNullableRawType)
+          ..parent = patternGuard;
+      }
     }
 
     rewrite = popRewrite();
diff --git a/pkg/front_end/lib/src/fasta/type_inference/matching_expressions.dart b/pkg/front_end/lib/src/fasta/type_inference/matching_expressions.dart
index 80cce0f..8a217ae 100644
--- a/pkg/front_end/lib/src/fasta/type_inference/matching_expressions.dart
+++ b/pkg/front_end/lib/src/fasta/type_inference/matching_expressions.dart
@@ -5,6 +5,7 @@
 import 'package:front_end/src/fasta/type_inference/delayed_expressions.dart';
 import 'package:front_end/src/fasta/type_inference/matching_cache.dart';
 import 'package:kernel/ast.dart';
+import 'package:kernel/core_types.dart';
 
 import '../names.dart';
 
@@ -13,8 +14,9 @@
 class MatchingExpressionVisitor
     implements PatternVisitor1<DelayedExpression, CacheableExpression> {
   final MatchingCache matchingCache;
+  final CoreTypes coreTypes;
 
-  MatchingExpressionVisitor(this.matchingCache);
+  MatchingExpressionVisitor(this.matchingCache, this.coreTypes);
 
   DelayedExpression visitPattern(
       Pattern node, CacheableExpression matchedExpression) {
@@ -625,6 +627,7 @@
                       isImplicit: true, fileOffset: node.fileOffset)
                 ],
                 fileOffset: node.fileOffset);
+
             break;
           case RelationalAccessKind.Static:
             FunctionType functionType = node.functionType!;
@@ -669,6 +672,9 @@
                 fileOffset: node.fileOffset);
             break;
         }
+        expression = new DelayedAsExpression(
+            expression, coreTypes.boolNonNullableRawType,
+            isImplicit: true, fileOffset: node.fileOffset);
         return matchingCache.createComparisonExpression(
             matchedExpression, node.name!.text, constant, expression,
             staticTarget: staticTarget, fileOffset: node.fileOffset);
diff --git a/pkg/front_end/testcases/modular.status b/pkg/front_end/testcases/modular.status
index 36480fe..bdb1334 100644
--- a/pkg/front_end/testcases/modular.status
+++ b/pkg/front_end/testcases/modular.status
@@ -84,5 +84,4 @@
 nnbd_mixed/messages_with_types_opt_in: TypeCheckError
 nnbd_mixed/messages_with_types_opt_out: TypeCheckError
 no_such_method_forwarders/mixin_nsm: TypeCheckError
-patterns/pattern_types: TypeCheckError
 runtime_checks_new/mixin_forwarding_stub_getter: TypeCheckError
diff --git a/pkg/front_end/testcases/patterns/dynamic_guard.dart b/pkg/front_end/testcases/patterns/dynamic_guard.dart
index 830bcf6..39c416c 100644
--- a/pkg/front_end/testcases/patterns/dynamic_guard.dart
+++ b/pkg/front_end/testcases/patterns/dynamic_guard.dart
@@ -7,7 +7,7 @@
 main() {
   var [a] = [5];
   int b;
-  [b] = [5];
+  [b] = [if (a case == 5 when guard()) 5];
   if (a case == 5 when guard()) {
     a = 6;
   }
@@ -19,4 +19,5 @@
     case int e when guard():
       print(a);
   }
+  var d = {if (a case == 5 when guard()) 5: 6};
 }
diff --git a/pkg/front_end/testcases/patterns/dynamic_guard.dart.strong.expect b/pkg/front_end/testcases/patterns/dynamic_guard.dart.strong.expect
index 0de2f06..8dba64c 100644
--- a/pkg/front_end/testcases/patterns/dynamic_guard.dart.strong.expect
+++ b/pkg/front_end/testcases/patterns/dynamic_guard.dart.strong.expect
@@ -13,48 +13,63 @@
   }
   core::int b;
   block {
-    final synthesized dynamic #1#0 = <core::int>[5];
-    if(!(#1#0{core::List<core::int>}.{core::List::length}{core::int} =={core::num::==}{(core::Object) → core::bool} #C1 && (let final dynamic #t2 = b = #1#0{core::List<core::int>}.{core::List::[]}(0){(core::int) → core::int} in true)))
+    final synthesized dynamic #2#0 = block {
+      final core::List<core::int> #t2 = <core::int>[];
+      {
+        final synthesized core::int #1#0 = a;
+        if(#1#0 =={core::num::==}{(core::Object) → core::bool} #C2 && self::guard() as{TypeError,ForNonNullableByDefault} core::bool)
+          #t2.{core::List::add}{Invariant}(5){(core::int) → void};
+      }
+    } =>#t2;
+    if(!(#2#0{core::List<core::int>}.{core::List::length}{core::int} =={core::num::==}{(core::Object) → core::bool} #C1 && (let final dynamic #t3 = b = #2#0{core::List<core::int>}.{core::List::[]}(0){(core::int) → core::int} in true)))
       throw new core::StateError::•("Pattern matching error");
-  } =>#1#0;
+  } =>#2#0;
   {
-    final synthesized core::int #2#0 = a;
-    if(#2#0 =={core::num::==}{(core::Object) → core::bool} #C2 && self::guard() as{TypeError,ForNonNullableByDefault} core::bool) {
+    final synthesized core::int #3#0 = a;
+    if(#3#0 =={core::num::==}{(core::Object) → core::bool} #C2 && self::guard() as{TypeError,ForNonNullableByDefault} core::bool) {
       a = 6;
     }
   }
   core::int c = block {
-    core::int #t3;
-    final synthesized core::int #3#0 = a;
+    core::int #t4;
+    final synthesized core::int #4#0 = a;
     #L1:
     {
       {
         core::int d;
-        if(#3#0 is{ForNonNullableByDefault} core::int && (let final dynamic #t4 = d = #3#0 in true) && self::guard() as{TypeError,ForNonNullableByDefault} core::bool) {
-          #t3 = d;
+        if(#4#0 is{ForNonNullableByDefault} core::int && (let final dynamic #t5 = d = #4#0 in true) && self::guard() as{TypeError,ForNonNullableByDefault} core::bool) {
+          #t4 = d;
           break #L1;
         }
       }
       {
         if(true) {
-          #t3 = 0;
+          #t4 = 0;
           break #L1;
         }
       }
     }
-  } =>#t3;
+  } =>#t4;
   #L2:
   {
-    final synthesized core::int #4#0 = b;
+    final synthesized core::int #5#0 = b;
     {
       core::int e;
-      if(#4#0 is{ForNonNullableByDefault} core::int && (let final dynamic #t5 = e = #4#0 in true) && self::guard() as{TypeError,ForNonNullableByDefault} core::bool) {
+      if(#5#0 is{ForNonNullableByDefault} core::int && (let final dynamic #t6 = e = #5#0 in true) && self::guard() as{TypeError,ForNonNullableByDefault} core::bool) {
         {
           core::print(a);
         }
       }
     }
   }
+  core::Map<core::int, core::int> d = block {
+    final core::Map<core::int, core::int> #t7 = <core::int, core::int>{};
+    {
+      final synthesized core::int #6#0 = a;
+      if(#6#0 =={core::num::==}{(core::Object) → core::bool} #C2 && self::guard() as{TypeError,ForNonNullableByDefault} core::bool)
+        #t7.{core::Map::[]=}{Invariant}(5, 6){(core::int, core::int) → void};
+    }
+  } =>#t7;
 }
 
 constants  {
diff --git a/pkg/front_end/testcases/patterns/dynamic_guard.dart.strong.transformed.expect b/pkg/front_end/testcases/patterns/dynamic_guard.dart.strong.transformed.expect
index 421d9eb..83c4795 100644
--- a/pkg/front_end/testcases/patterns/dynamic_guard.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/patterns/dynamic_guard.dart.strong.transformed.expect
@@ -13,48 +13,63 @@
   }
   core::int b;
   block {
-    final synthesized dynamic #1#0 = core::_GrowableList::_literal1<core::int>(5);
-    if(!(#1#0{core::List<core::int>}.{core::List::length}{core::int} =={core::num::==}{(core::Object) → core::bool} #C1 && (let final core::int #t2 = b = #1#0{core::List<core::int>}.{core::List::[]}(0){(core::int) → core::int} in true)))
+    final synthesized dynamic #2#0 = block {
+      final core::List<core::int> #t2 = core::_GrowableList::•<core::int>(0);
+      {
+        final synthesized core::int #1#0 = a;
+        if(#1#0 =={core::num::==}{(core::Object) → core::bool} #C2 && self::guard() as{TypeError,ForNonNullableByDefault} core::bool)
+          #t2.{core::List::add}{Invariant}(5){(core::int) → void};
+      }
+    } =>#t2;
+    if(!(#2#0{core::List<core::int>}.{core::List::length}{core::int} =={core::num::==}{(core::Object) → core::bool} #C1 && (let final core::int #t3 = b = #2#0{core::List<core::int>}.{core::List::[]}(0){(core::int) → core::int} in true)))
       throw new core::StateError::•("Pattern matching error");
-  } =>#1#0;
+  } =>#2#0;
   {
-    final synthesized core::int #2#0 = a;
-    if(#2#0 =={core::num::==}{(core::Object) → core::bool} #C2 && self::guard() as{TypeError,ForNonNullableByDefault} core::bool) {
+    final synthesized core::int #3#0 = a;
+    if(#3#0 =={core::num::==}{(core::Object) → core::bool} #C2 && self::guard() as{TypeError,ForNonNullableByDefault} core::bool) {
       a = 6;
     }
   }
   core::int c = block {
-    core::int #t3;
-    final synthesized core::int #3#0 = a;
+    core::int #t4;
+    final synthesized core::int #4#0 = a;
     #L1:
     {
       {
         core::int d;
-        if(#3#0 is{ForNonNullableByDefault} core::int && (let final core::int #t4 = d = #3#0 in true) && self::guard() as{TypeError,ForNonNullableByDefault} core::bool) {
-          #t3 = d;
+        if(#4#0 is{ForNonNullableByDefault} core::int && (let final core::int #t5 = d = #4#0 in true) && self::guard() as{TypeError,ForNonNullableByDefault} core::bool) {
+          #t4 = d;
           break #L1;
         }
       }
       {
         if(true) {
-          #t3 = 0;
+          #t4 = 0;
           break #L1;
         }
       }
     }
-  } =>#t3;
+  } =>#t4;
   #L2:
   {
-    final synthesized core::int #4#0 = b;
+    final synthesized core::int #5#0 = b;
     {
       core::int e;
-      if(#4#0 is{ForNonNullableByDefault} core::int && (let final core::int #t5 = e = #4#0 in true) && self::guard() as{TypeError,ForNonNullableByDefault} core::bool) {
+      if(#5#0 is{ForNonNullableByDefault} core::int && (let final core::int #t6 = e = #5#0 in true) && self::guard() as{TypeError,ForNonNullableByDefault} core::bool) {
         {
           core::print(a);
         }
       }
     }
   }
+  core::Map<core::int, core::int> d = block {
+    final core::Map<core::int, core::int> #t7 = <core::int, core::int>{};
+    {
+      final synthesized core::int #6#0 = a;
+      if(#6#0 =={core::num::==}{(core::Object) → core::bool} #C2 && self::guard() as{TypeError,ForNonNullableByDefault} core::bool)
+        #t7.{core::Map::[]=}{Invariant}(5, 6){(core::int, core::int) → void};
+    }
+  } =>#t7;
 }
 
 constants  {
diff --git a/pkg/front_end/testcases/patterns/dynamic_guard.dart.weak.expect b/pkg/front_end/testcases/patterns/dynamic_guard.dart.weak.expect
index 9a146cd..6ca6186 100644
--- a/pkg/front_end/testcases/patterns/dynamic_guard.dart.weak.expect
+++ b/pkg/front_end/testcases/patterns/dynamic_guard.dart.weak.expect
@@ -14,49 +14,64 @@
   }
   core::int b;
   block {
-    final synthesized dynamic #1#0 = <core::int>[5];
-    if(!(#1#0{core::List<core::int>}.{core::List::length}{core::int} =={core::num::==}{(core::Object) → core::bool} #C1 && (let final dynamic #t2 = b = #1#0{core::List<core::int>}.{core::List::[]}(0){(core::int) → core::int} in true)))
+    final synthesized dynamic #2#0 = block {
+      final core::List<core::int> #t2 = <core::int>[];
+      {
+        final synthesized core::int #1#0 = a;
+        if(#1#0 =={core::num::==}{(core::Object) → core::bool} #C2 && self::guard() as{TypeError,ForNonNullableByDefault} core::bool)
+          #t2.{core::List::add}{Invariant}(5){(core::int) → void};
+      }
+    } =>#t2;
+    if(!(#2#0{core::List<core::int>}.{core::List::length}{core::int} =={core::num::==}{(core::Object) → core::bool} #C1 && (let final dynamic #t3 = b = #2#0{core::List<core::int>}.{core::List::[]}(0){(core::int) → core::int} in true)))
       throw new core::StateError::•("Pattern matching error");
-  } =>#1#0;
+  } =>#2#0;
   {
-    final synthesized core::int #2#0 = a;
-    if(#2#0 =={core::num::==}{(core::Object) → core::bool} #C2 && self::guard() as{TypeError,ForNonNullableByDefault} core::bool) {
+    final synthesized core::int #3#0 = a;
+    if(#3#0 =={core::num::==}{(core::Object) → core::bool} #C2 && self::guard() as{TypeError,ForNonNullableByDefault} core::bool) {
       a = 6;
     }
   }
   core::int c = block {
-    core::int #t3;
-    final synthesized core::int #3#0 = a;
+    core::int #t4;
+    final synthesized core::int #4#0 = a;
     #L1:
     {
       {
         core::int d;
-        if(#3#0 is{ForNonNullableByDefault} core::int && (let final dynamic #t4 = d = #3#0 in true) && self::guard() as{TypeError,ForNonNullableByDefault} core::bool) {
-          #t3 = d;
+        if(#4#0 is{ForNonNullableByDefault} core::int && (let final dynamic #t5 = d = #4#0 in true) && self::guard() as{TypeError,ForNonNullableByDefault} core::bool) {
+          #t4 = d;
           break #L1;
         }
       }
       {
         if(true) {
-          #t3 = 0;
+          #t4 = 0;
           break #L1;
         }
       }
       throw new _in::ReachabilityError::•("`null` encountered as case in a switch expression with a non-nullable type.");
     }
-  } =>#t3;
+  } =>#t4;
   #L2:
   {
-    final synthesized core::int #4#0 = b;
+    final synthesized core::int #5#0 = b;
     {
       core::int e;
-      if(#4#0 is{ForNonNullableByDefault} core::int && (let final dynamic #t5 = e = #4#0 in true) && self::guard() as{TypeError,ForNonNullableByDefault} core::bool) {
+      if(#5#0 is{ForNonNullableByDefault} core::int && (let final dynamic #t6 = e = #5#0 in true) && self::guard() as{TypeError,ForNonNullableByDefault} core::bool) {
         {
           core::print(a);
         }
       }
     }
   }
+  core::Map<core::int, core::int> d = block {
+    final core::Map<core::int, core::int> #t7 = <core::int, core::int>{};
+    {
+      final synthesized core::int #6#0 = a;
+      if(#6#0 =={core::num::==}{(core::Object) → core::bool} #C2 && self::guard() as{TypeError,ForNonNullableByDefault} core::bool)
+        #t7.{core::Map::[]=}{Invariant}(5, 6){(core::int, core::int) → void};
+    }
+  } =>#t7;
 }
 
 constants  {
diff --git a/pkg/front_end/testcases/patterns/dynamic_guard.dart.weak.modular.expect b/pkg/front_end/testcases/patterns/dynamic_guard.dart.weak.modular.expect
index 9a146cd..6ca6186 100644
--- a/pkg/front_end/testcases/patterns/dynamic_guard.dart.weak.modular.expect
+++ b/pkg/front_end/testcases/patterns/dynamic_guard.dart.weak.modular.expect
@@ -14,49 +14,64 @@
   }
   core::int b;
   block {
-    final synthesized dynamic #1#0 = <core::int>[5];
-    if(!(#1#0{core::List<core::int>}.{core::List::length}{core::int} =={core::num::==}{(core::Object) → core::bool} #C1 && (let final dynamic #t2 = b = #1#0{core::List<core::int>}.{core::List::[]}(0){(core::int) → core::int} in true)))
+    final synthesized dynamic #2#0 = block {
+      final core::List<core::int> #t2 = <core::int>[];
+      {
+        final synthesized core::int #1#0 = a;
+        if(#1#0 =={core::num::==}{(core::Object) → core::bool} #C2 && self::guard() as{TypeError,ForNonNullableByDefault} core::bool)
+          #t2.{core::List::add}{Invariant}(5){(core::int) → void};
+      }
+    } =>#t2;
+    if(!(#2#0{core::List<core::int>}.{core::List::length}{core::int} =={core::num::==}{(core::Object) → core::bool} #C1 && (let final dynamic #t3 = b = #2#0{core::List<core::int>}.{core::List::[]}(0){(core::int) → core::int} in true)))
       throw new core::StateError::•("Pattern matching error");
-  } =>#1#0;
+  } =>#2#0;
   {
-    final synthesized core::int #2#0 = a;
-    if(#2#0 =={core::num::==}{(core::Object) → core::bool} #C2 && self::guard() as{TypeError,ForNonNullableByDefault} core::bool) {
+    final synthesized core::int #3#0 = a;
+    if(#3#0 =={core::num::==}{(core::Object) → core::bool} #C2 && self::guard() as{TypeError,ForNonNullableByDefault} core::bool) {
       a = 6;
     }
   }
   core::int c = block {
-    core::int #t3;
-    final synthesized core::int #3#0 = a;
+    core::int #t4;
+    final synthesized core::int #4#0 = a;
     #L1:
     {
       {
         core::int d;
-        if(#3#0 is{ForNonNullableByDefault} core::int && (let final dynamic #t4 = d = #3#0 in true) && self::guard() as{TypeError,ForNonNullableByDefault} core::bool) {
-          #t3 = d;
+        if(#4#0 is{ForNonNullableByDefault} core::int && (let final dynamic #t5 = d = #4#0 in true) && self::guard() as{TypeError,ForNonNullableByDefault} core::bool) {
+          #t4 = d;
           break #L1;
         }
       }
       {
         if(true) {
-          #t3 = 0;
+          #t4 = 0;
           break #L1;
         }
       }
       throw new _in::ReachabilityError::•("`null` encountered as case in a switch expression with a non-nullable type.");
     }
-  } =>#t3;
+  } =>#t4;
   #L2:
   {
-    final synthesized core::int #4#0 = b;
+    final synthesized core::int #5#0 = b;
     {
       core::int e;
-      if(#4#0 is{ForNonNullableByDefault} core::int && (let final dynamic #t5 = e = #4#0 in true) && self::guard() as{TypeError,ForNonNullableByDefault} core::bool) {
+      if(#5#0 is{ForNonNullableByDefault} core::int && (let final dynamic #t6 = e = #5#0 in true) && self::guard() as{TypeError,ForNonNullableByDefault} core::bool) {
         {
           core::print(a);
         }
       }
     }
   }
+  core::Map<core::int, core::int> d = block {
+    final core::Map<core::int, core::int> #t7 = <core::int, core::int>{};
+    {
+      final synthesized core::int #6#0 = a;
+      if(#6#0 =={core::num::==}{(core::Object) → core::bool} #C2 && self::guard() as{TypeError,ForNonNullableByDefault} core::bool)
+        #t7.{core::Map::[]=}{Invariant}(5, 6){(core::int, core::int) → void};
+    }
+  } =>#t7;
 }
 
 constants  {
diff --git a/pkg/front_end/testcases/patterns/dynamic_guard.dart.weak.transformed.expect b/pkg/front_end/testcases/patterns/dynamic_guard.dart.weak.transformed.expect
index da657d7..e6783f0 100644
--- a/pkg/front_end/testcases/patterns/dynamic_guard.dart.weak.transformed.expect
+++ b/pkg/front_end/testcases/patterns/dynamic_guard.dart.weak.transformed.expect
@@ -14,49 +14,64 @@
   }
   core::int b;
   block {
-    final synthesized dynamic #1#0 = core::_GrowableList::_literal1<core::int>(5);
-    if(!(#1#0{core::List<core::int>}.{core::List::length}{core::int} =={core::num::==}{(core::Object) → core::bool} #C1 && (let final core::int #t2 = b = #1#0{core::List<core::int>}.{core::List::[]}(0){(core::int) → core::int} in true)))
+    final synthesized dynamic #2#0 = block {
+      final core::List<core::int> #t2 = core::_GrowableList::•<core::int>(0);
+      {
+        final synthesized core::int #1#0 = a;
+        if(#1#0 =={core::num::==}{(core::Object) → core::bool} #C2 && self::guard() as{TypeError,ForNonNullableByDefault} core::bool)
+          #t2.{core::List::add}{Invariant}(5){(core::int) → void};
+      }
+    } =>#t2;
+    if(!(#2#0{core::List<core::int>}.{core::List::length}{core::int} =={core::num::==}{(core::Object) → core::bool} #C1 && (let final core::int #t3 = b = #2#0{core::List<core::int>}.{core::List::[]}(0){(core::int) → core::int} in true)))
       throw new core::StateError::•("Pattern matching error");
-  } =>#1#0;
+  } =>#2#0;
   {
-    final synthesized core::int #2#0 = a;
-    if(#2#0 =={core::num::==}{(core::Object) → core::bool} #C2 && self::guard() as{TypeError,ForNonNullableByDefault} core::bool) {
+    final synthesized core::int #3#0 = a;
+    if(#3#0 =={core::num::==}{(core::Object) → core::bool} #C2 && self::guard() as{TypeError,ForNonNullableByDefault} core::bool) {
       a = 6;
     }
   }
   core::int c = block {
-    core::int #t3;
-    final synthesized core::int #3#0 = a;
+    core::int #t4;
+    final synthesized core::int #4#0 = a;
     #L1:
     {
       {
         core::int d;
-        if(#3#0 is{ForNonNullableByDefault} core::int && (let final core::int #t4 = d = #3#0 in true) && self::guard() as{TypeError,ForNonNullableByDefault} core::bool) {
-          #t3 = d;
+        if(#4#0 is{ForNonNullableByDefault} core::int && (let final core::int #t5 = d = #4#0 in true) && self::guard() as{TypeError,ForNonNullableByDefault} core::bool) {
+          #t4 = d;
           break #L1;
         }
       }
       {
         if(true) {
-          #t3 = 0;
+          #t4 = 0;
           break #L1;
         }
       }
       throw new _in::ReachabilityError::•("`null` encountered as case in a switch expression with a non-nullable type.");
     }
-  } =>#t3;
+  } =>#t4;
   #L2:
   {
-    final synthesized core::int #4#0 = b;
+    final synthesized core::int #5#0 = b;
     {
       core::int e;
-      if(#4#0 is{ForNonNullableByDefault} core::int && (let final core::int #t5 = e = #4#0 in true) && self::guard() as{TypeError,ForNonNullableByDefault} core::bool) {
+      if(#5#0 is{ForNonNullableByDefault} core::int && (let final core::int #t6 = e = #5#0 in true) && self::guard() as{TypeError,ForNonNullableByDefault} core::bool) {
         {
           core::print(a);
         }
       }
     }
   }
+  core::Map<core::int, core::int> d = block {
+    final core::Map<core::int, core::int> #t7 = <core::int, core::int>{};
+    {
+      final synthesized core::int #6#0 = a;
+      if(#6#0 =={core::num::==}{(core::Object) → core::bool} #C2 && self::guard() as{TypeError,ForNonNullableByDefault} core::bool)
+        #t7.{core::Map::[]=}{Invariant}(5, 6){(core::int, core::int) → void};
+    }
+  } =>#t7;
 }
 
 constants  {
diff --git a/pkg/front_end/testcases/patterns/issue51724_2.dart b/pkg/front_end/testcases/patterns/issue51724_2.dart
new file mode 100644
index 0000000..a0df069
--- /dev/null
+++ b/pkg/front_end/testcases/patterns/issue51724_2.dart
@@ -0,0 +1,45 @@
+// Copyright (c) 2023, 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.
+
+class C {
+  final int value;
+  String log = "";
+  C(this.value);
+
+  void clearLog() {
+    log = "";
+  }
+
+  dynamic operator >(num other) {
+    log += "C($value)>$other;";
+    return this.value - other;
+  }
+}
+
+String test1(C c) {
+  switch (c) {
+    case > 1:
+      return "1";
+    default:
+      return "no match";
+  }
+}
+
+main() {
+  C c1 = C(0);
+  C c2 = C(2);
+  throws(() {
+    test1(c1);
+  });
+}
+
+throws(void Function() f) {
+  try {
+    f();
+  } catch (e) {
+    print(e);
+    return;
+  }
+  throw 'Missing exception';
+}
diff --git a/pkg/front_end/testcases/patterns/issue51724_2.dart.strong.expect b/pkg/front_end/testcases/patterns/issue51724_2.dart.strong.expect
new file mode 100644
index 0000000..c036540
--- /dev/null
+++ b/pkg/front_end/testcases/patterns/issue51724_2.dart.strong.expect
@@ -0,0 +1,59 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "dart:core" as core;
+
+class C extends core::Object {
+  final field core::int value;
+  field core::String log = "";
+  constructor •(core::int value) → self::C
+    : self::C::value = value, super core::Object::•()
+    ;
+  method clearLog() → void {
+    this.{self::C::log} = "";
+  }
+  operator >(core::num other) → dynamic {
+    this.{self::C::log} = this.{self::C::log}{core::String}.{core::String::+}("C(${this.{self::C::value}{core::int}})>${other};"){(core::String) → core::String};
+    return this.{self::C::value}{core::int}.{core::num::-}(other){(core::num) → core::num};
+  }
+}
+static method test1(self::C c) → core::String {
+  #L1:
+  {
+    final synthesized self::C #0#0 = c;
+    {
+      if(#0#0.{self::C::>}(#C1){(core::num) → dynamic} as{ForNonNullableByDefault} core::bool) {
+        {
+          return "1";
+        }
+      }
+    }
+    {
+      {
+        {
+          return "no match";
+        }
+      }
+    }
+  }
+}
+static method main() → dynamic {
+  self::C c1 = new self::C::•(0);
+  self::C c2 = new self::C::•(2);
+  self::throws(() → void {
+    self::test1(c1);
+  });
+}
+static method throws(() → void f) → dynamic {
+  try {
+    f(){() → void};
+  }
+  on core::Object catch(final core::Object e) {
+    core::print(e);
+    return;
+  }
+  throw "Missing exception";
+}
+
+constants  {
+  #C1 = 1
+}
diff --git a/pkg/front_end/testcases/patterns/issue51724_2.dart.strong.transformed.expect b/pkg/front_end/testcases/patterns/issue51724_2.dart.strong.transformed.expect
new file mode 100644
index 0000000..c036540
--- /dev/null
+++ b/pkg/front_end/testcases/patterns/issue51724_2.dart.strong.transformed.expect
@@ -0,0 +1,59 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "dart:core" as core;
+
+class C extends core::Object {
+  final field core::int value;
+  field core::String log = "";
+  constructor •(core::int value) → self::C
+    : self::C::value = value, super core::Object::•()
+    ;
+  method clearLog() → void {
+    this.{self::C::log} = "";
+  }
+  operator >(core::num other) → dynamic {
+    this.{self::C::log} = this.{self::C::log}{core::String}.{core::String::+}("C(${this.{self::C::value}{core::int}})>${other};"){(core::String) → core::String};
+    return this.{self::C::value}{core::int}.{core::num::-}(other){(core::num) → core::num};
+  }
+}
+static method test1(self::C c) → core::String {
+  #L1:
+  {
+    final synthesized self::C #0#0 = c;
+    {
+      if(#0#0.{self::C::>}(#C1){(core::num) → dynamic} as{ForNonNullableByDefault} core::bool) {
+        {
+          return "1";
+        }
+      }
+    }
+    {
+      {
+        {
+          return "no match";
+        }
+      }
+    }
+  }
+}
+static method main() → dynamic {
+  self::C c1 = new self::C::•(0);
+  self::C c2 = new self::C::•(2);
+  self::throws(() → void {
+    self::test1(c1);
+  });
+}
+static method throws(() → void f) → dynamic {
+  try {
+    f(){() → void};
+  }
+  on core::Object catch(final core::Object e) {
+    core::print(e);
+    return;
+  }
+  throw "Missing exception";
+}
+
+constants  {
+  #C1 = 1
+}
diff --git a/pkg/front_end/testcases/patterns/issue51724_2.dart.textual_outline.expect b/pkg/front_end/testcases/patterns/issue51724_2.dart.textual_outline.expect
new file mode 100644
index 0000000..954e4cd
--- /dev/null
+++ b/pkg/front_end/testcases/patterns/issue51724_2.dart.textual_outline.expect
@@ -0,0 +1,11 @@
+class C {
+  final int value;
+  String log = "";
+  C(this.value);
+  void clearLog() {}
+  dynamic operator >(num other) {}
+}
+
+String test1(C c) {}
+main() {}
+throws(void Function() f) {}
diff --git a/pkg/front_end/testcases/patterns/issue51724_2.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/patterns/issue51724_2.dart.textual_outline_modelled.expect
new file mode 100644
index 0000000..f5f71fe
--- /dev/null
+++ b/pkg/front_end/testcases/patterns/issue51724_2.dart.textual_outline_modelled.expect
@@ -0,0 +1,12 @@
+String test1(C c) {}
+
+class C {
+  C(this.value);
+  String log = "";
+  dynamic operator >(num other) {}
+  final int value;
+  void clearLog() {}
+}
+
+main() {}
+throws(void Function() f) {}
diff --git a/pkg/front_end/testcases/patterns/issue51724_2.dart.weak.expect b/pkg/front_end/testcases/patterns/issue51724_2.dart.weak.expect
new file mode 100644
index 0000000..c036540
--- /dev/null
+++ b/pkg/front_end/testcases/patterns/issue51724_2.dart.weak.expect
@@ -0,0 +1,59 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "dart:core" as core;
+
+class C extends core::Object {
+  final field core::int value;
+  field core::String log = "";
+  constructor •(core::int value) → self::C
+    : self::C::value = value, super core::Object::•()
+    ;
+  method clearLog() → void {
+    this.{self::C::log} = "";
+  }
+  operator >(core::num other) → dynamic {
+    this.{self::C::log} = this.{self::C::log}{core::String}.{core::String::+}("C(${this.{self::C::value}{core::int}})>${other};"){(core::String) → core::String};
+    return this.{self::C::value}{core::int}.{core::num::-}(other){(core::num) → core::num};
+  }
+}
+static method test1(self::C c) → core::String {
+  #L1:
+  {
+    final synthesized self::C #0#0 = c;
+    {
+      if(#0#0.{self::C::>}(#C1){(core::num) → dynamic} as{ForNonNullableByDefault} core::bool) {
+        {
+          return "1";
+        }
+      }
+    }
+    {
+      {
+        {
+          return "no match";
+        }
+      }
+    }
+  }
+}
+static method main() → dynamic {
+  self::C c1 = new self::C::•(0);
+  self::C c2 = new self::C::•(2);
+  self::throws(() → void {
+    self::test1(c1);
+  });
+}
+static method throws(() → void f) → dynamic {
+  try {
+    f(){() → void};
+  }
+  on core::Object catch(final core::Object e) {
+    core::print(e);
+    return;
+  }
+  throw "Missing exception";
+}
+
+constants  {
+  #C1 = 1
+}
diff --git a/pkg/front_end/testcases/patterns/issue51724_2.dart.weak.modular.expect b/pkg/front_end/testcases/patterns/issue51724_2.dart.weak.modular.expect
new file mode 100644
index 0000000..c036540
--- /dev/null
+++ b/pkg/front_end/testcases/patterns/issue51724_2.dart.weak.modular.expect
@@ -0,0 +1,59 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "dart:core" as core;
+
+class C extends core::Object {
+  final field core::int value;
+  field core::String log = "";
+  constructor •(core::int value) → self::C
+    : self::C::value = value, super core::Object::•()
+    ;
+  method clearLog() → void {
+    this.{self::C::log} = "";
+  }
+  operator >(core::num other) → dynamic {
+    this.{self::C::log} = this.{self::C::log}{core::String}.{core::String::+}("C(${this.{self::C::value}{core::int}})>${other};"){(core::String) → core::String};
+    return this.{self::C::value}{core::int}.{core::num::-}(other){(core::num) → core::num};
+  }
+}
+static method test1(self::C c) → core::String {
+  #L1:
+  {
+    final synthesized self::C #0#0 = c;
+    {
+      if(#0#0.{self::C::>}(#C1){(core::num) → dynamic} as{ForNonNullableByDefault} core::bool) {
+        {
+          return "1";
+        }
+      }
+    }
+    {
+      {
+        {
+          return "no match";
+        }
+      }
+    }
+  }
+}
+static method main() → dynamic {
+  self::C c1 = new self::C::•(0);
+  self::C c2 = new self::C::•(2);
+  self::throws(() → void {
+    self::test1(c1);
+  });
+}
+static method throws(() → void f) → dynamic {
+  try {
+    f(){() → void};
+  }
+  on core::Object catch(final core::Object e) {
+    core::print(e);
+    return;
+  }
+  throw "Missing exception";
+}
+
+constants  {
+  #C1 = 1
+}
diff --git a/pkg/front_end/testcases/patterns/issue51724_2.dart.weak.outline.expect b/pkg/front_end/testcases/patterns/issue51724_2.dart.weak.outline.expect
new file mode 100644
index 0000000..cc16f25
--- /dev/null
+++ b/pkg/front_end/testcases/patterns/issue51724_2.dart.weak.outline.expect
@@ -0,0 +1,20 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "dart:core" as core;
+
+class C extends core::Object {
+  final field core::int value;
+  field core::String log;
+  constructor •(core::int value) → self::C
+    ;
+  method clearLog() → void
+    ;
+  operator >(core::num other) → dynamic
+    ;
+}
+static method test1(self::C c) → core::String
+  ;
+static method main() → dynamic
+  ;
+static method throws(() → void f) → dynamic
+  ;
diff --git a/pkg/front_end/testcases/patterns/issue51724_2.dart.weak.transformed.expect b/pkg/front_end/testcases/patterns/issue51724_2.dart.weak.transformed.expect
new file mode 100644
index 0000000..c036540
--- /dev/null
+++ b/pkg/front_end/testcases/patterns/issue51724_2.dart.weak.transformed.expect
@@ -0,0 +1,59 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "dart:core" as core;
+
+class C extends core::Object {
+  final field core::int value;
+  field core::String log = "";
+  constructor •(core::int value) → self::C
+    : self::C::value = value, super core::Object::•()
+    ;
+  method clearLog() → void {
+    this.{self::C::log} = "";
+  }
+  operator >(core::num other) → dynamic {
+    this.{self::C::log} = this.{self::C::log}{core::String}.{core::String::+}("C(${this.{self::C::value}{core::int}})>${other};"){(core::String) → core::String};
+    return this.{self::C::value}{core::int}.{core::num::-}(other){(core::num) → core::num};
+  }
+}
+static method test1(self::C c) → core::String {
+  #L1:
+  {
+    final synthesized self::C #0#0 = c;
+    {
+      if(#0#0.{self::C::>}(#C1){(core::num) → dynamic} as{ForNonNullableByDefault} core::bool) {
+        {
+          return "1";
+        }
+      }
+    }
+    {
+      {
+        {
+          return "no match";
+        }
+      }
+    }
+  }
+}
+static method main() → dynamic {
+  self::C c1 = new self::C::•(0);
+  self::C c2 = new self::C::•(2);
+  self::throws(() → void {
+    self::test1(c1);
+  });
+}
+static method throws(() → void f) → dynamic {
+  try {
+    f(){() → void};
+  }
+  on core::Object catch(final core::Object e) {
+    core::print(e);
+    return;
+  }
+  throw "Missing exception";
+}
+
+constants  {
+  #C1 = 1
+}
diff --git a/pkg/front_end/testcases/patterns/pattern_types.dart.strong.expect b/pkg/front_end/testcases/patterns/pattern_types.dart.strong.expect
index a5ee8e4..2d7443e 100644
--- a/pkg/front_end/testcases/patterns/pattern_types.dart.strong.expect
+++ b/pkg/front_end/testcases/patterns/pattern_types.dart.strong.expect
@@ -311,22 +311,22 @@
   }
   {
     final synthesized dynamic #2#0 = dyn;
-    if(#2#0{dynamic}.<(#C1)) {
+    if(#2#0{dynamic}.<(#C1) as{ForNonNullableByDefault} core::bool) {
     }
   }
   {
     final synthesized dynamic #3#0 = dyn;
-    if(#3#0{dynamic}.<=(#C1)) {
+    if(#3#0{dynamic}.<=(#C1) as{ForNonNullableByDefault} core::bool) {
     }
   }
   {
     final synthesized dynamic #4#0 = dyn;
-    if(#4#0{dynamic}.>(#C1)) {
+    if(#4#0{dynamic}.>(#C1) as{ForNonNullableByDefault} core::bool) {
     }
   }
   {
     final synthesized dynamic #5#0 = dyn;
-    if(#5#0{dynamic}.>=(#C1)) {
+    if(#5#0{dynamic}.>=(#C1) as{ForNonNullableByDefault} core::bool) {
     }
   }
   {
@@ -400,7 +400,7 @@
   }
   {
     final synthesized self::Class #19#0 = cls;
-    if(self::_extension#0|>=(#19#0, #C1)) {
+    if(self::_extension#0|>=(#19#0, #C1) as{ForNonNullableByDefault} core::bool) {
     }
   }
   {
diff --git a/pkg/front_end/testcases/patterns/pattern_types.dart.strong.transformed.expect b/pkg/front_end/testcases/patterns/pattern_types.dart.strong.transformed.expect
new file mode 100644
index 0000000..a85b5f6
--- /dev/null
+++ b/pkg/front_end/testcases/patterns/pattern_types.dart.strong.transformed.expect
@@ -0,0 +1,560 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:6:1: Error: 'Invalid' is imported from both 'pkg/front_end/testcases/patterns/pattern_types_lib1.dart' and 'pkg/front_end/testcases/patterns/pattern_types_lib2.dart'.
+// import 'pattern_types_lib2.dart';
+// ^^^^^^^
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:84:20: Error: Undefined name 'field'.
+//     case Invalid(: field): // invalid get
+//                    ^^^^^
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:84:18: Error: The getter name is not specified explicitly, and the pattern is not a variable. Try specifying the getter name explicitly, or using a variable pattern.
+//     case Invalid(: field): // invalid get
+//                  ^
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:75:16: Error: The getter 'missing' isn't defined for the class 'Class'.
+//  - 'Class' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+// Try correcting the name to the name of an existing getter, or defining a getter or field named 'missing'.
+//     case Class(: var missing): // Error: missing getter
+//                ^^^^^^^
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:76:17: Error: The getter 'field' isn't defined for the class 'Class?'.
+//  - 'Class' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+// Try correcting the name to the name of an existing getter, or defining a getter or field named 'field'.
+//     case Class_(: var field): // Error: nullable member get
+//                 ^^^^^
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:77:17: Error: The getter 'method' isn't defined for the class 'Class?'.
+//  - 'Class' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+// Try correcting the name to the name of an existing getter, or defining a getter or field named 'method'.
+//     case Class_(: var method): // Error: nullable member tear-off
+//                 ^^^^^^
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:78:17: Error: The getter 'extensionGetter' isn't defined for the class 'Class?'.
+//  - 'Class' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+// Try correcting the name to the name of an existing getter, or defining a getter or field named 'extensionGetter'.
+//     case Class_(: var extensionGetter): // Error: nullable extension member get
+//                 ^^^^^^^^^^^^^^^
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:79:17: Error: The getter 'extensionMethod' isn't defined for the class 'Class?'.
+//  - 'Class' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+// Try correcting the name to the name of an existing getter, or defining a getter or field named 'extensionMethod'.
+//     case Class_(: var extensionMethod): // Error: nullable extension tear-off
+//                 ^^^^^^^^^^^^^^^
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:80:21: Error: The getter 'call' isn't defined for the class 'void Function()?'.
+// Try correcting the name to the name of an existing getter, or defining a getter or field named 'call'.
+//     case Function1_(: var call): // Error: nullable function tear-off
+//                     ^^^^
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:81:19: Error: The getter '$1' isn't defined for the class '(int, {String named})?'.
+// Try correcting the name to the name of an existing getter, or defining a getter or field named '$1'.
+//     case Record1_(: var $1): // Error: nullable record index get
+//                   ^^
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:82:19: Error: The getter 'named' isn't defined for the class '(int, {String named})?'.
+// Try correcting the name to the name of an existing getter, or defining a getter or field named 'named'.
+//     case Record1_(: var named): // Error: nullable record named get
+//                   ^^^^^
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:83:16: Error: The getter 'ambiguousField' isn't defined for the class 'Class'.
+//  - 'Class' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+// Try correcting the name to the name of an existing getter, or defining a getter or field named 'ambiguousField'.
+//     case Class(: var ambiguousField): // Error: ambiguous get
+//                ^^^^^^^^^^^^^^
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:125:26: Error: Cannot invoke a non-'const' constructor where a const expression is expected.
+// Try using a constructor or factory that is 'const'.
+//   if (cls2 case == const Class2()) {} // instance ==
+//                          ^^^^^^
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:127:26: Error: Cannot invoke a non-'const' constructor where a const expression is expected.
+// Try using a constructor or factory that is 'const'.
+//   if (cls2 case != const Class2()) {} // instance == negated
+//                          ^^^^^^
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:129:25: Error: Cannot invoke a non-'const' constructor where a const expression is expected.
+// Try using a constructor or factory that is 'const'.
+//   if (cls2 case < const Class2()) {} // instance <
+//                         ^^^^^^
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:113:18: Error: The argument type 'String' can't be assigned to the parameter type 'int'.
+//   if (cls case < '0') {} // Error: invalid instance < argument
+//                  ^
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:115:16: Error: A value of type 'int' can't be assigned to a variable of type 'bool'.
+//   if (cls case > 0) {} // Error: invalid instance >
+//                ^
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:119:17: Error: The method '<' isn't defined for the class 'Class?'.
+//  - 'Class' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+// Try correcting the name to the name of an existing method, or defining a method named '<'.
+//   if (cls_ case < 0) {} // Error: nullable instance <
+//                 ^
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:120:17: Error: The method '<=' isn't defined for the class 'Class?'.
+//  - 'Class' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+// Try correcting the name to the name of an existing method, or defining a method named '<='.
+//   if (cls_ case <= 0) {} // Error: nullable extension <=
+//                 ^^
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:121:19: Error: The method '<' isn't defined for the class 'String'.
+// Try correcting the name to the name of an existing method, or defining a method named '<'.
+//   if (string case < 0) {} // Error: missing <
+//                   ^
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:122:19: Error: The method '<=' isn't defined for the class 'String'.
+// Try correcting the name to the name of an existing method, or defining a method named '<='.
+//   if (string case <= 0) {} // Error: ambiguous <=
+//                   ^^
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:126:20: Error: The argument type 'int' can't be assigned to the parameter type 'Class2'.
+//  - 'Class2' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+//   if (cls2 case == 0) {} // Error: invalid instance == argument
+//                    ^
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:128:20: Error: The argument type 'int' can't be assigned to the parameter type 'Class2'.
+//  - 'Class2' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+//   if (cls2 case != 0) {} // Error: invalid instance == argument negated
+//                    ^
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:130:19: Error: The argument type 'int' can't be assigned to the parameter type 'Class2'.
+//  - 'Class2' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+//   if (cls2 case < 0) {} // Error: invalid instance < argument
+//                   ^
+//
+import self as self;
+import "dart:core" as core;
+
+import "org-dartlang-testcase:///pattern_types_lib1.dart";
+import "org-dartlang-testcase:///pattern_types_lib2.dart";
+
+typedef Dynamic = dynamic;
+typedef Function1 = () → void;
+typedef Function1_ = () →? void;
+typedef Record1 = (core::int, {required named: core::String});
+typedef Record1_ = (core::int, {required named: core::String})?;
+typedef Class_ = self::Class?;
+class Class extends core::Object {
+  field dynamic field = null;
+  synthetic constructor •() → self::Class
+    : super core::Object::•()
+    ;
+  method method() → void {}
+  operator <(core::int i) → core::bool
+    return true;
+  operator >(core::int i) → core::int
+    return 0;
+  operator ==(core::Object other) → core::bool
+    return true;
+}
+class Class2 extends core::Object {
+  synthetic constructor •() → self::Class2
+    : super core::Object::•()
+    ;
+  operator <(self::Class2 i) → core::bool
+    return true;
+  operator ==(covariant-by-declaration self::Class2 other) → core::bool
+    return true;
+}
+extension /* unnamed */ _extension#0 on self::Class {
+  get extensionGetter = self::_extension#0|get#extensionGetter;
+  method extensionMethod = self::_extension#0|extensionMethod;
+  tearoff extensionMethod = self::_extension#0|get#extensionMethod;
+  operator <= = self::_extension#0|<=;
+  operator >= = self::_extension#0|>=;
+  get ambiguousField = self::_extension#0|get#ambiguousField;
+}
+extension /* unnamed */ _extension#1 on self::Class {
+  get ambiguousField = self::_extension#1|get#ambiguousField;
+}
+extension /* unnamed */ _extension#2 on core::String {
+  operator <= = self::_extension#2|<=;
+}
+extension /* unnamed */ _extension#3 on core::String {
+  operator <= = self::_extension#3|<=;
+}
+static method _extension#0|get#extensionGetter(lowered final self::Class #this) → core::int
+  return 42;
+static method _extension#0|extensionMethod(lowered final self::Class #this) → void {}
+static method _extension#0|get#extensionMethod(lowered final self::Class #this) → () → void
+  return () → void => self::_extension#0|extensionMethod(#this);
+static method _extension#0|<=(lowered final self::Class #this, core::int i) → core::bool
+  return true;
+static method _extension#0|>=(lowered final self::Class #this, core::int i) → core::int
+  return 0;
+static method _extension#0|get#ambiguousField(lowered final self::Class #this) → core::int
+  return 42;
+static method _extension#1|get#ambiguousField(lowered final self::Class #this) → core::String
+  return "42";
+static method _extension#2|<=(lowered final core::String #this, dynamic other) → core::bool
+  return true;
+static method _extension#3|<=(lowered final core::String #this, dynamic other) → core::bool
+  return true;
+static method objectPattern(dynamic o) → dynamic {
+  #L1:
+  {
+    final synthesized dynamic #0#0 = o;
+    synthesized dynamic #0#5;
+    synthesized core::bool #0#5#isSet = false;
+    synthesized dynamic #0#6;
+    synthesized core::bool #0#6#isSet = false;
+    synthesized dynamic #0#12;
+    synthesized core::bool #0#12#isSet = false;
+    synthesized dynamic #0#14;
+    synthesized core::bool #0#14#isSet = false;
+    synthesized dynamic #0#15;
+    synthesized core::bool #0#15#isSet = false;
+    {
+      core::int hashCode;
+      () → core::String toString;
+      lowered dynamic field#case#0;
+      lowered () → void method#case#0;
+      lowered dynamic extensionGetter#case#0;
+      lowered dynamic extensionMethod#case#0;
+      dynamic dynamicAccess;
+      lowered () → void call#case#0;
+      lowered core::int $1#case#0;
+      lowered core::String named#case#0;
+      dynamic missing;
+      lowered dynamic field#case#1;
+      lowered () → void method#case#1;
+      lowered dynamic extensionGetter#case#1;
+      lowered dynamic extensionMethod#case#1;
+      lowered () →? void call#case#1;
+      lowered core::int $1#case#1;
+      lowered core::String named#case#1;
+      dynamic ambiguousField;
+      if(#0#0 is{ForNonNullableByDefault} Null && (let final core::int #t1 = hashCode = #0#0{Null}.{core::Object::hashCode}{core::int} in true) || #0#0 is{ForNonNullableByDefault} Null && (let final () → core::String #t2 = toString = #0#0{Null}.{core::Object::toString}{() → core::String} in true) || #0#0 is{ForNonNullableByDefault} self::Class && (let final dynamic #t3 = field#case#0 = #0#5#isSet ?{dynamic} #0#5{dynamic} : let final core::bool* #t4 = #0#5#isSet = true in #0#5 = #0#0{self::Class}.{self::Class::field}{dynamic} in true) || #0#0 is{ForNonNullableByDefault} self::Class && (let final () → void #t5 = method#case#0 = #0#6#isSet ?{() → void} #0#6{() → void} : let final core::bool* #t6 = #0#6#isSet = true in #0#6 = #0#0{self::Class}.{self::Class::method}{() → void} in true) || #0#0 is{ForNonNullableByDefault} self::Class && (let final core::int #t7 = extensionGetter#case#0 = self::_extension#0|get#extensionGetter(#0#0{self::Class}) in true) || #0#0 is{ForNonNullableByDefault} self::Class && (let final void #t8 = extensionMethod#case#0 = self::_extension#0|extensionMethod(#0#0{self::Class}) in true) || #0#0 is{ForNonNullableByDefault} dynamic && (let final dynamic #t9 = dynamicAccess = #0#0{dynamic}.dynamicAccess in true) || #0#0 is{ForNonNullableByDefault} () → void && (let final () → void #t10 = call#case#0 = #0#12#isSet ?{() → void} #0#12{() → void} : let final core::bool* #t11 = #0#12#isSet = true in #0#12 = #0#0{() → void}.call in true) || #0#0 is{ForNonNullableByDefault} (core::int, {required named: core::String}) && (let final core::int #t12 = $1#case#0 = #0#14#isSet ?{core::int} #0#14{core::int} : let final core::bool* #t13 = #0#14#isSet = true in #0#14 = #0#0{(core::int, {required named: core::String})}.$1{core::int} in true) || #0#0 is{ForNonNullableByDefault} (core::int, {required named: core::String}) && (let final core::String #t14 = named#case#0 = #0#15#isSet ?{core::String} #0#15{core::String} : let final core::bool* #t15 = #0#15#isSet = true in #0#15 = #0#0{(core::int, {required named: core::String})}.named{core::String} in true) || #0#0 is{ForNonNullableByDefault} self::Class && (let final invalid-type #t16 = invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:75:16: Error: The getter 'missing' isn't defined for the class 'Class'.
+ - 'Class' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'missing'.
+    case Class(: var missing): // Error: missing getter
+               ^^^^^^^" in invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:75:16: Error: The getter 'missing' isn't defined for the class 'Class'.
+ - 'Class' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'missing'.
+    case Class(: var missing): // Error: missing getter
+               ^^^^^^^") || #0#0 is{ForNonNullableByDefault} self::Class? && (let final invalid-type #t17 = #0#5#isSet ?{invalid-type} #0#5{invalid-type} : let final core::bool* #t18 = #0#5#isSet = true in #0#5 = invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:76:17: Error: The getter 'field' isn't defined for the class 'Class?'.
+ - 'Class' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'field'.
+    case Class_(: var field): // Error: nullable member get
+                ^^^^^" in invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:76:17: Error: The getter 'field' isn't defined for the class 'Class?'.
+ - 'Class' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'field'.
+    case Class_(: var field): // Error: nullable member get
+                ^^^^^") || #0#0 is{ForNonNullableByDefault} self::Class? && (let final invalid-type #t19 = #0#6#isSet ?{invalid-type} #0#6{invalid-type} : let final core::bool* #t20 = #0#6#isSet = true in #0#6 = invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:77:17: Error: The getter 'method' isn't defined for the class 'Class?'.
+ - 'Class' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'method'.
+    case Class_(: var method): // Error: nullable member tear-off
+                ^^^^^^" in invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:77:17: Error: The getter 'method' isn't defined for the class 'Class?'.
+ - 'Class' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'method'.
+    case Class_(: var method): // Error: nullable member tear-off
+                ^^^^^^") || #0#0 is{ForNonNullableByDefault} self::Class? && (let final invalid-type #t21 = invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:78:17: Error: The getter 'extensionGetter' isn't defined for the class 'Class?'.
+ - 'Class' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'extensionGetter'.
+    case Class_(: var extensionGetter): // Error: nullable extension member get
+                ^^^^^^^^^^^^^^^" in invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:78:17: Error: The getter 'extensionGetter' isn't defined for the class 'Class?'.
+ - 'Class' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'extensionGetter'.
+    case Class_(: var extensionGetter): // Error: nullable extension member get
+                ^^^^^^^^^^^^^^^") || #0#0 is{ForNonNullableByDefault} self::Class? && (let final invalid-type #t22 = invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:79:17: Error: The getter 'extensionMethod' isn't defined for the class 'Class?'.
+ - 'Class' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'extensionMethod'.
+    case Class_(: var extensionMethod): // Error: nullable extension tear-off
+                ^^^^^^^^^^^^^^^" in invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:79:17: Error: The getter 'extensionMethod' isn't defined for the class 'Class?'.
+ - 'Class' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'extensionMethod'.
+    case Class_(: var extensionMethod): // Error: nullable extension tear-off
+                ^^^^^^^^^^^^^^^") || #0#0 is{ForNonNullableByDefault} () →? void && (let final invalid-type #t23 = #0#12#isSet ?{invalid-type} #0#12{invalid-type} : let final core::bool* #t24 = #0#12#isSet = true in #0#12 = invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:80:21: Error: The getter 'call' isn't defined for the class 'void Function()?'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'call'.
+    case Function1_(: var call): // Error: nullable function tear-off
+                    ^^^^" in invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:80:21: Error: The getter 'call' isn't defined for the class 'void Function()?'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'call'.
+    case Function1_(: var call): // Error: nullable function tear-off
+                    ^^^^") || #0#0 is{ForNonNullableByDefault} (core::int, {required named: core::String})? && (let final invalid-type #t25 = #0#14#isSet ?{invalid-type} #0#14{invalid-type} : let final core::bool* #t26 = #0#14#isSet = true in #0#14 = invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:81:19: Error: The getter '\$1' isn't defined for the class '(int, {String named})?'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named '\$1'.
+    case Record1_(: var \$1): // Error: nullable record index get
+                  ^^" in invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:81:19: Error: The getter '\$1' isn't defined for the class '(int, {String named})?'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named '\$1'.
+    case Record1_(: var \$1): // Error: nullable record index get
+                  ^^") || #0#0 is{ForNonNullableByDefault} (core::int, {required named: core::String})? && (let final invalid-type #t27 = #0#15#isSet ?{invalid-type} #0#15{invalid-type} : let final core::bool* #t28 = #0#15#isSet = true in #0#15 = invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:82:19: Error: The getter 'named' isn't defined for the class '(int, {String named})?'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'named'.
+    case Record1_(: var named): // Error: nullable record named get
+                  ^^^^^" in invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:82:19: Error: The getter 'named' isn't defined for the class '(int, {String named})?'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'named'.
+    case Record1_(: var named): // Error: nullable record named get
+                  ^^^^^") || #0#0 is{ForNonNullableByDefault} self::Class && (let final invalid-type #t29 = invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:83:16: Error: The getter 'ambiguousField' isn't defined for the class 'Class'.
+ - 'Class' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'ambiguousField'.
+    case Class(: var ambiguousField): // Error: ambiguous get
+               ^^^^^^^^^^^^^^" in invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:83:16: Error: The getter 'ambiguousField' isn't defined for the class 'Class'.
+ - 'Class' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'ambiguousField'.
+    case Class(: var ambiguousField): // Error: ambiguous get
+               ^^^^^^^^^^^^^^") || #0#0 is{ForNonNullableByDefault} invalid-type) {
+      }
+    }
+  }
+}
+static method relationalPattern(dynamic dyn, Never never, self::Class cls, self::Class? cls_, invalid-type invalid, core::String string, self::Class2 cls2, self::Class2? cls2_) → dynamic {
+  {
+    final synthesized dynamic #0#0 = dyn;
+    if(#0#0 =={core::Object::==}{(core::Object) → core::bool} #C1) {
+    }
+  }
+  {
+    final synthesized dynamic #1#0 = dyn;
+    if(!(#1#0 =={core::Object::==}{(core::Object) → core::bool} #C1)) {
+    }
+  }
+  {
+    final synthesized dynamic #2#0 = dyn;
+    if(#2#0{dynamic}.<(#C1) as{ForNonNullableByDefault} core::bool) {
+    }
+  }
+  {
+    final synthesized dynamic #3#0 = dyn;
+    if(#3#0{dynamic}.<=(#C1) as{ForNonNullableByDefault} core::bool) {
+    }
+  }
+  {
+    final synthesized dynamic #4#0 = dyn;
+    if(#4#0{dynamic}.>(#C1) as{ForNonNullableByDefault} core::bool) {
+    }
+  }
+  {
+    final synthesized dynamic #5#0 = dyn;
+    if(#5#0{dynamic}.>=(#C1) as{ForNonNullableByDefault} core::bool) {
+    }
+  }
+  {
+    final synthesized Never #6#0 = never;
+    if(#6#0 =={core::Object::==}{(dynamic) → Never} #C1) {
+    }
+  }
+  {
+    final synthesized Never #7#0 = never;
+    if(!(#7#0 =={core::Object::==}{(dynamic) → Never} #C1)) {
+    }
+  }
+  {
+    final synthesized Never #8#0 = never;
+    if(#8#0{Never}.<(#C1)) {
+    }
+  }
+  {
+    final synthesized Never #9#0 = never;
+    if(#9#0{Never}.<=(#C1)) {
+    }
+  }
+  {
+    final synthesized Never #10#0 = never;
+    if(#10#0{Never}.>(#C1)) {
+    }
+  }
+  {
+    final synthesized Never #11#0 = never;
+    if(#11#0{Never}.>=(#C1)) {
+    }
+  }
+  {
+    final synthesized self::Class #12#0 = cls;
+    if(#12#0 =={self::Class::==}{(core::Object) → core::bool} #C1) {
+    }
+  }
+  {
+    final synthesized self::Class #13#0 = cls;
+    if(!(#13#0 =={self::Class::==}{(core::Object) → core::bool} #C1)) {
+    }
+  }
+  {
+    final synthesized self::Class #14#0 = cls;
+    if(#14#0.{self::Class::<}(#C1){(core::int) → core::bool}) {
+    }
+  }
+  {
+    final synthesized self::Class #15#0 = cls;
+    if(self::_extension#0|<=(#15#0, #C1)) {
+    }
+  }
+  {
+    final synthesized self::Class #16#0 = cls;
+    if(invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:113:18: Error: The argument type 'String' can't be assigned to the parameter type 'int'.
+  if (cls case < '0') {} // Error: invalid instance < argument
+                 ^") {
+    }
+  }
+  {
+    final synthesized self::Class #17#0 = cls;
+    if(self::_extension#0|<=(#17#0, #C2 as{ForNonNullableByDefault} core::int)) {
+    }
+  }
+  {
+    final synthesized self::Class #18#0 = cls;
+    if(invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:115:16: Error: A value of type 'int' can't be assigned to a variable of type 'bool'.
+  if (cls case > 0) {} // Error: invalid instance >
+               ^") {
+    }
+  }
+  {
+    final synthesized self::Class #19#0 = cls;
+    if(self::_extension#0|>=(#19#0, #C1) as{ForNonNullableByDefault} core::bool) {
+    }
+  }
+  {
+    final synthesized self::Class? #20#0 = cls_;
+    if(#20#0 =={self::Class::==}{(core::Object) → core::bool} #C1) {
+    }
+  }
+  {
+    final synthesized self::Class? #21#0 = cls_;
+    if(!(#21#0 =={self::Class::==}{(core::Object) → core::bool} #C1)) {
+    }
+  }
+  {
+    final synthesized self::Class? #22#0 = cls_;
+    if(invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:119:17: Error: The method '<' isn't defined for the class 'Class?'.
+ - 'Class' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+Try correcting the name to the name of an existing method, or defining a method named '<'.
+  if (cls_ case < 0) {} // Error: nullable instance <
+                ^") {
+    }
+  }
+  {
+    final synthesized self::Class? #23#0 = cls_;
+    if(invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:120:17: Error: The method '<=' isn't defined for the class 'Class?'.
+ - 'Class' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+Try correcting the name to the name of an existing method, or defining a method named '<='.
+  if (cls_ case <= 0) {} // Error: nullable extension <=
+                ^^") {
+    }
+  }
+  {
+    final synthesized core::String #24#0 = string;
+    if(invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:121:19: Error: The method '<' isn't defined for the class 'String'.
+Try correcting the name to the name of an existing method, or defining a method named '<'.
+  if (string case < 0) {} // Error: missing <
+                  ^") {
+    }
+  }
+  {
+    final synthesized core::String #25#0 = string;
+    if(invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:122:19: Error: The method '<=' isn't defined for the class 'String'.
+Try correcting the name to the name of an existing method, or defining a method named '<='.
+  if (string case <= 0) {} // Error: ambiguous <=
+                  ^^") {
+    }
+  }
+  {
+    final synthesized invalid-type #26#0 = invalid;
+    if(#26#0 =={core::Object::==}{(core::Object) → core::bool} #C1) {
+    }
+  }
+  {
+    final synthesized invalid-type #27#0 = invalid;
+    if(#27#0{<invalid>}.<(#C1)) {
+    }
+  }
+  {
+    final synthesized self::Class2 #28#0 = cls2;
+    final const synthesized invalid-type #28#1 = invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:125:26: Error: Cannot invoke a non-'const' constructor where a const expression is expected.
+Try using a constructor or factory that is 'const'.
+  if (cls2 case == const Class2()) {} // instance ==
+                         ^^^^^^";
+    if(#28#0 =={self::Class2::==}{(self::Class2) → core::bool} invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:125:26: Error: Cannot invoke a non-'const' constructor where a const expression is expected.
+Try using a constructor or factory that is 'const'.
+  if (cls2 case == const Class2()) {} // instance ==
+                         ^^^^^^") {
+    }
+  }
+  {
+    final synthesized self::Class2 #29#0 = cls2;
+    if(invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:126:20: Error: The argument type 'int' can't be assigned to the parameter type 'Class2'.
+ - 'Class2' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+  if (cls2 case == 0) {} // Error: invalid instance == argument
+                   ^") {
+    }
+  }
+  {
+    final synthesized self::Class2 #30#0 = cls2;
+    final const synthesized invalid-type #30#1 = invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:127:26: Error: Cannot invoke a non-'const' constructor where a const expression is expected.
+Try using a constructor or factory that is 'const'.
+  if (cls2 case != const Class2()) {} // instance == negated
+                         ^^^^^^";
+    if(!(#30#0 =={self::Class2::==}{(self::Class2) → core::bool} invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:127:26: Error: Cannot invoke a non-'const' constructor where a const expression is expected.
+Try using a constructor or factory that is 'const'.
+  if (cls2 case != const Class2()) {} // instance == negated
+                         ^^^^^^")) {
+    }
+  }
+  {
+    final synthesized self::Class2 #31#0 = cls2;
+    if(invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:128:20: Error: The argument type 'int' can't be assigned to the parameter type 'Class2'.
+ - 'Class2' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+  if (cls2 case != 0) {} // Error: invalid instance == argument negated
+                   ^") {
+    }
+  }
+  {
+    final synthesized self::Class2 #32#0 = cls2;
+    final const synthesized invalid-type #32#1 = invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:129:25: Error: Cannot invoke a non-'const' constructor where a const expression is expected.
+Try using a constructor or factory that is 'const'.
+  if (cls2 case < const Class2()) {} // instance <
+                        ^^^^^^";
+    if(#32#0.{self::Class2::<}(invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:129:25: Error: Cannot invoke a non-'const' constructor where a const expression is expected.
+Try using a constructor or factory that is 'const'.
+  if (cls2 case < const Class2()) {} // instance <
+                        ^^^^^^"){(self::Class2) → core::bool}) {
+    }
+  }
+  {
+    final synthesized self::Class2 #33#0 = cls2;
+    if(invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:130:19: Error: The argument type 'int' can't be assigned to the parameter type 'Class2'.
+ - 'Class2' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+  if (cls2 case < 0) {} // Error: invalid instance < argument
+                  ^") {
+    }
+  }
+  {
+    final synthesized self::Class2? #34#0 = cls2_;
+    if(#34#0 == null) {
+    }
+  }
+}
+
+library /*isNonNullableByDefault*/;
+import self as self2;
+import "dart:core" as core;
+
+class Invalid extends core::Object {
+  field dynamic field = null;
+  synthetic constructor •() → self2::Invalid
+    : super core::Object::•()
+    ;
+  operator <(dynamic other) → dynamic
+    return true;
+  operator ==(core::Object other) → core::bool
+    return true;
+}
+
+library /*isNonNullableByDefault*/;
+import self as self3;
+import "dart:core" as core;
+
+class Invalid extends core::Object {
+  field dynamic field = null;
+  synthetic constructor •() → self3::Invalid
+    : super core::Object::•()
+    ;
+  operator <(dynamic other) → dynamic
+    return true;
+  operator ==(core::Object other) → core::bool
+    return true;
+}
+
+constants  {
+  #C1 = 0
+  #C2 = "0"
+}
diff --git a/pkg/front_end/testcases/patterns/pattern_types.dart.weak.expect b/pkg/front_end/testcases/patterns/pattern_types.dart.weak.expect
index 42ddd8d..a92a26f 100644
--- a/pkg/front_end/testcases/patterns/pattern_types.dart.weak.expect
+++ b/pkg/front_end/testcases/patterns/pattern_types.dart.weak.expect
@@ -312,22 +312,22 @@
   }
   {
     final synthesized dynamic #2#0 = dyn;
-    if(#2#0{dynamic}.<(#C1)) {
+    if(#2#0{dynamic}.<(#C1) as{ForNonNullableByDefault} core::bool) {
     }
   }
   {
     final synthesized dynamic #3#0 = dyn;
-    if(#3#0{dynamic}.<=(#C1)) {
+    if(#3#0{dynamic}.<=(#C1) as{ForNonNullableByDefault} core::bool) {
     }
   }
   {
     final synthesized dynamic #4#0 = dyn;
-    if(#4#0{dynamic}.>(#C1)) {
+    if(#4#0{dynamic}.>(#C1) as{ForNonNullableByDefault} core::bool) {
     }
   }
   {
     final synthesized dynamic #5#0 = dyn;
-    if(#5#0{dynamic}.>=(#C1)) {
+    if(#5#0{dynamic}.>=(#C1) as{ForNonNullableByDefault} core::bool) {
     }
   }
   {
@@ -401,7 +401,7 @@
   }
   {
     final synthesized self::Class #19#0 = cls;
-    if(self::_extension#0|>=(#19#0, #C1)) {
+    if(self::_extension#0|>=(#19#0, #C1) as{ForNonNullableByDefault} core::bool) {
     }
   }
   {
diff --git a/pkg/front_end/testcases/patterns/pattern_types.dart.weak.modular.expect b/pkg/front_end/testcases/patterns/pattern_types.dart.weak.modular.expect
index 42ddd8d..a92a26f 100644
--- a/pkg/front_end/testcases/patterns/pattern_types.dart.weak.modular.expect
+++ b/pkg/front_end/testcases/patterns/pattern_types.dart.weak.modular.expect
@@ -312,22 +312,22 @@
   }
   {
     final synthesized dynamic #2#0 = dyn;
-    if(#2#0{dynamic}.<(#C1)) {
+    if(#2#0{dynamic}.<(#C1) as{ForNonNullableByDefault} core::bool) {
     }
   }
   {
     final synthesized dynamic #3#0 = dyn;
-    if(#3#0{dynamic}.<=(#C1)) {
+    if(#3#0{dynamic}.<=(#C1) as{ForNonNullableByDefault} core::bool) {
     }
   }
   {
     final synthesized dynamic #4#0 = dyn;
-    if(#4#0{dynamic}.>(#C1)) {
+    if(#4#0{dynamic}.>(#C1) as{ForNonNullableByDefault} core::bool) {
     }
   }
   {
     final synthesized dynamic #5#0 = dyn;
-    if(#5#0{dynamic}.>=(#C1)) {
+    if(#5#0{dynamic}.>=(#C1) as{ForNonNullableByDefault} core::bool) {
     }
   }
   {
@@ -401,7 +401,7 @@
   }
   {
     final synthesized self::Class #19#0 = cls;
-    if(self::_extension#0|>=(#19#0, #C1)) {
+    if(self::_extension#0|>=(#19#0, #C1) as{ForNonNullableByDefault} core::bool) {
     }
   }
   {
diff --git a/pkg/front_end/testcases/patterns/pattern_types.dart.weak.transformed.expect b/pkg/front_end/testcases/patterns/pattern_types.dart.weak.transformed.expect
new file mode 100644
index 0000000..66c4e26
--- /dev/null
+++ b/pkg/front_end/testcases/patterns/pattern_types.dart.weak.transformed.expect
@@ -0,0 +1,561 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:6:1: Error: 'Invalid' is imported from both 'pkg/front_end/testcases/patterns/pattern_types_lib1.dart' and 'pkg/front_end/testcases/patterns/pattern_types_lib2.dart'.
+// import 'pattern_types_lib2.dart';
+// ^^^^^^^
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:84:20: Error: Undefined name 'field'.
+//     case Invalid(: field): // invalid get
+//                    ^^^^^
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:84:18: Error: The getter name is not specified explicitly, and the pattern is not a variable. Try specifying the getter name explicitly, or using a variable pattern.
+//     case Invalid(: field): // invalid get
+//                  ^
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:75:16: Error: The getter 'missing' isn't defined for the class 'Class'.
+//  - 'Class' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+// Try correcting the name to the name of an existing getter, or defining a getter or field named 'missing'.
+//     case Class(: var missing): // Error: missing getter
+//                ^^^^^^^
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:76:17: Error: The getter 'field' isn't defined for the class 'Class?'.
+//  - 'Class' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+// Try correcting the name to the name of an existing getter, or defining a getter or field named 'field'.
+//     case Class_(: var field): // Error: nullable member get
+//                 ^^^^^
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:77:17: Error: The getter 'method' isn't defined for the class 'Class?'.
+//  - 'Class' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+// Try correcting the name to the name of an existing getter, or defining a getter or field named 'method'.
+//     case Class_(: var method): // Error: nullable member tear-off
+//                 ^^^^^^
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:78:17: Error: The getter 'extensionGetter' isn't defined for the class 'Class?'.
+//  - 'Class' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+// Try correcting the name to the name of an existing getter, or defining a getter or field named 'extensionGetter'.
+//     case Class_(: var extensionGetter): // Error: nullable extension member get
+//                 ^^^^^^^^^^^^^^^
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:79:17: Error: The getter 'extensionMethod' isn't defined for the class 'Class?'.
+//  - 'Class' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+// Try correcting the name to the name of an existing getter, or defining a getter or field named 'extensionMethod'.
+//     case Class_(: var extensionMethod): // Error: nullable extension tear-off
+//                 ^^^^^^^^^^^^^^^
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:80:21: Error: The getter 'call' isn't defined for the class 'void Function()?'.
+// Try correcting the name to the name of an existing getter, or defining a getter or field named 'call'.
+//     case Function1_(: var call): // Error: nullable function tear-off
+//                     ^^^^
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:81:19: Error: The getter '$1' isn't defined for the class '(int, {String named})?'.
+// Try correcting the name to the name of an existing getter, or defining a getter or field named '$1'.
+//     case Record1_(: var $1): // Error: nullable record index get
+//                   ^^
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:82:19: Error: The getter 'named' isn't defined for the class '(int, {String named})?'.
+// Try correcting the name to the name of an existing getter, or defining a getter or field named 'named'.
+//     case Record1_(: var named): // Error: nullable record named get
+//                   ^^^^^
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:83:16: Error: The getter 'ambiguousField' isn't defined for the class 'Class'.
+//  - 'Class' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+// Try correcting the name to the name of an existing getter, or defining a getter or field named 'ambiguousField'.
+//     case Class(: var ambiguousField): // Error: ambiguous get
+//                ^^^^^^^^^^^^^^
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:125:26: Error: Cannot invoke a non-'const' constructor where a const expression is expected.
+// Try using a constructor or factory that is 'const'.
+//   if (cls2 case == const Class2()) {} // instance ==
+//                          ^^^^^^
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:127:26: Error: Cannot invoke a non-'const' constructor where a const expression is expected.
+// Try using a constructor or factory that is 'const'.
+//   if (cls2 case != const Class2()) {} // instance == negated
+//                          ^^^^^^
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:129:25: Error: Cannot invoke a non-'const' constructor where a const expression is expected.
+// Try using a constructor or factory that is 'const'.
+//   if (cls2 case < const Class2()) {} // instance <
+//                         ^^^^^^
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:113:18: Error: The argument type 'String' can't be assigned to the parameter type 'int'.
+//   if (cls case < '0') {} // Error: invalid instance < argument
+//                  ^
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:115:16: Error: A value of type 'int' can't be assigned to a variable of type 'bool'.
+//   if (cls case > 0) {} // Error: invalid instance >
+//                ^
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:119:17: Error: The method '<' isn't defined for the class 'Class?'.
+//  - 'Class' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+// Try correcting the name to the name of an existing method, or defining a method named '<'.
+//   if (cls_ case < 0) {} // Error: nullable instance <
+//                 ^
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:120:17: Error: The method '<=' isn't defined for the class 'Class?'.
+//  - 'Class' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+// Try correcting the name to the name of an existing method, or defining a method named '<='.
+//   if (cls_ case <= 0) {} // Error: nullable extension <=
+//                 ^^
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:121:19: Error: The method '<' isn't defined for the class 'String'.
+// Try correcting the name to the name of an existing method, or defining a method named '<'.
+//   if (string case < 0) {} // Error: missing <
+//                   ^
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:122:19: Error: The method '<=' isn't defined for the class 'String'.
+// Try correcting the name to the name of an existing method, or defining a method named '<='.
+//   if (string case <= 0) {} // Error: ambiguous <=
+//                   ^^
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:126:20: Error: The argument type 'int' can't be assigned to the parameter type 'Class2'.
+//  - 'Class2' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+//   if (cls2 case == 0) {} // Error: invalid instance == argument
+//                    ^
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:128:20: Error: The argument type 'int' can't be assigned to the parameter type 'Class2'.
+//  - 'Class2' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+//   if (cls2 case != 0) {} // Error: invalid instance == argument negated
+//                    ^
+//
+// pkg/front_end/testcases/patterns/pattern_types.dart:130:19: Error: The argument type 'int' can't be assigned to the parameter type 'Class2'.
+//  - 'Class2' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+//   if (cls2 case < 0) {} // Error: invalid instance < argument
+//                   ^
+//
+import self as self;
+import "dart:core" as core;
+import "dart:_internal" as _in;
+
+import "org-dartlang-testcase:///pattern_types_lib1.dart";
+import "org-dartlang-testcase:///pattern_types_lib2.dart";
+
+typedef Dynamic = dynamic;
+typedef Function1 = () → void;
+typedef Function1_ = () →? void;
+typedef Record1 = (core::int, {required named: core::String});
+typedef Record1_ = (core::int, {required named: core::String})?;
+typedef Class_ = self::Class?;
+class Class extends core::Object {
+  field dynamic field = null;
+  synthetic constructor •() → self::Class
+    : super core::Object::•()
+    ;
+  method method() → void {}
+  operator <(core::int i) → core::bool
+    return true;
+  operator >(core::int i) → core::int
+    return 0;
+  operator ==(core::Object other) → core::bool
+    return true;
+}
+class Class2 extends core::Object {
+  synthetic constructor •() → self::Class2
+    : super core::Object::•()
+    ;
+  operator <(self::Class2 i) → core::bool
+    return true;
+  operator ==(covariant-by-declaration self::Class2 other) → core::bool
+    return true;
+}
+extension /* unnamed */ _extension#0 on self::Class {
+  get extensionGetter = self::_extension#0|get#extensionGetter;
+  method extensionMethod = self::_extension#0|extensionMethod;
+  tearoff extensionMethod = self::_extension#0|get#extensionMethod;
+  operator <= = self::_extension#0|<=;
+  operator >= = self::_extension#0|>=;
+  get ambiguousField = self::_extension#0|get#ambiguousField;
+}
+extension /* unnamed */ _extension#1 on self::Class {
+  get ambiguousField = self::_extension#1|get#ambiguousField;
+}
+extension /* unnamed */ _extension#2 on core::String {
+  operator <= = self::_extension#2|<=;
+}
+extension /* unnamed */ _extension#3 on core::String {
+  operator <= = self::_extension#3|<=;
+}
+static method _extension#0|get#extensionGetter(lowered final self::Class #this) → core::int
+  return 42;
+static method _extension#0|extensionMethod(lowered final self::Class #this) → void {}
+static method _extension#0|get#extensionMethod(lowered final self::Class #this) → () → void
+  return () → void => self::_extension#0|extensionMethod(#this);
+static method _extension#0|<=(lowered final self::Class #this, core::int i) → core::bool
+  return true;
+static method _extension#0|>=(lowered final self::Class #this, core::int i) → core::int
+  return 0;
+static method _extension#0|get#ambiguousField(lowered final self::Class #this) → core::int
+  return 42;
+static method _extension#1|get#ambiguousField(lowered final self::Class #this) → core::String
+  return "42";
+static method _extension#2|<=(lowered final core::String #this, dynamic other) → core::bool
+  return true;
+static method _extension#3|<=(lowered final core::String #this, dynamic other) → core::bool
+  return true;
+static method objectPattern(dynamic o) → dynamic {
+  #L1:
+  {
+    final synthesized dynamic #0#0 = o;
+    synthesized dynamic #0#5;
+    synthesized core::bool #0#5#isSet = false;
+    synthesized dynamic #0#6;
+    synthesized core::bool #0#6#isSet = false;
+    synthesized dynamic #0#12;
+    synthesized core::bool #0#12#isSet = false;
+    synthesized dynamic #0#14;
+    synthesized core::bool #0#14#isSet = false;
+    synthesized dynamic #0#15;
+    synthesized core::bool #0#15#isSet = false;
+    {
+      core::int hashCode;
+      () → core::String toString;
+      lowered dynamic field#case#0;
+      lowered () → void method#case#0;
+      lowered dynamic extensionGetter#case#0;
+      lowered dynamic extensionMethod#case#0;
+      dynamic dynamicAccess;
+      lowered () → void call#case#0;
+      lowered core::int $1#case#0;
+      lowered core::String named#case#0;
+      dynamic missing;
+      lowered dynamic field#case#1;
+      lowered () → void method#case#1;
+      lowered dynamic extensionGetter#case#1;
+      lowered dynamic extensionMethod#case#1;
+      lowered () →? void call#case#1;
+      lowered core::int $1#case#1;
+      lowered core::String named#case#1;
+      dynamic ambiguousField;
+      if(#0#0 is{ForNonNullableByDefault} Null && (let final core::int #t1 = hashCode = #0#0{Null}.{core::Object::hashCode}{core::int} in true) || #0#0 is{ForNonNullableByDefault} Null && (let final () → core::String #t2 = toString = #0#0{Null}.{core::Object::toString}{() → core::String} in true) || #0#0 is{ForNonNullableByDefault} self::Class && (let final dynamic #t3 = field#case#0 = #0#5#isSet ?{dynamic} #0#5{dynamic} : let final core::bool* #t4 = #0#5#isSet = true in #0#5 = #0#0{self::Class}.{self::Class::field}{dynamic} in true) || #0#0 is{ForNonNullableByDefault} self::Class && (let final () → void #t5 = method#case#0 = #0#6#isSet ?{() → void} #0#6{() → void} : let final core::bool* #t6 = #0#6#isSet = true in #0#6 = #0#0{self::Class}.{self::Class::method}{() → void} in true) || #0#0 is{ForNonNullableByDefault} self::Class && (let final core::int #t7 = extensionGetter#case#0 = self::_extension#0|get#extensionGetter(#0#0{self::Class}) in true) || #0#0 is{ForNonNullableByDefault} self::Class && (let final void #t8 = extensionMethod#case#0 = self::_extension#0|extensionMethod(#0#0{self::Class}) in true) || #0#0 is{ForNonNullableByDefault} dynamic && (let final dynamic #t9 = dynamicAccess = #0#0{dynamic}.dynamicAccess in true) || #0#0 is{ForNonNullableByDefault} () → void && (let final () → void #t10 = call#case#0 = #0#12#isSet ?{() → void} #0#12{() → void} : let final core::bool* #t11 = #0#12#isSet = true in #0#12 = #0#0{() → void}.call in true) || #0#0 is{ForNonNullableByDefault} (core::int, {required named: core::String}) && (let final core::int #t12 = $1#case#0 = #0#14#isSet ?{core::int} #0#14{core::int} : let final core::bool* #t13 = #0#14#isSet = true in #0#14 = #0#0{(core::int, {required named: core::String})}.$1{core::int} in true) || #0#0 is{ForNonNullableByDefault} (core::int, {required named: core::String}) && (let final core::String #t14 = named#case#0 = #0#15#isSet ?{core::String} #0#15{core::String} : let final core::bool* #t15 = #0#15#isSet = true in #0#15 = #0#0{(core::int, {required named: core::String})}.named{core::String} in true) || #0#0 is{ForNonNullableByDefault} self::Class && (let final invalid-type #t16 = invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:75:16: Error: The getter 'missing' isn't defined for the class 'Class'.
+ - 'Class' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'missing'.
+    case Class(: var missing): // Error: missing getter
+               ^^^^^^^" in invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:75:16: Error: The getter 'missing' isn't defined for the class 'Class'.
+ - 'Class' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'missing'.
+    case Class(: var missing): // Error: missing getter
+               ^^^^^^^") || #0#0 is{ForNonNullableByDefault} self::Class? && (let final invalid-type #t17 = #0#5#isSet ?{invalid-type} #0#5{invalid-type} : let final core::bool* #t18 = #0#5#isSet = true in #0#5 = invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:76:17: Error: The getter 'field' isn't defined for the class 'Class?'.
+ - 'Class' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'field'.
+    case Class_(: var field): // Error: nullable member get
+                ^^^^^" in invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:76:17: Error: The getter 'field' isn't defined for the class 'Class?'.
+ - 'Class' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'field'.
+    case Class_(: var field): // Error: nullable member get
+                ^^^^^") || #0#0 is{ForNonNullableByDefault} self::Class? && (let final invalid-type #t19 = #0#6#isSet ?{invalid-type} #0#6{invalid-type} : let final core::bool* #t20 = #0#6#isSet = true in #0#6 = invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:77:17: Error: The getter 'method' isn't defined for the class 'Class?'.
+ - 'Class' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'method'.
+    case Class_(: var method): // Error: nullable member tear-off
+                ^^^^^^" in invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:77:17: Error: The getter 'method' isn't defined for the class 'Class?'.
+ - 'Class' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'method'.
+    case Class_(: var method): // Error: nullable member tear-off
+                ^^^^^^") || #0#0 is{ForNonNullableByDefault} self::Class? && (let final invalid-type #t21 = invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:78:17: Error: The getter 'extensionGetter' isn't defined for the class 'Class?'.
+ - 'Class' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'extensionGetter'.
+    case Class_(: var extensionGetter): // Error: nullable extension member get
+                ^^^^^^^^^^^^^^^" in invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:78:17: Error: The getter 'extensionGetter' isn't defined for the class 'Class?'.
+ - 'Class' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'extensionGetter'.
+    case Class_(: var extensionGetter): // Error: nullable extension member get
+                ^^^^^^^^^^^^^^^") || #0#0 is{ForNonNullableByDefault} self::Class? && (let final invalid-type #t22 = invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:79:17: Error: The getter 'extensionMethod' isn't defined for the class 'Class?'.
+ - 'Class' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'extensionMethod'.
+    case Class_(: var extensionMethod): // Error: nullable extension tear-off
+                ^^^^^^^^^^^^^^^" in invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:79:17: Error: The getter 'extensionMethod' isn't defined for the class 'Class?'.
+ - 'Class' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'extensionMethod'.
+    case Class_(: var extensionMethod): // Error: nullable extension tear-off
+                ^^^^^^^^^^^^^^^") || #0#0 is{ForNonNullableByDefault} () →? void && (let final invalid-type #t23 = #0#12#isSet ?{invalid-type} #0#12{invalid-type} : let final core::bool* #t24 = #0#12#isSet = true in #0#12 = invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:80:21: Error: The getter 'call' isn't defined for the class 'void Function()?'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'call'.
+    case Function1_(: var call): // Error: nullable function tear-off
+                    ^^^^" in invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:80:21: Error: The getter 'call' isn't defined for the class 'void Function()?'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'call'.
+    case Function1_(: var call): // Error: nullable function tear-off
+                    ^^^^") || #0#0 is{ForNonNullableByDefault} (core::int, {required named: core::String})? && (let final invalid-type #t25 = #0#14#isSet ?{invalid-type} #0#14{invalid-type} : let final core::bool* #t26 = #0#14#isSet = true in #0#14 = invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:81:19: Error: The getter '\$1' isn't defined for the class '(int, {String named})?'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named '\$1'.
+    case Record1_(: var \$1): // Error: nullable record index get
+                  ^^" in invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:81:19: Error: The getter '\$1' isn't defined for the class '(int, {String named})?'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named '\$1'.
+    case Record1_(: var \$1): // Error: nullable record index get
+                  ^^") || #0#0 is{ForNonNullableByDefault} (core::int, {required named: core::String})? && (let final invalid-type #t27 = #0#15#isSet ?{invalid-type} #0#15{invalid-type} : let final core::bool* #t28 = #0#15#isSet = true in #0#15 = invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:82:19: Error: The getter 'named' isn't defined for the class '(int, {String named})?'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'named'.
+    case Record1_(: var named): // Error: nullable record named get
+                  ^^^^^" in invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:82:19: Error: The getter 'named' isn't defined for the class '(int, {String named})?'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'named'.
+    case Record1_(: var named): // Error: nullable record named get
+                  ^^^^^") || #0#0 is{ForNonNullableByDefault} self::Class && (let final invalid-type #t29 = invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:83:16: Error: The getter 'ambiguousField' isn't defined for the class 'Class'.
+ - 'Class' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'ambiguousField'.
+    case Class(: var ambiguousField): // Error: ambiguous get
+               ^^^^^^^^^^^^^^" in invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:83:16: Error: The getter 'ambiguousField' isn't defined for the class 'Class'.
+ - 'Class' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'ambiguousField'.
+    case Class(: var ambiguousField): // Error: ambiguous get
+               ^^^^^^^^^^^^^^") || #0#0 is{ForNonNullableByDefault} invalid-type) {
+      }
+    }
+  }
+}
+static method relationalPattern(dynamic dyn, Never never, self::Class cls, self::Class? cls_, invalid-type invalid, core::String string, self::Class2 cls2, self::Class2? cls2_) → dynamic {
+  {
+    final synthesized dynamic #0#0 = dyn;
+    if(#0#0 =={core::Object::==}{(core::Object) → core::bool} #C1) {
+    }
+  }
+  {
+    final synthesized dynamic #1#0 = dyn;
+    if(!(#1#0 =={core::Object::==}{(core::Object) → core::bool} #C1)) {
+    }
+  }
+  {
+    final synthesized dynamic #2#0 = dyn;
+    if(#2#0{dynamic}.<(#C1) as{ForNonNullableByDefault} core::bool) {
+    }
+  }
+  {
+    final synthesized dynamic #3#0 = dyn;
+    if(#3#0{dynamic}.<=(#C1) as{ForNonNullableByDefault} core::bool) {
+    }
+  }
+  {
+    final synthesized dynamic #4#0 = dyn;
+    if(#4#0{dynamic}.>(#C1) as{ForNonNullableByDefault} core::bool) {
+    }
+  }
+  {
+    final synthesized dynamic #5#0 = dyn;
+    if(#5#0{dynamic}.>=(#C1) as{ForNonNullableByDefault} core::bool) {
+    }
+  }
+  {
+    final synthesized Never #6#0 = let final Never #t30 = never in throw new _in::ReachabilityError::•("`null` encountered as the result from expression with type `Never`.");
+    if(#6#0 =={core::Object::==}{(dynamic) → Never} #C1) {
+    }
+  }
+  {
+    final synthesized Never #7#0 = let final Never #t31 = never in throw new _in::ReachabilityError::•("`null` encountered as the result from expression with type `Never`.");
+    if(!(#7#0 =={core::Object::==}{(dynamic) → Never} #C1)) {
+    }
+  }
+  {
+    final synthesized Never #8#0 = let final Never #t32 = never in throw new _in::ReachabilityError::•("`null` encountered as the result from expression with type `Never`.");
+    if(#8#0{Never}.<(#C1)) {
+    }
+  }
+  {
+    final synthesized Never #9#0 = let final Never #t33 = never in throw new _in::ReachabilityError::•("`null` encountered as the result from expression with type `Never`.");
+    if(#9#0{Never}.<=(#C1)) {
+    }
+  }
+  {
+    final synthesized Never #10#0 = let final Never #t34 = never in throw new _in::ReachabilityError::•("`null` encountered as the result from expression with type `Never`.");
+    if(#10#0{Never}.>(#C1)) {
+    }
+  }
+  {
+    final synthesized Never #11#0 = let final Never #t35 = never in throw new _in::ReachabilityError::•("`null` encountered as the result from expression with type `Never`.");
+    if(#11#0{Never}.>=(#C1)) {
+    }
+  }
+  {
+    final synthesized self::Class #12#0 = cls;
+    if(#12#0 =={self::Class::==}{(core::Object) → core::bool} #C1) {
+    }
+  }
+  {
+    final synthesized self::Class #13#0 = cls;
+    if(!(#13#0 =={self::Class::==}{(core::Object) → core::bool} #C1)) {
+    }
+  }
+  {
+    final synthesized self::Class #14#0 = cls;
+    if(#14#0.{self::Class::<}(#C1){(core::int) → core::bool}) {
+    }
+  }
+  {
+    final synthesized self::Class #15#0 = cls;
+    if(self::_extension#0|<=(#15#0, #C1)) {
+    }
+  }
+  {
+    final synthesized self::Class #16#0 = cls;
+    if(invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:113:18: Error: The argument type 'String' can't be assigned to the parameter type 'int'.
+  if (cls case < '0') {} // Error: invalid instance < argument
+                 ^") {
+    }
+  }
+  {
+    final synthesized self::Class #17#0 = cls;
+    if(self::_extension#0|<=(#17#0, #C2 as{ForNonNullableByDefault} core::int)) {
+    }
+  }
+  {
+    final synthesized self::Class #18#0 = cls;
+    if(invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:115:16: Error: A value of type 'int' can't be assigned to a variable of type 'bool'.
+  if (cls case > 0) {} // Error: invalid instance >
+               ^") {
+    }
+  }
+  {
+    final synthesized self::Class #19#0 = cls;
+    if(self::_extension#0|>=(#19#0, #C1) as{ForNonNullableByDefault} core::bool) {
+    }
+  }
+  {
+    final synthesized self::Class? #20#0 = cls_;
+    if(#20#0 =={self::Class::==}{(core::Object) → core::bool} #C1) {
+    }
+  }
+  {
+    final synthesized self::Class? #21#0 = cls_;
+    if(!(#21#0 =={self::Class::==}{(core::Object) → core::bool} #C1)) {
+    }
+  }
+  {
+    final synthesized self::Class? #22#0 = cls_;
+    if(invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:119:17: Error: The method '<' isn't defined for the class 'Class?'.
+ - 'Class' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+Try correcting the name to the name of an existing method, or defining a method named '<'.
+  if (cls_ case < 0) {} // Error: nullable instance <
+                ^") {
+    }
+  }
+  {
+    final synthesized self::Class? #23#0 = cls_;
+    if(invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:120:17: Error: The method '<=' isn't defined for the class 'Class?'.
+ - 'Class' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+Try correcting the name to the name of an existing method, or defining a method named '<='.
+  if (cls_ case <= 0) {} // Error: nullable extension <=
+                ^^") {
+    }
+  }
+  {
+    final synthesized core::String #24#0 = string;
+    if(invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:121:19: Error: The method '<' isn't defined for the class 'String'.
+Try correcting the name to the name of an existing method, or defining a method named '<'.
+  if (string case < 0) {} // Error: missing <
+                  ^") {
+    }
+  }
+  {
+    final synthesized core::String #25#0 = string;
+    if(invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:122:19: Error: The method '<=' isn't defined for the class 'String'.
+Try correcting the name to the name of an existing method, or defining a method named '<='.
+  if (string case <= 0) {} // Error: ambiguous <=
+                  ^^") {
+    }
+  }
+  {
+    final synthesized invalid-type #26#0 = invalid;
+    if(#26#0 =={core::Object::==}{(core::Object) → core::bool} #C1) {
+    }
+  }
+  {
+    final synthesized invalid-type #27#0 = invalid;
+    if(#27#0{<invalid>}.<(#C1)) {
+    }
+  }
+  {
+    final synthesized self::Class2 #28#0 = cls2;
+    final const synthesized invalid-type #28#1 = invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:125:26: Error: Cannot invoke a non-'const' constructor where a const expression is expected.
+Try using a constructor or factory that is 'const'.
+  if (cls2 case == const Class2()) {} // instance ==
+                         ^^^^^^";
+    if(#28#0 =={self::Class2::==}{(self::Class2) → core::bool} invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:125:26: Error: Cannot invoke a non-'const' constructor where a const expression is expected.
+Try using a constructor or factory that is 'const'.
+  if (cls2 case == const Class2()) {} // instance ==
+                         ^^^^^^") {
+    }
+  }
+  {
+    final synthesized self::Class2 #29#0 = cls2;
+    if(invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:126:20: Error: The argument type 'int' can't be assigned to the parameter type 'Class2'.
+ - 'Class2' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+  if (cls2 case == 0) {} // Error: invalid instance == argument
+                   ^") {
+    }
+  }
+  {
+    final synthesized self::Class2 #30#0 = cls2;
+    final const synthesized invalid-type #30#1 = invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:127:26: Error: Cannot invoke a non-'const' constructor where a const expression is expected.
+Try using a constructor or factory that is 'const'.
+  if (cls2 case != const Class2()) {} // instance == negated
+                         ^^^^^^";
+    if(!(#30#0 =={self::Class2::==}{(self::Class2) → core::bool} invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:127:26: Error: Cannot invoke a non-'const' constructor where a const expression is expected.
+Try using a constructor or factory that is 'const'.
+  if (cls2 case != const Class2()) {} // instance == negated
+                         ^^^^^^")) {
+    }
+  }
+  {
+    final synthesized self::Class2 #31#0 = cls2;
+    if(invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:128:20: Error: The argument type 'int' can't be assigned to the parameter type 'Class2'.
+ - 'Class2' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+  if (cls2 case != 0) {} // Error: invalid instance == argument negated
+                   ^") {
+    }
+  }
+  {
+    final synthesized self::Class2 #32#0 = cls2;
+    final const synthesized invalid-type #32#1 = invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:129:25: Error: Cannot invoke a non-'const' constructor where a const expression is expected.
+Try using a constructor or factory that is 'const'.
+  if (cls2 case < const Class2()) {} // instance <
+                        ^^^^^^";
+    if(#32#0.{self::Class2::<}(invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:129:25: Error: Cannot invoke a non-'const' constructor where a const expression is expected.
+Try using a constructor or factory that is 'const'.
+  if (cls2 case < const Class2()) {} // instance <
+                        ^^^^^^"){(self::Class2) → core::bool}) {
+    }
+  }
+  {
+    final synthesized self::Class2 #33#0 = cls2;
+    if(invalid-expression "pkg/front_end/testcases/patterns/pattern_types.dart:130:19: Error: The argument type 'int' can't be assigned to the parameter type 'Class2'.
+ - 'Class2' is from 'pkg/front_end/testcases/patterns/pattern_types.dart'.
+  if (cls2 case < 0) {} // Error: invalid instance < argument
+                  ^") {
+    }
+  }
+  {
+    final synthesized self::Class2? #34#0 = cls2_;
+    if(#34#0 == null) {
+    }
+  }
+}
+
+library /*isNonNullableByDefault*/;
+import self as self2;
+import "dart:core" as core;
+
+class Invalid extends core::Object {
+  field dynamic field = null;
+  synthetic constructor •() → self2::Invalid
+    : super core::Object::•()
+    ;
+  operator <(dynamic other) → dynamic
+    return true;
+  operator ==(core::Object other) → core::bool
+    return true;
+}
+
+library /*isNonNullableByDefault*/;
+import self as self3;
+import "dart:core" as core;
+
+class Invalid extends core::Object {
+  field dynamic field = null;
+  synthetic constructor •() → self3::Invalid
+    : super core::Object::•()
+    ;
+  operator <(dynamic other) → dynamic
+    return true;
+  operator ==(core::Object other) → core::bool
+    return true;
+}
+
+constants  {
+  #C1 = 0
+  #C2 = "0"
+}
diff --git a/pkg/front_end/testcases/patterns/relational_inside_case_greater_than.dart.strong.expect b/pkg/front_end/testcases/patterns/relational_inside_case_greater_than.dart.strong.expect
index 61c62a2..000f695 100644
--- a/pkg/front_end/testcases/patterns/relational_inside_case_greater_than.dart.strong.expect
+++ b/pkg/front_end/testcases/patterns/relational_inside_case_greater_than.dart.strong.expect
@@ -7,7 +7,7 @@
   {
     final synthesized dynamic #0#0 = x;
     {
-      if(#0#0{dynamic}.>(#C1)) {
+      if(#0#0{dynamic}.>(#C1) as{ForNonNullableByDefault} core::bool) {
         {
           break #L1;
         }
diff --git a/pkg/front_end/testcases/patterns/relational_inside_case_greater_than.dart.strong.transformed.expect b/pkg/front_end/testcases/patterns/relational_inside_case_greater_than.dart.strong.transformed.expect
index 61c62a2..000f695 100644
--- a/pkg/front_end/testcases/patterns/relational_inside_case_greater_than.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/patterns/relational_inside_case_greater_than.dart.strong.transformed.expect
@@ -7,7 +7,7 @@
   {
     final synthesized dynamic #0#0 = x;
     {
-      if(#0#0{dynamic}.>(#C1)) {
+      if(#0#0{dynamic}.>(#C1) as{ForNonNullableByDefault} core::bool) {
         {
           break #L1;
         }
diff --git a/pkg/front_end/testcases/patterns/relational_inside_case_greater_than.dart.weak.expect b/pkg/front_end/testcases/patterns/relational_inside_case_greater_than.dart.weak.expect
index 61c62a2..000f695 100644
--- a/pkg/front_end/testcases/patterns/relational_inside_case_greater_than.dart.weak.expect
+++ b/pkg/front_end/testcases/patterns/relational_inside_case_greater_than.dart.weak.expect
@@ -7,7 +7,7 @@
   {
     final synthesized dynamic #0#0 = x;
     {
-      if(#0#0{dynamic}.>(#C1)) {
+      if(#0#0{dynamic}.>(#C1) as{ForNonNullableByDefault} core::bool) {
         {
           break #L1;
         }
diff --git a/pkg/front_end/testcases/patterns/relational_inside_case_greater_than.dart.weak.modular.expect b/pkg/front_end/testcases/patterns/relational_inside_case_greater_than.dart.weak.modular.expect
index 61c62a2..000f695 100644
--- a/pkg/front_end/testcases/patterns/relational_inside_case_greater_than.dart.weak.modular.expect
+++ b/pkg/front_end/testcases/patterns/relational_inside_case_greater_than.dart.weak.modular.expect
@@ -7,7 +7,7 @@
   {
     final synthesized dynamic #0#0 = x;
     {
-      if(#0#0{dynamic}.>(#C1)) {
+      if(#0#0{dynamic}.>(#C1) as{ForNonNullableByDefault} core::bool) {
         {
           break #L1;
         }
diff --git a/pkg/front_end/testcases/patterns/relational_inside_case_greater_than.dart.weak.transformed.expect b/pkg/front_end/testcases/patterns/relational_inside_case_greater_than.dart.weak.transformed.expect
index 61c62a2..000f695 100644
--- a/pkg/front_end/testcases/patterns/relational_inside_case_greater_than.dart.weak.transformed.expect
+++ b/pkg/front_end/testcases/patterns/relational_inside_case_greater_than.dart.weak.transformed.expect
@@ -7,7 +7,7 @@
   {
     final synthesized dynamic #0#0 = x;
     {
-      if(#0#0{dynamic}.>(#C1)) {
+      if(#0#0{dynamic}.>(#C1) as{ForNonNullableByDefault} core::bool) {
         {
           break #L1;
         }
diff --git a/pkg/front_end/testcases/patterns/relational_inside_case_greater_than_or_equal.dart.strong.expect b/pkg/front_end/testcases/patterns/relational_inside_case_greater_than_or_equal.dart.strong.expect
index 320e77f..59a73e5 100644
--- a/pkg/front_end/testcases/patterns/relational_inside_case_greater_than_or_equal.dart.strong.expect
+++ b/pkg/front_end/testcases/patterns/relational_inside_case_greater_than_or_equal.dart.strong.expect
@@ -7,7 +7,7 @@
   {
     final synthesized dynamic #0#0 = x;
     {
-      if(#0#0{dynamic}.>=(#C1)) {
+      if(#0#0{dynamic}.>=(#C1) as{ForNonNullableByDefault} core::bool) {
         {
           break #L1;
         }
diff --git a/pkg/front_end/testcases/patterns/relational_inside_case_greater_than_or_equal.dart.strong.transformed.expect b/pkg/front_end/testcases/patterns/relational_inside_case_greater_than_or_equal.dart.strong.transformed.expect
index 320e77f..59a73e5 100644
--- a/pkg/front_end/testcases/patterns/relational_inside_case_greater_than_or_equal.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/patterns/relational_inside_case_greater_than_or_equal.dart.strong.transformed.expect
@@ -7,7 +7,7 @@
   {
     final synthesized dynamic #0#0 = x;
     {
-      if(#0#0{dynamic}.>=(#C1)) {
+      if(#0#0{dynamic}.>=(#C1) as{ForNonNullableByDefault} core::bool) {
         {
           break #L1;
         }
diff --git a/pkg/front_end/testcases/patterns/relational_inside_case_greater_than_or_equal.dart.weak.expect b/pkg/front_end/testcases/patterns/relational_inside_case_greater_than_or_equal.dart.weak.expect
index 320e77f..59a73e5 100644
--- a/pkg/front_end/testcases/patterns/relational_inside_case_greater_than_or_equal.dart.weak.expect
+++ b/pkg/front_end/testcases/patterns/relational_inside_case_greater_than_or_equal.dart.weak.expect
@@ -7,7 +7,7 @@
   {
     final synthesized dynamic #0#0 = x;
     {
-      if(#0#0{dynamic}.>=(#C1)) {
+      if(#0#0{dynamic}.>=(#C1) as{ForNonNullableByDefault} core::bool) {
         {
           break #L1;
         }
diff --git a/pkg/front_end/testcases/patterns/relational_inside_case_greater_than_or_equal.dart.weak.modular.expect b/pkg/front_end/testcases/patterns/relational_inside_case_greater_than_or_equal.dart.weak.modular.expect
index 320e77f..59a73e5 100644
--- a/pkg/front_end/testcases/patterns/relational_inside_case_greater_than_or_equal.dart.weak.modular.expect
+++ b/pkg/front_end/testcases/patterns/relational_inside_case_greater_than_or_equal.dart.weak.modular.expect
@@ -7,7 +7,7 @@
   {
     final synthesized dynamic #0#0 = x;
     {
-      if(#0#0{dynamic}.>=(#C1)) {
+      if(#0#0{dynamic}.>=(#C1) as{ForNonNullableByDefault} core::bool) {
         {
           break #L1;
         }
diff --git a/pkg/front_end/testcases/patterns/relational_inside_case_greater_than_or_equal.dart.weak.transformed.expect b/pkg/front_end/testcases/patterns/relational_inside_case_greater_than_or_equal.dart.weak.transformed.expect
index 320e77f..59a73e5 100644
--- a/pkg/front_end/testcases/patterns/relational_inside_case_greater_than_or_equal.dart.weak.transformed.expect
+++ b/pkg/front_end/testcases/patterns/relational_inside_case_greater_than_or_equal.dart.weak.transformed.expect
@@ -7,7 +7,7 @@
   {
     final synthesized dynamic #0#0 = x;
     {
-      if(#0#0{dynamic}.>=(#C1)) {
+      if(#0#0{dynamic}.>=(#C1) as{ForNonNullableByDefault} core::bool) {
         {
           break #L1;
         }
diff --git a/pkg/front_end/testcases/patterns/relational_inside_case_less_than.dart.strong.expect b/pkg/front_end/testcases/patterns/relational_inside_case_less_than.dart.strong.expect
index b9a7dde..79f0b26 100644
--- a/pkg/front_end/testcases/patterns/relational_inside_case_less_than.dart.strong.expect
+++ b/pkg/front_end/testcases/patterns/relational_inside_case_less_than.dart.strong.expect
@@ -7,7 +7,7 @@
   {
     final synthesized dynamic #0#0 = x;
     {
-      if(#0#0{dynamic}.<(#C1)) {
+      if(#0#0{dynamic}.<(#C1) as{ForNonNullableByDefault} core::bool) {
         {
           break #L1;
         }
diff --git a/pkg/front_end/testcases/patterns/relational_inside_case_less_than.dart.strong.transformed.expect b/pkg/front_end/testcases/patterns/relational_inside_case_less_than.dart.strong.transformed.expect
index b9a7dde..79f0b26 100644
--- a/pkg/front_end/testcases/patterns/relational_inside_case_less_than.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/patterns/relational_inside_case_less_than.dart.strong.transformed.expect
@@ -7,7 +7,7 @@
   {
     final synthesized dynamic #0#0 = x;
     {
-      if(#0#0{dynamic}.<(#C1)) {
+      if(#0#0{dynamic}.<(#C1) as{ForNonNullableByDefault} core::bool) {
         {
           break #L1;
         }
diff --git a/pkg/front_end/testcases/patterns/relational_inside_case_less_than.dart.weak.expect b/pkg/front_end/testcases/patterns/relational_inside_case_less_than.dart.weak.expect
index b9a7dde..79f0b26 100644
--- a/pkg/front_end/testcases/patterns/relational_inside_case_less_than.dart.weak.expect
+++ b/pkg/front_end/testcases/patterns/relational_inside_case_less_than.dart.weak.expect
@@ -7,7 +7,7 @@
   {
     final synthesized dynamic #0#0 = x;
     {
-      if(#0#0{dynamic}.<(#C1)) {
+      if(#0#0{dynamic}.<(#C1) as{ForNonNullableByDefault} core::bool) {
         {
           break #L1;
         }
diff --git a/pkg/front_end/testcases/patterns/relational_inside_case_less_than.dart.weak.modular.expect b/pkg/front_end/testcases/patterns/relational_inside_case_less_than.dart.weak.modular.expect
index b9a7dde..79f0b26 100644
--- a/pkg/front_end/testcases/patterns/relational_inside_case_less_than.dart.weak.modular.expect
+++ b/pkg/front_end/testcases/patterns/relational_inside_case_less_than.dart.weak.modular.expect
@@ -7,7 +7,7 @@
   {
     final synthesized dynamic #0#0 = x;
     {
-      if(#0#0{dynamic}.<(#C1)) {
+      if(#0#0{dynamic}.<(#C1) as{ForNonNullableByDefault} core::bool) {
         {
           break #L1;
         }
diff --git a/pkg/front_end/testcases/patterns/relational_inside_case_less_than.dart.weak.transformed.expect b/pkg/front_end/testcases/patterns/relational_inside_case_less_than.dart.weak.transformed.expect
index b9a7dde..79f0b26 100644
--- a/pkg/front_end/testcases/patterns/relational_inside_case_less_than.dart.weak.transformed.expect
+++ b/pkg/front_end/testcases/patterns/relational_inside_case_less_than.dart.weak.transformed.expect
@@ -7,7 +7,7 @@
   {
     final synthesized dynamic #0#0 = x;
     {
-      if(#0#0{dynamic}.<(#C1)) {
+      if(#0#0{dynamic}.<(#C1) as{ForNonNullableByDefault} core::bool) {
         {
           break #L1;
         }
diff --git a/pkg/front_end/testcases/patterns/relational_inside_case_less_than_or_equal.dart.strong.expect b/pkg/front_end/testcases/patterns/relational_inside_case_less_than_or_equal.dart.strong.expect
index 5952133..5933783 100644
--- a/pkg/front_end/testcases/patterns/relational_inside_case_less_than_or_equal.dart.strong.expect
+++ b/pkg/front_end/testcases/patterns/relational_inside_case_less_than_or_equal.dart.strong.expect
@@ -7,7 +7,7 @@
   {
     final synthesized dynamic #0#0 = x;
     {
-      if(#0#0{dynamic}.<=(#C1)) {
+      if(#0#0{dynamic}.<=(#C1) as{ForNonNullableByDefault} core::bool) {
         {
           break #L1;
         }
diff --git a/pkg/front_end/testcases/patterns/relational_inside_case_less_than_or_equal.dart.strong.transformed.expect b/pkg/front_end/testcases/patterns/relational_inside_case_less_than_or_equal.dart.strong.transformed.expect
index 5952133..5933783 100644
--- a/pkg/front_end/testcases/patterns/relational_inside_case_less_than_or_equal.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/patterns/relational_inside_case_less_than_or_equal.dart.strong.transformed.expect
@@ -7,7 +7,7 @@
   {
     final synthesized dynamic #0#0 = x;
     {
-      if(#0#0{dynamic}.<=(#C1)) {
+      if(#0#0{dynamic}.<=(#C1) as{ForNonNullableByDefault} core::bool) {
         {
           break #L1;
         }
diff --git a/pkg/front_end/testcases/patterns/relational_inside_case_less_than_or_equal.dart.weak.expect b/pkg/front_end/testcases/patterns/relational_inside_case_less_than_or_equal.dart.weak.expect
index 5952133..5933783 100644
--- a/pkg/front_end/testcases/patterns/relational_inside_case_less_than_or_equal.dart.weak.expect
+++ b/pkg/front_end/testcases/patterns/relational_inside_case_less_than_or_equal.dart.weak.expect
@@ -7,7 +7,7 @@
   {
     final synthesized dynamic #0#0 = x;
     {
-      if(#0#0{dynamic}.<=(#C1)) {
+      if(#0#0{dynamic}.<=(#C1) as{ForNonNullableByDefault} core::bool) {
         {
           break #L1;
         }
diff --git a/pkg/front_end/testcases/patterns/relational_inside_case_less_than_or_equal.dart.weak.modular.expect b/pkg/front_end/testcases/patterns/relational_inside_case_less_than_or_equal.dart.weak.modular.expect
index 5952133..5933783 100644
--- a/pkg/front_end/testcases/patterns/relational_inside_case_less_than_or_equal.dart.weak.modular.expect
+++ b/pkg/front_end/testcases/patterns/relational_inside_case_less_than_or_equal.dart.weak.modular.expect
@@ -7,7 +7,7 @@
   {
     final synthesized dynamic #0#0 = x;
     {
-      if(#0#0{dynamic}.<=(#C1)) {
+      if(#0#0{dynamic}.<=(#C1) as{ForNonNullableByDefault} core::bool) {
         {
           break #L1;
         }
diff --git a/pkg/front_end/testcases/patterns/relational_inside_case_less_than_or_equal.dart.weak.transformed.expect b/pkg/front_end/testcases/patterns/relational_inside_case_less_than_or_equal.dart.weak.transformed.expect
index 5952133..5933783 100644
--- a/pkg/front_end/testcases/patterns/relational_inside_case_less_than_or_equal.dart.weak.transformed.expect
+++ b/pkg/front_end/testcases/patterns/relational_inside_case_less_than_or_equal.dart.weak.transformed.expect
@@ -7,7 +7,7 @@
   {
     final synthesized dynamic #0#0 = x;
     {
-      if(#0#0{dynamic}.<=(#C1)) {
+      if(#0#0{dynamic}.<=(#C1) as{ForNonNullableByDefault} core::bool) {
         {
           break #L1;
         }
diff --git a/pkg/front_end/testcases/patterns/relational_inside_if_case.dart.strong.expect b/pkg/front_end/testcases/patterns/relational_inside_if_case.dart.strong.expect
index d4b5370..8f938d2 100644
--- a/pkg/front_end/testcases/patterns/relational_inside_if_case.dart.strong.expect
+++ b/pkg/front_end/testcases/patterns/relational_inside_if_case.dart.strong.expect
@@ -30,22 +30,22 @@
   }
   {
     final synthesized dynamic #5#0 = x;
-    if(#5#0{dynamic}.<(#C1)) {
+    if(#5#0{dynamic}.<(#C1) as{ForNonNullableByDefault} core::bool) {
     }
   }
   {
     final synthesized dynamic #6#0 = x;
-    if(#6#0{dynamic}.<=(#C1)) {
+    if(#6#0{dynamic}.<=(#C1) as{ForNonNullableByDefault} core::bool) {
     }
   }
   {
     final synthesized dynamic #7#0 = x;
-    if(#7#0{dynamic}.>(#C1)) {
+    if(#7#0{dynamic}.>(#C1) as{ForNonNullableByDefault} core::bool) {
     }
   }
   {
     final synthesized dynamic #8#0 = x;
-    if(#8#0{dynamic}.>=(#C1)) {
+    if(#8#0{dynamic}.>=(#C1) as{ForNonNullableByDefault} core::bool) {
     }
   }
 }
diff --git a/pkg/front_end/testcases/patterns/relational_inside_if_case.dart.strong.transformed.expect b/pkg/front_end/testcases/patterns/relational_inside_if_case.dart.strong.transformed.expect
index d4b5370..8f938d2 100644
--- a/pkg/front_end/testcases/patterns/relational_inside_if_case.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/patterns/relational_inside_if_case.dart.strong.transformed.expect
@@ -30,22 +30,22 @@
   }
   {
     final synthesized dynamic #5#0 = x;
-    if(#5#0{dynamic}.<(#C1)) {
+    if(#5#0{dynamic}.<(#C1) as{ForNonNullableByDefault} core::bool) {
     }
   }
   {
     final synthesized dynamic #6#0 = x;
-    if(#6#0{dynamic}.<=(#C1)) {
+    if(#6#0{dynamic}.<=(#C1) as{ForNonNullableByDefault} core::bool) {
     }
   }
   {
     final synthesized dynamic #7#0 = x;
-    if(#7#0{dynamic}.>(#C1)) {
+    if(#7#0{dynamic}.>(#C1) as{ForNonNullableByDefault} core::bool) {
     }
   }
   {
     final synthesized dynamic #8#0 = x;
-    if(#8#0{dynamic}.>=(#C1)) {
+    if(#8#0{dynamic}.>=(#C1) as{ForNonNullableByDefault} core::bool) {
     }
   }
 }
diff --git a/pkg/front_end/testcases/patterns/relational_inside_if_case.dart.weak.expect b/pkg/front_end/testcases/patterns/relational_inside_if_case.dart.weak.expect
index d4b5370..8f938d2 100644
--- a/pkg/front_end/testcases/patterns/relational_inside_if_case.dart.weak.expect
+++ b/pkg/front_end/testcases/patterns/relational_inside_if_case.dart.weak.expect
@@ -30,22 +30,22 @@
   }
   {
     final synthesized dynamic #5#0 = x;
-    if(#5#0{dynamic}.<(#C1)) {
+    if(#5#0{dynamic}.<(#C1) as{ForNonNullableByDefault} core::bool) {
     }
   }
   {
     final synthesized dynamic #6#0 = x;
-    if(#6#0{dynamic}.<=(#C1)) {
+    if(#6#0{dynamic}.<=(#C1) as{ForNonNullableByDefault} core::bool) {
     }
   }
   {
     final synthesized dynamic #7#0 = x;
-    if(#7#0{dynamic}.>(#C1)) {
+    if(#7#0{dynamic}.>(#C1) as{ForNonNullableByDefault} core::bool) {
     }
   }
   {
     final synthesized dynamic #8#0 = x;
-    if(#8#0{dynamic}.>=(#C1)) {
+    if(#8#0{dynamic}.>=(#C1) as{ForNonNullableByDefault} core::bool) {
     }
   }
 }
diff --git a/pkg/front_end/testcases/patterns/relational_inside_if_case.dart.weak.modular.expect b/pkg/front_end/testcases/patterns/relational_inside_if_case.dart.weak.modular.expect
index d4b5370..8f938d2 100644
--- a/pkg/front_end/testcases/patterns/relational_inside_if_case.dart.weak.modular.expect
+++ b/pkg/front_end/testcases/patterns/relational_inside_if_case.dart.weak.modular.expect
@@ -30,22 +30,22 @@
   }
   {
     final synthesized dynamic #5#0 = x;
-    if(#5#0{dynamic}.<(#C1)) {
+    if(#5#0{dynamic}.<(#C1) as{ForNonNullableByDefault} core::bool) {
     }
   }
   {
     final synthesized dynamic #6#0 = x;
-    if(#6#0{dynamic}.<=(#C1)) {
+    if(#6#0{dynamic}.<=(#C1) as{ForNonNullableByDefault} core::bool) {
     }
   }
   {
     final synthesized dynamic #7#0 = x;
-    if(#7#0{dynamic}.>(#C1)) {
+    if(#7#0{dynamic}.>(#C1) as{ForNonNullableByDefault} core::bool) {
     }
   }
   {
     final synthesized dynamic #8#0 = x;
-    if(#8#0{dynamic}.>=(#C1)) {
+    if(#8#0{dynamic}.>=(#C1) as{ForNonNullableByDefault} core::bool) {
     }
   }
 }
diff --git a/pkg/front_end/testcases/patterns/relational_inside_if_case.dart.weak.transformed.expect b/pkg/front_end/testcases/patterns/relational_inside_if_case.dart.weak.transformed.expect
index d4b5370..8f938d2 100644
--- a/pkg/front_end/testcases/patterns/relational_inside_if_case.dart.weak.transformed.expect
+++ b/pkg/front_end/testcases/patterns/relational_inside_if_case.dart.weak.transformed.expect
@@ -30,22 +30,22 @@
   }
   {
     final synthesized dynamic #5#0 = x;
-    if(#5#0{dynamic}.<(#C1)) {
+    if(#5#0{dynamic}.<(#C1) as{ForNonNullableByDefault} core::bool) {
     }
   }
   {
     final synthesized dynamic #6#0 = x;
-    if(#6#0{dynamic}.<=(#C1)) {
+    if(#6#0{dynamic}.<=(#C1) as{ForNonNullableByDefault} core::bool) {
     }
   }
   {
     final synthesized dynamic #7#0 = x;
-    if(#7#0{dynamic}.>(#C1)) {
+    if(#7#0{dynamic}.>(#C1) as{ForNonNullableByDefault} core::bool) {
     }
   }
   {
     final synthesized dynamic #8#0 = x;
-    if(#8#0{dynamic}.>=(#C1)) {
+    if(#8#0{dynamic}.>=(#C1) as{ForNonNullableByDefault} core::bool) {
     }
   }
 }
diff --git a/pkg/front_end/testcases/strong.status b/pkg/front_end/testcases/strong.status
index e987dd7..3398df8 100644
--- a/pkg/front_end/testcases/strong.status
+++ b/pkg/front_end/testcases/strong.status
@@ -149,7 +149,6 @@
 nnbd/issue42603: TypeCheckError
 nnbd/no_support_for_old_null_aware_index_access_syntax: RuntimeError # Expected.
 no_such_method_forwarders/mixin_nsm: TypeCheckError
-patterns/pattern_types: TypeCheckError
 rasta/abstract_constructor: RuntimeError
 rasta/bad_constructor_redirection: RuntimeError
 rasta/bad_continue: RuntimeError
diff --git a/pkg/front_end/testcases/weak.status b/pkg/front_end/testcases/weak.status
index 329c378..097d101 100644
--- a/pkg/front_end/testcases/weak.status
+++ b/pkg/front_end/testcases/weak.status
@@ -230,7 +230,6 @@
 nnbd_mixed/messages_with_types_opt_in: TypeCheckError
 nnbd_mixed/messages_with_types_opt_out: TypeCheckError
 nnbd_mixed/mixin_from_opt_in/main: RuntimeError
-patterns/pattern_types: TypeCheckError
 rasta/abstract_constructor: RuntimeError
 rasta/bad_constructor_redirection: RuntimeError
 rasta/bad_continue: RuntimeError