| Index: pkg/analyzer/lib/src/generated/resolver.dart
|
| diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
|
| index ef63fdb523be9417b5d78b5569c48e026ef4154e..d55cec2f41eaa5fcdae8158a369cf7808f5a3652 100644
|
| --- a/pkg/analyzer/lib/src/generated/resolver.dart
|
| +++ b/pkg/analyzer/lib/src/generated/resolver.dart
|
| @@ -9723,24 +9723,17 @@ class ResolverVisitor extends ScopedVisitor {
|
| return;
|
| }
|
| // prepare current variable type
|
| - DartType type = _promoteManager.getType(element);
|
| - if (type == null) {
|
| - type = expression.staticType;
|
| - }
|
| - // Declared type should not be "dynamic".
|
| - if (type == null || type.isDynamic) {
|
| - return;
|
| - }
|
| - // Promoted type should not be "dynamic".
|
| - if (potentialType == null || potentialType.isDynamic) {
|
| - return;
|
| - }
|
| - // Promoted type should be more specific than declared.
|
| - if (!potentialType.isMoreSpecificThan(type)) {
|
| - return;
|
| + DartType type = _promoteManager.getType(element) ??
|
| + expression.staticType ??
|
| + DynamicTypeImpl.instance;
|
| +
|
| + potentialType ??= DynamicTypeImpl.instance;
|
| +
|
| + // Check if we can promote to potentialType from type.
|
| + if (typeSystem.canPromoteToType(potentialType, type)) {
|
| + // Do promote type of variable.
|
| + _promoteManager.setType(element, potentialType);
|
| }
|
| - // Do promote type of variable.
|
| - _promoteManager.setType(element, potentialType);
|
| }
|
| }
|
|
|
|
|