[ddc] Avoid calling addTypeCaches with new types

Some preparation for deleting all the old type system code.

Change-Id: I9319064100ce19a4122612c36781c7e4a71094aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352724
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
diff --git a/pkg/dev_compiler/lib/src/kernel/compiler.dart b/pkg/dev_compiler/lib/src/kernel/compiler.dart
index d55ec1b..80bcac5 100644
--- a/pkg/dev_compiler/lib/src/kernel/compiler.dart
+++ b/pkg/dev_compiler/lib/src/kernel/compiler.dart
@@ -985,8 +985,9 @@
       ];
       body.add(runtimeStatement('addRtiResources(#, #)',
           [className, js_ast.stringArray(implementedRecipes)]));
+    } else {
+      body.add(runtimeStatement('addTypeCaches(#)', [className]));
     }
-    body.add(runtimeStatement('addTypeCaches(#)', [className]));
 
     _emitClassSignature(c, className, body);
     _initExtensionSymbols(c);
diff --git a/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/classes.dart b/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/classes.dart
index 5ac53d2..f593b76 100644
--- a/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/classes.dart
+++ b/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/classes.dart
@@ -710,6 +710,8 @@
 /// The first element of [interfaceRecipes] must always be the type recipe for
 /// the type represented by [classRef].
 void addRtiResources(Object classRef, JSArray<String> interfaceRecipes) {
+  // Create a rti object cache property used in dart:_rti.
+  JS('', '#[#] = null', classRef, rti.constructorRtiCachePropertyName);
   // Attach the [classRef]'s own interface type recipe.
   // The recipe is used in dart:_rti to create an [rti.Rti] instance when
   // needed.
@@ -731,8 +733,7 @@
 /// monomorphic, which results in faster execution in V8.
 addTypeCaches(type) {
   if (JS_GET_FLAG('NEW_RUNTIME_TYPES')) {
-    // Create a rti object cache property used in dart:_rti.
-    JS('', '#[#] = null', type, rti.constructorRtiCachePropertyName);
+    throwUnimplementedInCurrentRti();
   } else {
     JS('', '#[#] = void 0', type, _cachedLegacy);
     JS('', '#[#] = void 0', type, _cachedNullable);