OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library analyzer.src.task.strong_mode; | 5 library analyzer.src.task.strong_mode; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
10 import 'package:analyzer/dart/ast/visitor.dart'; | 10 import 'package:analyzer/dart/ast/visitor.dart'; |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 | 266 |
267 _FieldOverrideInferenceResult typeResult = | 267 _FieldOverrideInferenceResult typeResult = |
268 _computeFieldOverrideType(element); | 268 _computeFieldOverrideType(element); |
269 if (typeResult.isError == null || typeResult.type == null) { | 269 if (typeResult.isError == null || typeResult.type == null) { |
270 return; | 270 return; |
271 } | 271 } |
272 | 272 |
273 if (element.kind == ElementKind.GETTER) { | 273 if (element.kind == ElementKind.GETTER) { |
274 (element as ExecutableElementImpl).returnType = typeResult.type; | 274 (element as ExecutableElementImpl).returnType = typeResult.type; |
275 } else if (element.kind == ElementKind.SETTER) { | 275 } else if (element.kind == ElementKind.SETTER) { |
276 var parameter = element.parameters[0] as ParameterElementImpl; | 276 List<ParameterElement> parameters = element.parameters; |
277 if (parameter.hasImplicitType) { | 277 if (parameters.isNotEmpty) { |
278 parameter.type = typeResult.type; | 278 var parameter = parameters[0] as ParameterElementImpl; |
| 279 if (parameter.hasImplicitType) { |
| 280 parameter.type = typeResult.type; |
| 281 } |
| 282 parameter.inheritsCovariant = typeResult.isCovariant; |
279 } | 283 } |
280 parameter.inheritsCovariant = typeResult.isCovariant; | |
281 } | 284 } |
282 setFieldType(element.variable, typeResult.type); | 285 setFieldType(element.variable, typeResult.type); |
283 } | 286 } |
284 | 287 |
285 /** | 288 /** |
286 * Infer type information for all of the instance members in the given | 289 * Infer type information for all of the instance members in the given |
287 * [classElement]. | 290 * [classElement]. |
288 */ | 291 */ |
289 void _inferClass(ClassElement classElement) { | 292 void _inferClass(ClassElement classElement) { |
290 if (classElement is ClassElementImpl) { | 293 if (classElement is ClassElementImpl) { |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 AstNode parent = node.parent; | 674 AstNode parent = node.parent; |
672 if (parent is PropertyAccess && parent.propertyName == node || | 675 if (parent is PropertyAccess && parent.propertyName == node || |
673 parent is PrefixedIdentifier && parent.identifier == node) { | 676 parent is PrefixedIdentifier && parent.identifier == node) { |
674 isValid = false; | 677 isValid = false; |
675 } | 678 } |
676 } else if (element is PropertyAccessorElement && !element.isStatic) { | 679 } else if (element is PropertyAccessorElement && !element.isStatic) { |
677 isValid = false; | 680 isValid = false; |
678 } | 681 } |
679 } | 682 } |
680 } | 683 } |
OLD | NEW |