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

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

Issue 1823793002: Better casting of for-in loops. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Handle supertypes of Iterable and Stream. Created 4 years, 9 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
Index: pkg/analyzer/lib/src/task/strong/info.dart
diff --git a/pkg/analyzer/lib/src/task/strong/info.dart b/pkg/analyzer/lib/src/task/strong/info.dart
index 2aaa4c69421cbc249a32562fc44bf2ee42f50b85..b8f09eaae92aba0ea445f2f5e84ca93e58be5120 100644
--- a/pkg/analyzer/lib/src/task/strong/info.dart
+++ b/pkg/analyzer/lib/src/task/strong/info.dart
@@ -67,24 +67,24 @@ abstract class DownCast extends CoercionInfo {
DownCast._internal(
TypeSystem rules, Expression expression, this._fromType, this._toType)
- : super(rules, expression) {
- assert(_toType != baseType &&
- _fromType == baseType &&
- (baseType.isDynamic ||
- // Call methods make the following non-redundant.
- _toType.isSubtypeOf(baseType) ||
- baseType.isAssignableTo(_toType)));
- }
+ : super(rules, expression);
@override
List<Object> get arguments => [baseType, convertedType];
+ /// The type being cast from.
+ ///
+ /// This is usually the static type of the associated expression, but may not
+ /// be if the cast is attached to a variable in a for-in loop.
+ @override
+ DartType get baseType => _fromType;
+
DartType get convertedType => _toType;
@override
String get message => 'Unsound implicit cast from {0} to {1}';
- // Factory to create correct DownCast variant.
+ /// Factory to create correct DownCast variant.
static StaticInfo create(StrongTypeSystemImpl rules, Expression expression,
DartType fromType, DartType toType) {
// toT <:_R fromT => to <: fromT
« no previous file with comments | « pkg/analyzer/lib/src/task/strong/checker.dart ('k') | pkg/analyzer/test/generated/static_type_warning_code_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698