[dart2js] Fix `impliedClasses` logic during RTI resolution.
This code was inadvertently falling through to the `throw` if `VoidType`
was encountered (although this case currently never happens). In
addition, we were missing cases for some of the newer `DartType`s.
This CL fixes those cases and removes Object from the classes implied by
`DynamicType`.
Change-Id: Ibfecd92c0113d11eb8870d511d60cbc34ac1bfa0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159020
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
diff --git a/pkg/compiler/lib/src/js_backend/runtime_types_resolution.dart b/pkg/compiler/lib/src/js_backend/runtime_types_resolution.dart
index 086d55aa..7afc77e 100644
--- a/pkg/compiler/lib/src/js_backend/runtime_types_resolution.dart
+++ b/pkg/compiler/lib/src/js_backend/runtime_types_resolution.dart
@@ -1201,18 +1201,23 @@
type = type.withoutNullability;
if (type is InterfaceType) {
return [type.element];
- } else if (type is DynamicType) {
- return [commonElements.objectClass];
+ } else if (type is NeverType ||
+ type is DynamicType ||
+ type is VoidType ||
+ type is AnyType ||
+ type is ErasedType) {
+ // No classes implied.
+ return const [];
} else if (type is FunctionType) {
// TODO(johnniwinther): Include only potential function type subtypes.
return [commonElements.functionClass];
- } else if (type is VoidType) {
- // No classes implied.
} else if (type is FunctionTypeVariable) {
return impliedClasses(type.bound);
} else if (type is FutureOrType) {
- return [commonElements.futureClass]
- ..addAll(impliedClasses(type.typeArgument));
+ return [
+ commonElements.futureClass,
+ ...impliedClasses(type.typeArgument),
+ ];
} else if (type is TypeVariableType) {
// TODO(johnniwinther): Can we do better?
return impliedClasses(