[dart2wasm] Fix some missed conversions on `_TypedData` getters.

Change-Id: Ib246388aa0b48dff2ebf4704633b7ffc79b1b40a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250560
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
diff --git a/pkg/dart2wasm/lib/intrinsics.dart b/pkg/dart2wasm/lib/intrinsics.dart
index 7971b28..68f9aeb 100644
--- a/pkg/dart2wasm/lib/intrinsics.dart
+++ b/pkg/dart2wasm/lib/intrinsics.dart
@@ -1250,6 +1250,11 @@
         ClassInfo info = translator.classInfo[cls]!;
         b.local_get(paramLocals[0]);
         translator.ref_cast(b, info);
+        // TODO(joshualitt): Because we currently merge getters to support
+        // dynamic calls, the return types of `.length` and `.offsetInBytes` can
+        // change. Should we decide to stop merging getters, we should remove
+        // the conversions below.
+        w.ValueType outputType = function.type.outputs.single;
         switch (name) {
           case "length":
             assert(cls == translator.typedListBaseClass ||
@@ -1260,6 +1265,7 @@
               b.struct_get(info.struct, FieldIndex.byteDataViewLength);
             }
             b.i64_extend_i32_u();
+            translator.convertType(function, intType, outputType);
             return true;
           case "offsetInBytes":
             assert(cls == translator.typedListViewClass ||
@@ -1270,6 +1276,7 @@
               b.struct_get(info.struct, FieldIndex.byteDataViewOffsetInBytes);
             }
             b.i64_extend_i32_u();
+            translator.convertType(function, intType, outputType);
             return true;
           case "_typedData":
             assert(cls == translator.typedListViewClass ||