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

Unified Diff: pkg/analyzer/lib/src/task/strong/rules.dart

Issue 1462133005: Downwards inference. This adds support to the resolver for downwards (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Minor fixes Created 5 years, 1 month 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
Index: pkg/analyzer/lib/src/task/strong/rules.dart
diff --git a/pkg/analyzer/lib/src/task/strong/rules.dart b/pkg/analyzer/lib/src/task/strong/rules.dart
index 32236a8aaee630c3d0584190def357676a92d62e..6503c22cdac75484430ffdea653a371f5f211a08 100644
--- a/pkg/analyzer/lib/src/task/strong/rules.dart
+++ b/pkg/analyzer/lib/src/task/strong/rules.dart
@@ -421,6 +421,7 @@ class TypeRules {
var reason = null;
var errors = <String>[];
+
var ok = inferrer.inferExpression(expr, toT, errors);
if (ok) return InferredType.create(this, expr, toT);
reason = (errors.isNotEmpty) ? errors.first : null;
@@ -508,24 +509,11 @@ class DownwardsInference {
/// Downward inference
bool _inferExpression(Expression e, DartType t, List<String> errors,
{cast: true}) {
- if (e is ConditionalExpression) {
- return _inferConditionalExpression(e, t, errors);
- }
- if (e is ParenthesizedExpression) {
- return _inferParenthesizedExpression(e, t, errors);
- }
if (rules.isSubTypeOf(rules.getStaticType(e), t)) return true;
if (cast && rules.getStaticType(e).isDynamic) {
annotateCastFromDynamic(e, t);
return true;
}
- if (e is FunctionExpression) return _inferFunctionExpression(e, t, errors);
- if (e is ListLiteral) return _inferListLiteral(e, t, errors);
- if (e is MapLiteral) return _inferMapLiteral(e, t, errors);
- if (e is NamedExpression) return _inferNamedExpression(e, t, errors);
- if (e is InstanceCreationExpression) {
- return _inferInstanceCreationExpression(e, t, errors);
- }
errors.add("$e cannot be typed as $t");
return false;
}

Powered by Google App Engine
This is Rietveld 408576698