Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 /// This file declares a "shadow hierarchy" of concrete classes which extend | 5 /// This file declares a "shadow hierarchy" of concrete classes which extend |
| 6 /// the kernel class hierarchy, adding methods and fields needed by the | 6 /// the kernel class hierarchy, adding methods and fields needed by the |
| 7 /// BodyBuilder. | 7 /// BodyBuilder. |
| 8 /// | 8 /// |
| 9 /// Instances of these classes may be created using the factory methods in | 9 /// Instances of these classes may be created using the factory methods in |
| 10 /// `ast_factory.dart`. | 10 /// `ast_factory.dart`. |
| (...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 877 // KernelVariableDeclaration. | 877 // KernelVariableDeclaration. |
| 878 mutatedInClosure = true; | 878 mutatedInClosure = true; |
| 879 declaredType = variable.type; | 879 declaredType = variable.type; |
| 880 } | 880 } |
| 881 return inferrer.inferVariableGet(typeContext, typeNeeded, mutatedInClosure, | 881 return inferrer.inferVariableGet(typeContext, typeNeeded, mutatedInClosure, |
| 882 _fact, _scope, fileOffset, declaredType, (type) { | 882 _fact, _scope, fileOffset, declaredType, (type) { |
| 883 promotedType = type; | 883 promotedType = type; |
| 884 }); | 884 }); |
| 885 } | 885 } |
| 886 } | 886 } |
| 887 | |
| 888 /// Concrete shadow object representing a write to a variable in kernel form. | |
| 889 class KernelVariableSet extends VariableSet implements KernelExpression { | |
| 890 KernelVariableSet(VariableDeclaration variable, Expression value) | |
| 891 : super(variable, value); | |
| 892 | |
| 893 @override | |
| 894 DartType _inferExpression( | |
| 895 KernelTypeInferrer inferrer, DartType typeContext, bool typeNeeded) { | |
| 896 DartType declaredType; | |
| 897 var variable = this.variable; | |
| 898 if (variable is KernelVariableDeclaration) { | |
| 899 declaredType = variable._declaredType; | |
| 900 } else { | |
| 901 // Hack to deal with the fact that BodyBuilder still creates raw | |
| 902 // VariableDeclaration objects sometimes. | |
| 903 // TODO(paulberry): get rid of this once the type parameter is | |
| 904 // KernelVariableDeclaration. | |
| 905 declaredType = variable.type; | |
| 906 } | |
| 907 // TODO(scheglov) Should we use the declared type, or the promoted type? | |
|
Paul Berry
2017/05/04 19:31:03
I believe the declared type is better, since the p
scheglov
2017/05/04 19:41:01
Acknowledged.
| |
| 908 return inferrer.inferVariableSet(typeNeeded, declaredType, value); | |
|
scheglov
2017/05/04 18:41:58
We don't need "typeContext" in inferrer, should we
Paul Berry
2017/05/04 19:31:03
I would prefer for us to pass it in for consistenc
scheglov
2017/05/04 19:41:01
Done.
| |
| 909 } | |
| 910 } | |
| OLD | NEW |