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

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

Issue 1780783002: Don't report redundant type errors in strong mode. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Stop type propagation in test. 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 | « pkg/analyzer/lib/src/generated/error_verifier.dart ('k') | 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/type_system.dart
diff --git a/pkg/analyzer/lib/src/generated/type_system.dart b/pkg/analyzer/lib/src/generated/type_system.dart
index ff70e899be87bccc9ba815f3379da9b8c0c10d17..84f2eb7c2168c68532b02a388a9061296c734233 100644
--- a/pkg/analyzer/lib/src/generated/type_system.dart
+++ b/pkg/analyzer/lib/src/generated/type_system.dart
@@ -206,6 +206,18 @@ class StrongTypeSystemImpl extends TypeSystem {
return false;
}
+ // Don't allow a non-generic function where a generic one is expected. The
+ // former wouldn't know how to handle type arguments being passed to it.
+ // TODO(rnystrom): This same check also exists in FunctionTypeImpl.relate()
+ // but we don't always reliably go through that code path. This should be
+ // cleaned up to avoid the redundancy.
+ if (fromType is FunctionType &&
+ toType is FunctionType &&
+ fromType.typeFormals.isEmpty &&
+ toType.typeFormals.isNotEmpty) {
+ return false;
+ }
+
// If the subtype relation goes the other way, allow the implicit downcast.
// TODO(leafp): Emit warnings and hints for these in some way.
// TODO(leafp): Consider adding a flag to disable these? Or just rely on
« no previous file with comments | « pkg/analyzer/lib/src/generated/error_verifier.dart ('k') | pkg/analyzer/lib/src/task/strong/checker.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698