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/src/generated/ast.dart'; | 9 import 'package:analyzer/src/generated/ast.dart'; |
10 import 'package:analyzer/src/generated/element.dart'; | 10 import 'package:analyzer/src/generated/element.dart'; |
(...skipping 10 matching lines...) Expand all Loading... | |
21 // | 21 // |
22 // Update the type of the parameter. | 22 // Update the type of the parameter. |
23 // | 23 // |
24 parameter.type = type; | 24 parameter.type = type; |
25 // | 25 // |
26 // Update the type of the setter to reflect the new parameter type. | 26 // Update the type of the setter to reflect the new parameter type. |
27 // | 27 // |
28 FunctionType functionType = element.type; | 28 FunctionType functionType = element.type; |
29 if (functionType is FunctionTypeImpl) { | 29 if (functionType is FunctionTypeImpl) { |
30 element.type = | 30 element.type = |
31 new FunctionTypeImpl(element, functionType.prunedTypedefs); | 31 new FunctionTypeImpl(element, functionType.prunedTypedefs) |
32 ..typeArguments = functionType.typeArguments; | |
Jennifer Messerly
2015/09/24 22:35:56
not sure if y'all use cascades, let me know if the
Brian Wilkerson
2015/09/24 22:49:27
I haven't gotten in the habit of using them much,
| |
32 } else { | 33 } else { |
33 assert(false); | 34 assert(false); |
34 } | 35 } |
35 } else { | 36 } else { |
36 assert(false); | 37 assert(false); |
37 } | 38 } |
38 } else { | 39 } else { |
39 throw new StateError('element is an instance of ${element.runtimeType}'); | 40 throw new StateError('element is an instance of ${element.runtimeType}'); |
40 assert(false); | 41 assert(false); |
41 } | 42 } |
42 } | 43 } |
43 | 44 |
44 /** | 45 /** |
45 * Set the return type of the given [element] to the given [type]. | 46 * Set the return type of the given [element] to the given [type]. |
46 */ | 47 */ |
47 void setReturnType(ExecutableElement element, DartType type) { | 48 void setReturnType(ExecutableElement element, DartType type) { |
48 if (element is ExecutableElementImpl) { | 49 if (element is ExecutableElementImpl) { |
49 // | 50 // |
50 // Update the return type of the element, which is stored in two places: | 51 // Update the return type of the element, which is stored in two places: |
51 // directly in the element and indirectly in the type of the element. | 52 // directly in the element and indirectly in the type of the element. |
52 // | 53 // |
53 element.returnType = type; | 54 element.returnType = type; |
54 FunctionType functionType = element.type; | 55 FunctionType functionType = element.type; |
55 if (functionType is FunctionTypeImpl) { | 56 if (functionType is FunctionTypeImpl) { |
56 element.type = new FunctionTypeImpl(element, functionType.prunedTypedefs); | 57 element.type = new FunctionTypeImpl(element, functionType.prunedTypedefs) |
58 ..typeArguments = functionType.typeArguments; | |
57 } else { | 59 } else { |
58 assert(false); | 60 assert(false); |
59 } | 61 } |
60 } else { | 62 } else { |
61 assert(false); | 63 assert(false); |
62 } | 64 } |
63 } | 65 } |
64 | 66 |
65 /** | 67 /** |
66 * Return the element for the single parameter of the given [setter], or `null` | 68 * Return the element for the single parameter of the given [setter], or `null` |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
470 results.add(element); | 472 results.add(element); |
471 } | 473 } |
472 } | 474 } |
473 } | 475 } |
474 } | 476 } |
475 | 477 |
476 /** | 478 /** |
477 * A class of exception that is not used anywhere else. | 479 * A class of exception that is not used anywhere else. |
478 */ | 480 */ |
479 class _CycleException implements Exception {} | 481 class _CycleException implements Exception {} |
OLD | NEW |