Chromium Code Reviews| 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 7c3433d5d18ec5f3c2bfe55be18287c8310b3a6e..3ae42e474a965824460dc9d6ed74d540a8555bd1 100644 |
| --- a/pkg/analyzer/lib/src/generated/resolver.dart |
| +++ b/pkg/analyzer/lib/src/generated/resolver.dart |
| @@ -11674,6 +11674,11 @@ class TypeResolverVisitor extends ScopedVisitor { |
| bool _hasReferenceToSuper = false; |
| /** |
| + * True if we're analyzing in strong mode. |
| + */ |
| + bool _strongMode; |
| + |
| + /** |
| * Initialize a newly created visitor to resolve the nodes in an AST node. |
| * |
| * [definingLibrary] is the element for the library containing the node being |
| @@ -11695,6 +11700,7 @@ class TypeResolverVisitor extends ScopedVisitor { |
| nameScope: nameScope) { |
| _dynamicType = typeProvider.dynamicType; |
| _undefinedType = typeProvider.undefinedType; |
| + _strongMode = definingLibrary.context.analysisOptions.strongMode; |
| } |
| @override |
| @@ -11935,6 +11941,7 @@ class TypeResolverVisitor extends ScopedVisitor { |
| } |
| element.returnType = _computeReturnType(node.returnType); |
| element.type = new FunctionTypeImpl(element); |
| + _inferSetterReturnType(element); |
| return null; |
| } |
| @@ -11983,6 +11990,7 @@ class TypeResolverVisitor extends ScopedVisitor { |
| } |
| element.returnType = _computeReturnType(node.returnType); |
| element.type = new FunctionTypeImpl(element); |
| + _inferSetterReturnType(element); |
| if (element is PropertyAccessorElement) { |
| PropertyAccessorElement accessor = element as PropertyAccessorElement; |
| PropertyInducingElementImpl variable = |
| @@ -12511,6 +12519,20 @@ class TypeResolverVisitor extends ScopedVisitor { |
| return type; |
| } |
| + /** |
| + * In strong mode we infer "void" as the setter return type (as void is the |
| + * only legal return type for a setter). This allows us to give better |
| + * errors later if an invalid type is returned. |
| + */ |
| + void _inferSetterReturnType(ExecutableElementImpl element) { |
| + if (_strongMode && |
| + element is PropertyAccessorElementImpl && |
| + element.isSetter && |
| + element.returnType.isDynamic) { |
|
Brian Wilkerson
2015/12/17 17:57:59
We should check that the type 'dynamic' was not ex
Jennifer Messerly
2016/01/05 00:42:44
Good catch! I thought it was okay because it's inv
|
| + element.returnType = VoidTypeImpl.instance; |
| + } |
| + } |
| + |
| DartType _instantiateType(DartType type, List<DartType> typeArguments) { |
| if (type is InterfaceTypeImpl) { |
| return type.substitute4(typeArguments); |