Skip to content

Commit 87460ad

Browse files
bwilkersoncommit-bot@chromium.org
authored andcommitted
Decorate void and dynamic
Change-Id: I41cc3ad700c6d338295edbb7c78ef5d2ad92c05d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/106721 Commit-Queue: Brian Wilkerson <[email protected]> Reviewed-by: Dan Rubel <[email protected]> Reviewed-by: Paul Berry <[email protected]>
1 parent 3c596e8 commit 87460ad

1 file changed

Lines changed: 16 additions & 9 deletions

File tree

pkg/nnbd_migration/lib/src/decorated_type.dart

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,34 +47,41 @@ class DecoratedType {
4747
/// presumed to have come from code that is already migrated.
4848
factory DecoratedType.forElement(Element element, NullabilityGraph graph) {
4949
DecoratedType decorate(DartType type) {
50+
if (type.isVoid || type.isDynamic) {
51+
return DecoratedType(type, graph.always);
52+
}
5053
assert((type as TypeImpl).nullabilitySuffix ==
5154
NullabilitySuffix.star); // TODO(paulberry)
5255
if (type is FunctionType) {
5356
var positionalParameters = <DecoratedType>[];
5457
for (var parameter in type.parameters) {
55-
assert(parameter.isPositional); // TODO(paulberry)
56-
positionalParameters.add(decorate(parameter.type));
58+
if (parameter.isPositional) {
59+
positionalParameters.add(decorate(parameter.type));
60+
} else {
61+
// TODO(paulberry)
62+
throw UnimplementedError('Decorating (${parameter.displayName})');
63+
}
5764
}
5865
return DecoratedType(type, graph.never,
5966
returnType: decorate(type.returnType),
6067
positionalParameters: positionalParameters);
6168
} else if (type is InterfaceType) {
62-
assert(type.typeParameters.isEmpty); // TODO(paulberry)
69+
if (type.typeParameters.isNotEmpty) {
70+
// TODO(paulberry)
71+
throw UnimplementedError('Decorating ${type.displayName}');
72+
}
6373
return DecoratedType(type, graph.never);
6474
} else {
6575
throw type.runtimeType; // TODO(paulberry)
6676
}
6777
}
6878

6979
DecoratedType decoratedType;
70-
if (element is MethodElement) {
71-
decoratedType = decorate(element.type);
72-
} else if (element is PropertyAccessorElement) {
73-
decoratedType = decorate(element.type);
74-
} else if (element is ConstructorElement) {
80+
if (element is ExecutableElement) {
7581
decoratedType = decorate(element.type);
7682
} else {
77-
throw element.runtimeType; // TODO(paulberry)
83+
// TODO(paulberry)
84+
throw UnimplementedError('Decorating ${element.runtimeType}');
7885
}
7986
return decoratedType;
8087
}

0 commit comments

Comments
 (0)