[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>
This commit is contained in:
Mayank Patke 2020-08-18 23:20:00 +00:00 committed by commit-bot@chromium.org
parent 4c3ae7bca6
commit 1cec77f0a6

View file

@ -1201,18 +1201,23 @@ class RuntimeTypesNeedBuilderImpl implements RuntimeTypesNeedBuilder {
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(