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

Unified Diff: pkg/analyzer/lib/src/generated/error_verifier.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
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/task/strong/checker.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/error_verifier.dart
diff --git a/pkg/analyzer/lib/src/generated/error_verifier.dart b/pkg/analyzer/lib/src/generated/error_verifier.dart
index efd0f9365e26ac40b9008164b1c7000bef503189..28d02ec10a1ef67e12193db4bc039cffb3dc0b16 100644
--- a/pkg/analyzer/lib/src/generated/error_verifier.dart
+++ b/pkg/analyzer/lib/src/generated/error_verifier.dart
@@ -5694,6 +5694,15 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
iterableType = iterableType.resolveToBound(_typeProvider.objectType);
DartType bestIterableType =
_typeSystem.mostSpecificTypeArgument(iterableType, loopType);
+
+ // Allow it to be a supertype of Iterable<T> (basically just Object) and do
+ // an implicit downcast to Iterable<dynamic>.
+ if (bestIterableType == null) {
+ if (_typeSystem.isSubtypeOf(loopType, iterableType)) {
+ bestIterableType = DynamicTypeImpl.instance;
+ }
+ }
+
if (bestIterableType == null) {
_errorReporter.reportTypeErrorForNode(
StaticTypeWarningCode.FOR_IN_OF_INVALID_TYPE,
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/task/strong/checker.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698