Index: pkg/analyzer/lib/src/generated/resolver.dart |
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart |
index cfb6b8990b4d311c1b85e87220b9e6e9462fa186..fc771e6e8316d5b873c6cf878eb4162e89b8b6e0 100644 |
--- a/pkg/analyzer/lib/src/generated/resolver.dart |
+++ b/pkg/analyzer/lib/src/generated/resolver.dart |
@@ -5579,6 +5579,11 @@ class ResolverVisitor extends ScopedVisitor { |
bool resolveOnlyCommentInFunctionBody = false; |
/** |
+ * True if we're analyzing in strong mode. |
+ */ |
+ bool _strongMode; |
+ |
+ /** |
* Body of the function currently being analyzed, if any. |
*/ |
FunctionBody _currentFunctionBody; |
@@ -5609,6 +5614,7 @@ class ResolverVisitor extends ScopedVisitor { |
this.typeSystem = definingLibrary.context.typeSystem; |
bool strongModeHints = false; |
AnalysisOptions options = definingLibrary.context.analysisOptions; |
+ _strongMode = options.strongMode; |
if (options is AnalysisOptionsImpl) { |
strongModeHints = options.strongModeHints; |
} |
@@ -6299,13 +6305,23 @@ class ResolverVisitor extends ScopedVisitor { |
@override |
Object visitDefaultFormalParameter(DefaultFormalParameter node) { |
- InferenceContext.setType(node.defaultValue, node.parameter.element?.type); |
- super.visitDefaultFormalParameter(node); |
ParameterElement element = node.element; |
+ InferenceContext.setType(node.defaultValue, element.type); |
Jennifer Messerly
2016/06/23 20:14:46
I verified with an assert that `node.parameter.ele
|
+ super.visitDefaultFormalParameter(node); |
if (element.initializer != null && node.defaultValue != null) { |
(element.initializer as FunctionElementImpl).returnType = |
node.defaultValue.staticType; |
} |
+ if (_strongMode && |
+ node.defaultValue != null && |
+ element.hasImplicitType && |
+ element is! FieldFormalParameterElement) { |
Jennifer Messerly
2016/06/23 20:14:46
I experimented with allowing field formal paramete
|
+ |
+ DartType type = node.defaultValue.staticType; |
+ if (!type.isBottom && !type.isDynamic) { |
Leaf
2016/06/23 22:21:17
Are we quite sure that type can't be null here?
Jennifer Messerly
2016/06/24 18:33:59
I think so? :) after resolving an expression, the
Leaf
2016/06/24 21:48:53
I'm ok leaving it. Just wanted to check since we
|
+ (element as ParameterElementImpl).type = type; |
Leaf
2016/06/23 22:21:17
I'm been trying to record all inference events, ev
Jennifer Messerly
2016/06/24 18:33:59
Yeah that's a good idea ... the only strange part
|
+ } |
+ } |
// Clone the ASTs for default formal parameters, so that we can use them |
// during constant evaluation. |
if (!LibraryElementImpl.hasResolutionCapability( |