[cfe] Add experimental visitor mixins and experimental type

This CL reduces the noise of future CFE experiments in the
backends. Whenever new nodes will be added as an experiment, the
related exception-throwing implementations will be added to the
mixins, eliminating the need to add the visit methods to the backend
code directly. The experimental type addresses a similar issue in
exhaustive switch statements and expressions.

TEST=existing

Change-Id: I1a021e11a159a992500c42287cbe6ef027bf54a2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/455080
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
diff --git a/pkg/compiler/lib/src/ir/util.dart b/pkg/compiler/lib/src/ir/util.dart
index 4344b61..f3b76c1 100644
--- a/pkg/compiler/lib/src/ir/util.dart
+++ b/pkg/compiler/lib/src/ir/util.dart
@@ -140,7 +140,9 @@
   return null;
 }
 
-class _FreeVariableVisitor implements ir.DartTypeVisitor<bool> {
+class _FreeVariableVisitor
+    with ir.DartTypeVisitorExperimentExclusionMixin<bool>
+    implements ir.DartTypeVisitor<bool> {
   const _FreeVariableVisitor();
 
   bool visit(ir.DartType type) {
diff --git a/pkg/compiler/lib/src/ir/visitors.dart b/pkg/compiler/lib/src/ir/visitors.dart
index 76b51fe..1b1bd8d 100644
--- a/pkg/compiler/lib/src/ir/visitors.dart
+++ b/pkg/compiler/lib/src/ir/visitors.dart
@@ -43,7 +43,8 @@
 }
 
 /// Visitor that converts kernel dart types into [DartType].
-class DartTypeConverter extends ir.DartTypeVisitor<DartType> {
+class DartTypeConverter extends ir.DartTypeVisitor<DartType>
+    with ir.DartTypeVisitorExperimentExclusionMixin<DartType> {
   final IrToElementMap elementMap;
   final Map<ir.StructuralParameter, DartType> currentFunctionTypeParameters =
       <ir.StructuralParameter, DartType>{};
diff --git a/pkg/compiler/lib/src/serialization/helpers.dart b/pkg/compiler/lib/src/serialization/helpers.dart
index 21b81ac..502dc14 100644
--- a/pkg/compiler/lib/src/serialization/helpers.dart
+++ b/pkg/compiler/lib/src/serialization/helpers.dart
@@ -27,7 +27,12 @@
 enum _TypeParameterKind { cls, functionNode }
 
 class DartTypeNodeWriter
-    extends ir.DartTypeVisitor1<void, List<ir.StructuralParameter>> {
+    extends ir.DartTypeVisitor1<void, List<ir.StructuralParameter>>
+    with
+        ir.DartTypeVisitor1ExperimentExclusionMixin<
+          void,
+          List<ir.StructuralParameter>
+        > {
   final DataSinkWriter _sink;
 
   DartTypeNodeWriter(this._sink);
diff --git a/pkg/compiler/test/helpers/ir_types.dart b/pkg/compiler/test/helpers/ir_types.dart
index 46173a9..502f121 100644
--- a/pkg/compiler/test/helpers/ir_types.dart
+++ b/pkg/compiler/test/helpers/ir_types.dart
@@ -4,7 +4,9 @@
 
 import 'package:kernel/ast.dart' as ir;
 
-class TypeTextVisitor implements ir.DartTypeVisitor1<void, StringBuffer> {
+class TypeTextVisitor
+    with ir.DartTypeVisitor1ExperimentExclusionMixin<void, StringBuffer>
+    implements ir.DartTypeVisitor1<void, StringBuffer> {
   const TypeTextVisitor();
 
   @override
diff --git a/pkg/dart2bytecode/lib/generics.dart b/pkg/dart2bytecode/lib/generics.dart
index 0b20045..fdf131e 100644
--- a/pkg/dart2bytecode/lib/generics.dart
+++ b/pkg/dart2bytecode/lib/generics.dart
@@ -131,7 +131,9 @@
   return typeArgs.any((t) => t.accept(findTypeParams));
 }
 
-class FindFreeTypeParametersVisitor implements DartTypeVisitor<bool> {
+class FindFreeTypeParametersVisitor
+    with DartTypeVisitorExperimentExclusionMixin<bool>
+    implements DartTypeVisitor<bool> {
   Set<StructuralParameter>? _declaredTypeParameters;
 
   bool visit(DartType type) => type.accept(this);
diff --git a/pkg/dart2wasm/lib/code_generator.dart b/pkg/dart2wasm/lib/code_generator.dart
index 264286e..118a713 100644
--- a/pkg/dart2wasm/lib/code_generator.dart
+++ b/pkg/dart2wasm/lib/code_generator.dart
@@ -52,8 +52,15 @@
 /// produced type is not a subtype of the expected type.
 abstract class AstCodeGenerator
     extends ExpressionVisitor1<w.ValueType, w.ValueType>
-    with ExpressionVisitor1DefaultMixin<w.ValueType, w.ValueType>
-    implements InitializerVisitor<void>, StatementVisitor<void>, CodeGenerator {
+    with
+        ExpressionVisitor1DefaultMixin<w.ValueType, w.ValueType>,
+        ExpressionVisitor1ExperimentExclusionMixin<w.ValueType,
+            w.ValueType>,
+        StatementVisitorExperimentExclusionMixin<void>
+    implements
+        InitializerVisitor<void>,
+        StatementVisitor<void>,
+        CodeGenerator {
   final Translator translator;
   final w.FunctionType functionType;
   final Member enclosingMember;
diff --git a/pkg/dart2wasm/lib/constants.dart b/pkg/dart2wasm/lib/constants.dart
index 686352f..1e090d9 100644
--- a/pkg/dart2wasm/lib/constants.dart
+++ b/pkg/dart2wasm/lib/constants.dart
@@ -211,6 +211,8 @@
       TypedefType() => throw 'Unexpected DartType: $type',
       AuxiliaryType() => throw 'Unexpected DartType: $type',
       InvalidType() => throw 'Unexpected DartType: $type',
+      // ignore: unreachable_switch_case
+      ExperimentalType() => throw 'Unexpected DartType: $type',
     };
   }
 
diff --git a/pkg/dart2wasm/lib/translator.dart b/pkg/dart2wasm/lib/translator.dart
index 974d035..d39958f 100644
--- a/pkg/dart2wasm/lib/translator.dart
+++ b/pkg/dart2wasm/lib/translator.dart
@@ -680,6 +680,8 @@
       TypedefType() => throw 'unreachable, should be desugared by CFE',
       InvalidType() => throw 'unreachable, should be compile-time error',
       AuxiliaryType() => throw 'unreachable, unused by dart2wasm',
+      // ignore: unreachable_switch_case
+      ExperimentalType() => throw 'unreachable, experimental',
     })
         .withDeclaredNullability(nullability);
   }
diff --git a/pkg/dev_compiler/lib/src/kernel/compiler.dart b/pkg/dev_compiler/lib/src/kernel/compiler.dart
index 6205e24..e783c79 100644
--- a/pkg/dev_compiler/lib/src/kernel/compiler.dart
+++ b/pkg/dev_compiler/lib/src/kernel/compiler.dart
@@ -76,7 +76,10 @@
 }
 
 class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
-    with OnceConstantVisitorDefaultMixin<js_ast.Expression>
+    with
+        OnceConstantVisitorDefaultMixin<js_ast.Expression>,
+        StatementVisitorExperimentExclusionMixin<js_ast.Statement>,
+        ExpressionVisitorExperimentExclusionMixin<js_ast.Expression>
     implements
         StatementVisitor<js_ast.Statement>,
         ExpressionVisitor<js_ast.Expression>,
diff --git a/pkg/dev_compiler/lib/src/kernel/compiler_new.dart b/pkg/dev_compiler/lib/src/kernel/compiler_new.dart
index 7dd8c67..1eb64f3 100644
--- a/pkg/dev_compiler/lib/src/kernel/compiler_new.dart
+++ b/pkg/dev_compiler/lib/src/kernel/compiler_new.dart
@@ -272,7 +272,10 @@
 }
 
 class LibraryCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
-    with OnceConstantVisitorDefaultMixin<js_ast.Expression>
+    with
+        OnceConstantVisitorDefaultMixin<js_ast.Expression>,
+        StatementVisitorExperimentExclusionMixin<js_ast.Statement>,
+        ExpressionVisitorExperimentExclusionMixin<js_ast.Expression>
     implements
         StatementVisitor<js_ast.Statement>,
         ExpressionVisitor<js_ast.Expression> {
diff --git a/pkg/dev_compiler/lib/src/kernel/future_or_normalizer.dart b/pkg/dev_compiler/lib/src/kernel/future_or_normalizer.dart
index 9f64334..1dd7093 100644
--- a/pkg/dev_compiler/lib/src/kernel/future_or_normalizer.dart
+++ b/pkg/dev_compiler/lib/src/kernel/future_or_normalizer.dart
@@ -96,6 +96,9 @@
         throw UnsupportedError(
           '`ExtensionType`s must be erased before `FutureOr` normalization.',
         );
+      // ignore: unreachable_switch_case
+      case ExperimentalType():
+        throwUnsupportedExperimentalType(typeArgument);
       case AuxiliaryType():
         throwUnsupportedAuxiliaryType(typeArgument);
       case InvalidType():
diff --git a/pkg/dev_compiler/lib/src/kernel/js_typerep.dart b/pkg/dev_compiler/lib/src/kernel/js_typerep.dart
index 3a4e827..1ab8162 100644
--- a/pkg/dev_compiler/lib/src/kernel/js_typerep.dart
+++ b/pkg/dev_compiler/lib/src/kernel/js_typerep.dart
@@ -80,6 +80,9 @@
       case StructuralParameterType():
       case RecordType():
         return JSType.jsObject;
+      // ignore: unreachable_switch_case
+      case ExperimentalType():
+        throwUnsupportedExperimentalType(type);
       case AuxiliaryType():
         throwUnsupportedAuxiliaryType(type);
       case InvalidType():
diff --git a/pkg/dev_compiler/lib/src/kernel/kernel_helpers.dart b/pkg/dev_compiler/lib/src/kernel/kernel_helpers.dart
index 31db547..8c5d658 100644
--- a/pkg/dev_compiler/lib/src/kernel/kernel_helpers.dart
+++ b/pkg/dev_compiler/lib/src/kernel/kernel_helpers.dart
@@ -19,6 +19,11 @@
       'Unsupported auxiliary type $type (${type.runtimeType}).',
     );
 
+Never throwUnsupportedExperimentalType(ExperimentalType type) =>
+    throw UnsupportedError(
+      'Unsupported experimental type $type (${type.runtimeType}).',
+    );
+
 Constructor? unnamedConstructor(Class c) =>
     c.constructors.firstWhereOrNull((c) => c.name.text == '');
 
diff --git a/pkg/dev_compiler/lib/src/kernel/type_recipe_generator.dart b/pkg/dev_compiler/lib/src/kernel/type_recipe_generator.dart
index 5fac19b..27d3e56 100644
--- a/pkg/dev_compiler/lib/src/kernel/type_recipe_generator.dart
+++ b/pkg/dev_compiler/lib/src/kernel/type_recipe_generator.dart
@@ -263,7 +263,8 @@
 /// [TypeRecipeGenerator] and all interactions with it should be through that
 /// class. It contains state that needs to be correctly set before visiting a
 /// type to produce valid recipes in a given type environment context.
-class _TypeRecipeVisitor extends DartTypeVisitor<String> {
+class _TypeRecipeVisitor extends DartTypeVisitor<String>
+    with DartTypeVisitorExperimentExclusionMixin<String> {
   /// The type environment to evaluate recipes in.
   ///
   /// Part of the state that should be set before visiting a type.
diff --git a/pkg/dev_compiler/lib/src/kernel/type_table.dart b/pkg/dev_compiler/lib/src/kernel/type_table.dart
index 587738d..8f19817 100644
--- a/pkg/dev_compiler/lib/src/kernel/type_table.dart
+++ b/pkg/dev_compiler/lib/src/kernel/type_table.dart
@@ -41,6 +41,9 @@
         t.named.forEach((n) => find(n.type));
       case ExtensionType():
         find(t.extensionTypeErasure);
+      // ignore: unreachable_switch_case
+      case ExperimentalType():
+        throwUnsupportedExperimentalType(t);
       case AuxiliaryType():
         throwUnsupportedAuxiliaryType(t);
       case InvalidType():
@@ -121,6 +124,9 @@
       return 'Rec${nullability}Of$elements';
     case ExtensionType():
       return _typeString(type.extensionTypeErasure);
+    // ignore: unreachable_switch_case
+    case ExperimentalType():
+      throwUnsupportedExperimentalType(type);
     case AuxiliaryType():
       throwUnsupportedAuxiliaryType(type);
     case InvalidType():
diff --git a/pkg/front_end/lib/src/codes/type_labeler.dart b/pkg/front_end/lib/src/codes/type_labeler.dart
index 249bfbe..52c769f 100644
--- a/pkg/front_end/lib/src/codes/type_labeler.dart
+++ b/pkg/front_end/lib/src/codes/type_labeler.dart
@@ -32,7 +32,9 @@
 /// raw types with numeric markers in Dart comments (e.g. `/*1*/`) to
 /// distinguish different types with the same name. This is used in diagnostic
 /// messages to indicate the origins of types occurring in the message.
-class TypeLabeler implements DartTypeVisitor<void>, ConstantVisitor<void> {
+class TypeLabeler
+    with DartTypeVisitorExperimentExclusionMixin<void>
+    implements DartTypeVisitor<void>, ConstantVisitor<void> {
   final List<LabeledNode> names = <LabeledNode>[];
   final Map<String, List<LabeledNode>> nameMap = <String, List<LabeledNode>>{};
 
diff --git a/pkg/front_end/lib/src/kernel/constant_evaluator.dart b/pkg/front_end/lib/src/kernel/constant_evaluator.dart
index 4387667..f830233 100644
--- a/pkg/front_end/lib/src/kernel/constant_evaluator.dart
+++ b/pkg/front_end/lib/src/kernel/constant_evaluator.dart
@@ -2454,7 +2454,9 @@
   }
 }
 
-class ConstantEvaluator implements ExpressionVisitor<Constant> {
+class ConstantEvaluator
+    with ExpressionVisitorExperimentExclusionMixin<Constant>
+    implements ExpressionVisitor<Constant> {
   final DartLibrarySupport dartLibrarySupport;
   final ConstantsBackend backend;
   final NumberSemantics numberSemantics;
@@ -5930,7 +5932,9 @@
   }
 }
 
-class StatementConstantEvaluator implements StatementVisitor<ExecutionStatus> {
+class StatementConstantEvaluator
+    with StatementVisitorExperimentExclusionMixin<ExecutionStatus>
+    implements StatementVisitor<ExecutionStatus> {
   ConstantEvaluator exprEvaluator;
 
   StatementConstantEvaluator(this.exprEvaluator);
diff --git a/pkg/front_end/lib/src/kernel/exhaustiveness.dart b/pkg/front_end/lib/src/kernel/exhaustiveness.dart
index 29d74f0..b846e1f 100644
--- a/pkg/front_end/lib/src/kernel/exhaustiveness.dart
+++ b/pkg/front_end/lib/src/kernel/exhaustiveness.dart
@@ -869,7 +869,9 @@
   return type.accept1(const ExhaustiveDartTypeVisitor(), coreTypes);
 }
 
-class ExhaustiveDartTypeVisitor implements DartTypeVisitor1<bool, CoreTypes> {
+class ExhaustiveDartTypeVisitor
+    with DartTypeVisitor1ExperimentExclusionMixin<bool, CoreTypes>
+    implements DartTypeVisitor1<bool, CoreTypes> {
   const ExhaustiveDartTypeVisitor();
 
   @override
diff --git a/pkg/front_end/lib/src/kernel/invalid_type.dart b/pkg/front_end/lib/src/kernel/invalid_type.dart
index 0d7a116..edb329f 100644
--- a/pkg/front_end/lib/src/kernel/invalid_type.dart
+++ b/pkg/front_end/lib/src/kernel/invalid_type.dart
@@ -17,7 +17,9 @@
   return type.accept1(const _InvalidTypeFinder(), <TypedefType>{});
 }
 
-class _InvalidTypeFinder implements DartTypeVisitor1<bool, Set<TypedefType>> {
+class _InvalidTypeFinder
+    with DartTypeVisitor1ExperimentExclusionMixin<bool, Set<TypedefType>>
+    implements DartTypeVisitor1<bool, Set<TypedefType>> {
   const _InvalidTypeFinder();
 
   @override
diff --git a/pkg/front_end/lib/src/kernel/type_builder_computer.dart b/pkg/front_end/lib/src/kernel/type_builder_computer.dart
index 8f2b527..4a5e106 100644
--- a/pkg/front_end/lib/src/kernel/type_builder_computer.dart
+++ b/pkg/front_end/lib/src/kernel/type_builder_computer.dart
@@ -34,6 +34,11 @@
 }
 
 class _TypeBuilderComputerHelper
+    with
+        DartTypeVisitor1ExperimentExclusionMixin<
+          TypeBuilder,
+          Map<TypeParameter, DillNominalParameterBuilder>
+        >
     implements
         DartTypeVisitor1<
           TypeBuilder,
diff --git a/pkg/front_end/lib/src/testing/id_testing_utils.dart b/pkg/front_end/lib/src/testing/id_testing_utils.dart
index 939bcc8..0726971 100644
--- a/pkg/front_end/lib/src/testing/id_testing_utils.dart
+++ b/pkg/front_end/lib/src/testing/id_testing_utils.dart
@@ -711,7 +711,9 @@
   }
 }
 
-class DartTypeToTextVisitor implements DartTypeVisitor<void> {
+class DartTypeToTextVisitor
+    with DartTypeVisitorExperimentExclusionMixin<void>
+    implements DartTypeVisitor<void> {
   final StringBuffer sb;
   final TypeRepresentation typeRepresentation;
 
diff --git a/pkg/front_end/lib/src/type_inference/inference_visitor.dart b/pkg/front_end/lib/src/type_inference/inference_visitor.dart
index 2b900e5..a7a1255 100644
--- a/pkg/front_end/lib/src/type_inference/inference_visitor.dart
+++ b/pkg/front_end/lib/src/type_inference/inference_visitor.dart
@@ -119,7 +119,12 @@
           VariableDeclaration,
           SharedTypeView
         >,
-        StackChecker
+        StackChecker,
+        ExpressionVisitor1ExperimentExclusionMixin<
+          ExpressionInferenceResult,
+          DartType
+        >,
+        StatementVisitorExperimentExclusionMixin<StatementInferenceResult>
     implements
         ExpressionVisitor1<ExpressionInferenceResult, DartType>,
         StatementVisitor<StatementInferenceResult>,
diff --git a/pkg/front_end/lib/src/type_inference/type_inference_engine.dart b/pkg/front_end/lib/src/type_inference/type_inference_engine.dart
index 20e9522..09e582f 100644
--- a/pkg/front_end/lib/src/type_inference/type_inference_engine.dart
+++ b/pkg/front_end/lib/src/type_inference/type_inference_engine.dart
@@ -35,7 +35,9 @@
 
 /// Visitor to check whether a given type mentions any of a class's type
 /// parameters in a non-covariant fashion.
-class IncludesTypeParametersNonCovariantly implements DartTypeVisitor<bool> {
+class IncludesTypeParametersNonCovariantly
+    with DartTypeVisitorExperimentExclusionMixin<bool>
+    implements DartTypeVisitor<bool> {
   Variance _variance;
 
   final List<TypeParameter> _typeParametersToSearchFor;
diff --git a/pkg/front_end/test/spell_checking_list_common.txt b/pkg/front_end/test/spell_checking_list_common.txt
index cc5cdd5..d049d4e 100644
--- a/pkg/front_end/test/spell_checking_list_common.txt
+++ b/pkg/front_end/test/spell_checking_list_common.txt
@@ -102,6 +102,7 @@
 aliased
 aliases
 alignment
+alike
 all
 allocated
 allocating
@@ -1138,6 +1139,7 @@
 excluded
 excludes
 excluding
+exclusion
 exclusive
 executable
 executed
diff --git a/pkg/front_end/tool/bench_maker.dart b/pkg/front_end/tool/bench_maker.dart
index 634029c..b668787 100644
--- a/pkg/front_end/tool/bench_maker.dart
+++ b/pkg/front_end/tool/bench_maker.dart
@@ -28,7 +28,9 @@
   }
 }
 
-class BenchMaker implements DartTypeVisitor1<void, StringBuffer> {
+class BenchMaker
+    with DartTypeVisitor1ExperimentExclusionMixin<void, StringBuffer>
+    implements DartTypeVisitor1<void, StringBuffer> {
   final List<Object> checks = <Object>[];
 
   final Map<TreeNode, String> nodeNames = <TreeNode, String>{};
diff --git a/pkg/kernel/lib/binary/ast_to_binary.dart b/pkg/kernel/lib/binary/ast_to_binary.dart
index 15eabe6..c1afc99 100644
--- a/pkg/kernel/lib/binary/ast_to_binary.dart
+++ b/pkg/kernel/lib/binary/ast_to_binary.dart
@@ -15,7 +15,13 @@
 ///
 /// A [BinaryPrinter] can be used to write one file and must then be
 /// discarded.
-class BinaryPrinter implements Visitor<void>, BinarySink {
+class BinaryPrinter
+    with
+        TreeVisitorExperimentExclusionMixin<void>,
+        DartTypeVisitorExperimentExclusionMixin<void>,
+        StatementVisitorExperimentExclusionMixin<void>,
+        ExpressionVisitorExperimentExclusionMixin<void>
+    implements Visitor<void>, BinarySink {
   final VariableIndexer Function() _newVariableIndexer;
   VariableIndexer? _variableIndexer;
   LabelIndexer? _labelIndexer;
diff --git a/pkg/kernel/lib/clone.dart b/pkg/kernel/lib/clone.dart
index c4aaf24..e7adb0c 100644
--- a/pkg/kernel/lib/clone.dart
+++ b/pkg/kernel/lib/clone.dart
@@ -12,7 +12,12 @@
 ///
 /// This class does not clone members. For that, use the
 /// [CloneVisitorWithMembers] and setup references properly.
-class CloneVisitorNotMembers implements TreeVisitor<TreeNode> {
+class CloneVisitorNotMembers
+    with
+        TreeVisitorExperimentExclusionMixin<TreeNode>,
+        ExpressionVisitorExperimentExclusionMixin<TreeNode>,
+        StatementVisitorExperimentExclusionMixin<TreeNode>
+    implements TreeVisitor<TreeNode> {
   final Map<VariableDeclaration, VariableDeclaration> _variables =
       <VariableDeclaration, VariableDeclaration>{};
   final Map<LabeledStatement, LabeledStatement> labels =
diff --git a/pkg/kernel/lib/src/ast/types.dart b/pkg/kernel/lib/src/ast/types.dart
index 60850e7..189f31b 100644
--- a/pkg/kernel/lib/src/ast/types.dart
+++ b/pkg/kernel/lib/src/ast/types.dart
@@ -619,6 +619,26 @@
       v.visitAuxiliaryType(this, arg);
 }
 
+/// The root of the sealed sub-hierarchy for all experimental [DartType]s.
+///
+/// The purpose of [ExperimentalType] is to be a stand-in in exhaustive switch
+/// statements and alike in the backend code. That way, the backends won't need
+/// an update whenever an experimental type (a subclass of [ExperimentalType])
+/// is added or removed in the CFE.
+sealed class ExperimentalType extends DartType {
+  const ExperimentalType();
+
+  @override
+  R accept<R>(DartTypeVisitor<R> v) {
+    throw new UnsupportedError("`ExperimentalType.accept` is unsupported.");
+  }
+
+  @override
+  R accept1<R, A>(DartTypeVisitor1<R, A> v, A arg) {
+    throw new UnsupportedError("`ExperimentalType.accept1` is unsupported.");
+  }
+}
+
 /// The type arising from invalid type annotations.
 ///
 /// Can usually be treated as 'dynamic', but should occasionally be handled
diff --git a/pkg/kernel/lib/visitor.dart b/pkg/kernel/lib/visitor.dart
index a6ee7c1..d5cccf3 100644
--- a/pkg/kernel/lib/visitor.dart
+++ b/pkg/kernel/lib/visitor.dart
@@ -2602,3 +2602,74 @@
   R visitFunctionDeclaration(FunctionDeclaration node, A arg) =>
       defaultStatement(node, arg);
 }
+
+/// [DartTypeVisitorExperimentExclusionMixin] is intended to reduce the effects
+/// of CFE experiments on the backends.
+///
+/// The mixin provides implementations of the visit methods for the experimental
+/// nodes. The methods throw an exception signaling that the experimental nodes
+/// aren't supported.
+mixin DartTypeVisitorExperimentExclusionMixin<R>
+    implements DartTypeVisitor<R> {}
+
+/// [DartTypeVisitor1ExperimentExclusionMixin] is intended to reduce the effects
+/// of CFE experiments on the backends.
+///
+/// The mixin provides implementations of the visit methods for the experimental
+/// nodes. The methods throw an exception signaling that the experimental nodes
+/// aren't supported.
+mixin DartTypeVisitor1ExperimentExclusionMixin<R, A>
+    implements DartTypeVisitor1<R, A> {}
+
+/// [ExpressionVisitorExperimentExclusionMixin] is intended to reduce the
+/// effects of CFE experiments on the backends.
+///
+/// The mixin provides implementations of the visit methods for the experimental
+/// nodes. The methods throw an exception signaling that the experimental nodes
+/// aren't supported.
+mixin ExpressionVisitorExperimentExclusionMixin<R>
+    implements ExpressionVisitor<R> {}
+
+/// [ExpressionVisitor1ExperimentExclusionMixin] is intended to reduce the
+/// effects of CFE experiments on the backends.
+///
+/// The mixin provides implementations of the visit methods for the experimental
+/// nodes. The methods throw an exception signaling that the experimental nodes
+/// aren't supported.
+mixin ExpressionVisitor1ExperimentExclusionMixin<R, A>
+    implements ExpressionVisitor1<R, A> {}
+
+/// [StatementVisitorExperimentExclusionMixin] is intended to reduce the effects
+/// of CFE experiments on the backends.
+///
+/// The mixin provides implementations of the visit methods for the experimental
+/// nodes. The methods throw an exception signaling that the experimental nodes
+/// aren't supported.
+mixin StatementVisitorExperimentExclusionMixin<R>
+    implements StatementVisitor<R> {}
+
+/// [StatementVisitor1ExperimentExclusionMixin] is intended to reduce the
+/// effects of CFE experiments on the backends.
+///
+/// The mixin provides implementations of the visit methods for the experimental
+/// nodes. The methods throw an exception signaling that the experimental nodes
+/// aren't supported.
+mixin StatementVisitor1ExperimentExclusionMixin<R, A>
+    implements StatementVisitor1<R, A> {}
+
+/// [TreeVisitorExperimentExclusionMixin] is intended to reduce the effects of
+/// CFE experiments on the backends.
+///
+/// The mixin provides implementations of the visit methods for the experimental
+/// nodes. The methods throw an exception signaling that the experimental nodes
+/// aren't supported.
+mixin TreeVisitorExperimentExclusionMixin<R> implements TreeVisitor<R> {}
+
+/// [TreeVisitor1ExperimentExclusionMixin] is intended to reduce the effects of
+/// CFE experiments on the backends.
+///
+/// The mixin provides implementations of the visit methods for the experimental
+/// nodes. The methods throw an exception signaling that the experimental nodes
+/// aren't supported.
+mixin TreeVisitor1ExperimentExclusionMixin<R, A>
+    implements TreeVisitor1<R, A> {}
diff --git a/pkg/vm/lib/transformations/type_flow/summary_collector.dart b/pkg/vm/lib/transformations/type_flow/summary_collector.dart
index f1e05c7..a0c4a2e 100644
--- a/pkg/vm/lib/transformations/type_flow/summary_collector.dart
+++ b/pkg/vm/lib/transformations/type_flow/summary_collector.dart
@@ -2896,6 +2896,7 @@
 }
 
 class RuntimeTypeTranslatorImpl
+    with DartTypeVisitorExperimentExclusionMixin<TypeExpr>
     implements RuntimeTypeTranslator, DartTypeVisitor<TypeExpr> {
   final CoreTypes coreTypes;
   final Summary? summary;