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

Side by Side Diff: pkg/analyzer/lib/src/task/strong/info.dart

Issue 1627503002: remove obsolete UninferredClosure type (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 unified diff | Download patch
« no previous file with comments | « no previous file | pkg/analyzer/test/src/task/strong/checker_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /// Defines static information collected by the type checker and used later by 5 /// Defines static information collected by the type checker and used later by
6 /// emitters to generate code. 6 /// emitters to generate code.
7 // TODO(jmesserly): this was ported from package:dev_compiler, and needs to be 7 // TODO(jmesserly): this was ported from package:dev_compiler, and needs to be
8 // refactored to fit into analyzer. 8 // refactored to fit into analyzer.
9 library analyzer.src.task.strong.info; 9 library analyzer.src.task.strong.info;
10 10
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 // types, but the function type is not assignable to the class 117 // types, but the function type is not assignable to the class
118 assert(toT.isSubtypeOf(fromT) || fromT.isAssignableTo(toT)); 118 assert(toT.isSubtypeOf(fromT) || fromT.isAssignableTo(toT));
119 119
120 // Handle null call specially. 120 // Handle null call specially.
121 if (expression is NullLiteral) { 121 if (expression is NullLiteral) {
122 // TODO(vsm): Create a NullCast for this once we revisit nonnullability. 122 // TODO(vsm): Create a NullCast for this once we revisit nonnullability.
123 return new DownCastImplicit(rules, expression, cast); 123 return new DownCastImplicit(rules, expression, cast);
124 } 124 }
125 125
126 // Inference "casts": 126 // Inference "casts":
127 if (expression is Literal) { 127 if (expression is Literal || expression is FunctionExpression) {
128 // fromT should be an exact type - this will almost certainly fail at 128 // fromT should be an exact type - this will almost certainly fail at
129 // runtime. 129 // runtime.
130 return new StaticTypeError(rules, expression, toT, reason: reason); 130 return new StaticTypeError(rules, expression, toT, reason: reason);
131 } 131 }
132 if (expression is FunctionExpression) {
133 // fromT should be an exact type - this will almost certainly fail at
134 // runtime.
135 return new UninferredClosure(rules, expression, cast);
136 }
137 if (expression is InstanceCreationExpression) { 132 if (expression is InstanceCreationExpression) {
138 ConstructorElement e = expression.staticElement; 133 ConstructorElement e = expression.staticElement;
139 if (e == null || !e.isFactory) { 134 if (e == null || !e.isFactory) {
140 // fromT should be an exact type - this will almost certainly fail at 135 // fromT should be an exact type - this will almost certainly fail at
141 // runtime. 136 // runtime.
142 return new StaticTypeError(rules, expression, toT, reason: reason); 137 return new StaticTypeError(rules, expression, toT, reason: reason);
143 } 138 }
144 } 139 }
145 140
146 // TODO(vsm): Change this to an assert when we have generic methods and 141 // TODO(vsm): Change this to an assert when we have generic methods and
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 @override 553 @override
559 List<Object> get arguments => [node, baseType, expectedType]; 554 List<Object> get arguments => [node, baseType, expectedType];
560 @override 555 @override
561 String get message => 556 String get message =>
562 'Type check failed: {0} ({1}) is not of type {2}' + 557 'Type check failed: {0} ({1}) is not of type {2}' +
563 ((reason == null) ? '' : ' because $reason'); 558 ((reason == null) ? '' : ' because $reason');
564 559
565 @override 560 @override
566 String get name => 'STRONG_MODE_STATIC_TYPE_ERROR'; 561 String get name => 'STRONG_MODE_STATIC_TYPE_ERROR';
567 } 562 }
568
569 //
570 // Temporary "casts" of allocation sites - literals, constructor invocations,
571 // and closures. These should be handled by contextual inference. In most
572 // cases, inference will be sufficient, though in some it may unmask an actual
573 // error: e.g.,
574 // List<int> l = [1, 2, 3]; // Inference succeeds
575 // List<String> l = [1, 2, 3]; // Inference reveals static type error
576 // We're marking all as warnings for now.
577 //
578 // TODO(vsm,leafp): Remove this.
579 class UninferredClosure extends DownCast {
580 UninferredClosure(TypeSystem rules, FunctionExpression expression, Cast cast)
581 : super._internal(rules, expression, cast);
582
583 @override
584 String get name => 'STRONG_MODE_UNINFERRED_CLOSURE';
585
586 toErrorCode() => new StaticTypeWarningCode(name, message);
587 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/src/task/strong/checker_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698