| 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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 @override | 272 @override |
| 273 DartType _inferExpression( | 273 DartType _inferExpression( |
| 274 KernelTypeInferrer inferrer, DartType typeContext, bool typeNeeded) { | 274 KernelTypeInferrer inferrer, DartType typeContext, bool typeNeeded) { |
| 275 typeNeeded = | 275 typeNeeded = |
| 276 inferrer.listener.conditionalExpressionEnter(this, typeContext) || | 276 inferrer.listener.conditionalExpressionEnter(this, typeContext) || |
| 277 typeNeeded; | 277 typeNeeded; |
| 278 if (!inferrer.isTopLevel) { | 278 if (!inferrer.isTopLevel) { |
| 279 inferrer.inferExpression( | 279 inferrer.inferExpression( |
| 280 condition, inferrer.coreTypes.boolClass.rawType, false); | 280 condition, inferrer.coreTypes.boolClass.rawType, false); |
| 281 } | 281 } |
| 282 // TODO(paulberry): is it correct to pass the context down? | |
| 283 DartType thenType = inferrer.inferExpression(then, typeContext, true); | 282 DartType thenType = inferrer.inferExpression(then, typeContext, true); |
| 284 DartType otherwiseType = | 283 DartType otherwiseType = |
| 285 inferrer.inferExpression(otherwise, typeContext, true); | 284 inferrer.inferExpression(otherwise, typeContext, true); |
| 286 // TODO(paulberry): the spec proposal says we should only use LUB if the | |
| 287 // typeContext is `null`. If typeContext is non-null, we should use the | |
| 288 // greatest closure of the context with respect to `?` | |
| 289 DartType type = inferrer.typeSchemaEnvironment | 285 DartType type = inferrer.typeSchemaEnvironment |
| 290 .getLeastUpperBound(thenType, otherwiseType); | 286 .getLeastUpperBound(thenType, otherwiseType); |
| 291 staticType = type; | 287 staticType = type; |
| 292 var inferredType = typeNeeded ? type : null; | 288 var inferredType = typeNeeded ? type : null; |
| 293 inferrer.listener.conditionalExpressionExit(this, inferredType); | 289 inferrer.listener.conditionalExpressionExit(this, inferredType); |
| 294 return inferredType; | 290 return inferredType; |
| 295 } | 291 } |
| 296 } | 292 } |
| 297 | 293 |
| 298 /// Shadow object for [ConstructorInvocation]. | 294 /// Shadow object for [ConstructorInvocation]. |
| (...skipping 1600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1899 } | 1895 } |
| 1900 | 1896 |
| 1901 visitChildren(v) { | 1897 visitChildren(v) { |
| 1902 return internalError("Internal error: Unsupported operation."); | 1898 return internalError("Internal error: Unsupported operation."); |
| 1903 } | 1899 } |
| 1904 | 1900 |
| 1905 transformChildren(v) { | 1901 transformChildren(v) { |
| 1906 return internalError("Internal error: Unsupported operation."); | 1902 return internalError("Internal error: Unsupported operation."); |
| 1907 } | 1903 } |
| 1908 } | 1904 } |
| OLD | NEW |