Decorate void and dynamic

Change-Id: I41cc3ad700c6d338295edbb7c78ef5d2ad92c05d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/106721
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Dan Rubel <danrubel@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
This commit is contained in:
Brian Wilkerson 2019-06-19 18:51:06 +00:00 committed by commit-bot@chromium.org
parent 3c596e802b
commit 87460ad41a

View file

@ -47,19 +47,29 @@ class DecoratedType {
/// presumed to have come from code that is already migrated.
factory DecoratedType.forElement(Element element, NullabilityGraph graph) {
DecoratedType decorate(DartType type) {
if (type.isVoid || type.isDynamic) {
return DecoratedType(type, graph.always);
}
assert((type as TypeImpl).nullabilitySuffix ==
NullabilitySuffix.star); // TODO(paulberry)
if (type is FunctionType) {
var positionalParameters = <DecoratedType>[];
for (var parameter in type.parameters) {
assert(parameter.isPositional); // TODO(paulberry)
positionalParameters.add(decorate(parameter.type));
if (parameter.isPositional) {
positionalParameters.add(decorate(parameter.type));
} else {
// TODO(paulberry)
throw UnimplementedError('Decorating (${parameter.displayName})');
}
}
return DecoratedType(type, graph.never,
returnType: decorate(type.returnType),
positionalParameters: positionalParameters);
} else if (type is InterfaceType) {
assert(type.typeParameters.isEmpty); // TODO(paulberry)
if (type.typeParameters.isNotEmpty) {
// TODO(paulberry)
throw UnimplementedError('Decorating ${type.displayName}');
}
return DecoratedType(type, graph.never);
} else {
throw type.runtimeType; // TODO(paulberry)
@ -67,14 +77,11 @@ class DecoratedType {
}
DecoratedType decoratedType;
if (element is MethodElement) {
decoratedType = decorate(element.type);
} else if (element is PropertyAccessorElement) {
decoratedType = decorate(element.type);
} else if (element is ConstructorElement) {
if (element is ExecutableElement) {
decoratedType = decorate(element.type);
} else {
throw element.runtimeType; // TODO(paulberry)
// TODO(paulberry)
throw UnimplementedError('Decorating ${element.runtimeType}');
}
return decoratedType;
}