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

Unified Diff: pkg/analyzer/lib/src/task/strong_mode.dart

Issue 1367183004: analyzer strong mode: infer final field from initializer if super getters are dynamic (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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_mode_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_mode.dart
diff --git a/pkg/analyzer/lib/src/task/strong_mode.dart b/pkg/analyzer/lib/src/task/strong_mode.dart
index f8cb97f6e8964224c15fbab6d0fdc2a9993c3bae..b599cdf173c0a92349c5e4d5fb7895341e06a4e6 100644
--- a/pkg/analyzer/lib/src/task/strong_mode.dart
+++ b/pkg/analyzer/lib/src/task/strong_mode.dart
@@ -297,7 +297,11 @@ class InstanceMemberInferrer {
// Then, if none was found, infer the type from the initialization
// expression.
//
- if (newType == null) {
+ // Also, if we're the field is final and overridden getter is dynamic,
+ // we can infer from the initialization without breaking subtyping rules
+ // (return type is covariant).
+ //
+ if (newType == null || newType.isDynamic) {
Jennifer Messerly 2015/09/25 21:41:55 this fix is intended to match: https://github.com/
Brian Wilkerson 2015/09/25 22:00:00 hasImplicitType only applies to variables, not typ
Jennifer Messerly 2015/09/25 22:22:11 What doesn't make sense about the comment? That's
Leaf 2015/09/25 22:36:32 The comment has a wording problem in the first lin
Jennifer Messerly 2015/09/25 22:48:23 ah good catch. How about this: Also infer from th
Brian Wilkerson 2015/09/26 00:36:29 Aside from the grammatical error, it seems to me t
Jennifer Messerly 2015/09/26 00:48:23 "if <condition>, do this" "also, if <other conditi
if (fieldElement.initializer != null &&
(fieldElement.isFinal || overriddenGetters.isEmpty)) {
newType = fieldElement.initializer.returnType;
« no previous file with comments | « no previous file | pkg/analyzer/test/src/task/strong_mode_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698