Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(318)

Unified Diff: pkg/analyzer/lib/src/generated/resolver.dart

Issue 1585323003: fix #25486, promote from dynamic in strong mode (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/type_system.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
}
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/type_system.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698