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 11 matching lines...) Expand all Loading... |
22 * synthetic getter/setter types. | 22 * synthetic getter/setter types. |
23 */ | 23 */ |
24 void setFieldType(VariableElement field, DartType newType) { | 24 void setFieldType(VariableElement field, DartType newType) { |
25 (field as VariableElementImpl).type = newType; | 25 (field as VariableElementImpl).type = newType; |
26 if (field.initializer != null) { | 26 if (field.initializer != null) { |
27 (field.initializer as ExecutableElementImpl).returnType = newType; | 27 (field.initializer as ExecutableElementImpl).returnType = newType; |
28 } | 28 } |
29 if (field is PropertyInducingElementImpl) { | 29 if (field is PropertyInducingElementImpl) { |
30 (field.getter as ExecutableElementImpl).returnType = newType; | 30 (field.getter as ExecutableElementImpl).returnType = newType; |
31 if (!field.isFinal && !field.isConst) { | 31 if (!field.isFinal && !field.isConst) { |
32 (field.setter.parameters[0] as ParameterElementImpl).type = newType; | 32 List<ParameterElement> setterParameters = field.setter.parameters; |
| 33 if (setterParameters.isNotEmpty) { |
| 34 (setterParameters[0] as ParameterElementImpl).type = newType; |
| 35 } |
33 } | 36 } |
34 } | 37 } |
35 } | 38 } |
36 | 39 |
37 /** | 40 /** |
38 * Return the element for the single parameter of the given [setter], or `null` | 41 * Return the element for the single parameter of the given [setter], or `null` |
39 * if the executable element is not a setter or does not have a single | 42 * if the executable element is not a setter or does not have a single |
40 * parameter. | 43 * parameter. |
41 */ | 44 */ |
42 ParameterElement _getParameter(ExecutableElement setter) { | 45 ParameterElement _getParameter(ExecutableElement setter) { |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 results.add(element); | 476 results.add(element); |
474 } | 477 } |
475 } | 478 } |
476 } | 479 } |
477 } | 480 } |
478 | 481 |
479 /** | 482 /** |
480 * A class of exception that is not used anywhere else. | 483 * A class of exception that is not used anywhere else. |
481 */ | 484 */ |
482 class _CycleException implements Exception {} | 485 class _CycleException implements Exception {} |
OLD | NEW |