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

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

Issue 1578863004: fixes #24711, allow factory constructors to be downcast (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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 cf4f8226714d4f5000d77144aabbec8cde263ec4..b6882bc4368293ddd41074a32329e6acc3b5f637 100644
--- a/pkg/analyzer/lib/src/task/strong/info.dart
+++ b/pkg/analyzer/lib/src/task/strong/info.dart
@@ -133,9 +133,12 @@ abstract class DownCast extends CoercionInfo {
return new UninferredClosure(rules, expression, cast);
}
if (expression is InstanceCreationExpression) {
- // fromT should be an exact type - this will almost certainly fail at
- // runtime.
- return new StaticTypeError(rules, expression, toT, reason: reason);
+ ConstructorElement e = expression.staticElement;
+ if (e == null || !e.isFactory) {
+ // fromT should be an exact type - this will almost certainly fail at
+ // runtime.
+ return new StaticTypeError(rules, expression, toT, reason: reason);
+ }
}
// TODO(vsm): Change this to an assert when we have generic methods and
« 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