| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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.generated.resolver; | 5 library analyzer.src.generated.resolver; |
| 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 8413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8424 safelyVisit(node.rightHandSide); | 8424 safelyVisit(node.rightHandSide); |
| 8425 node.accept(elementResolver); | 8425 node.accept(elementResolver); |
| 8426 node.accept(typeAnalyzer); | 8426 node.accept(typeAnalyzer); |
| 8427 return null; | 8427 return null; |
| 8428 } | 8428 } |
| 8429 | 8429 |
| 8430 @override | 8430 @override |
| 8431 Object visitAwaitExpression(AwaitExpression node) { | 8431 Object visitAwaitExpression(AwaitExpression node) { |
| 8432 // TODO(leafp): Handle the implicit union type here | 8432 // TODO(leafp): Handle the implicit union type here |
| 8433 // https://github.com/dart-lang/sdk/issues/25322 | 8433 // https://github.com/dart-lang/sdk/issues/25322 |
| 8434 DartType contextType = StaticTypeAnalyzer.flattenFutures( | 8434 DartType contextType = InferenceContext.getType(node); |
| 8435 typeProvider, InferenceContext.getType(node)); | |
| 8436 if (contextType != null) { | 8435 if (contextType != null) { |
| 8437 InterfaceType futureT = | 8436 InterfaceType futureT = typeProvider.futureType |
| 8438 typeProvider.futureType.substitute4([contextType]); | 8437 .substitute4([contextType.flattenFutures(typeSystem)]); |
| 8439 InferenceContext.setType(node.expression, futureT); | 8438 InferenceContext.setType(node.expression, futureT); |
| 8440 } | 8439 } |
| 8441 return super.visitAwaitExpression(node); | 8440 return super.visitAwaitExpression(node); |
| 8442 } | 8441 } |
| 8443 | 8442 |
| 8444 @override | 8443 @override |
| 8445 Object visitBinaryExpression(BinaryExpression node) { | 8444 Object visitBinaryExpression(BinaryExpression node) { |
| 8446 TokenType operatorType = node.operator.type; | 8445 TokenType operatorType = node.operator.type; |
| 8447 Expression leftOperand = node.leftOperand; | 8446 Expression leftOperand = node.leftOperand; |
| 8448 Expression rightOperand = node.rightOperand; | 8447 Expression rightOperand = node.rightOperand; |
| (...skipping 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9471 // If it's synchronous, we expect Iterable<T>, otherwise Stream<T> | 9470 // If it's synchronous, we expect Iterable<T>, otherwise Stream<T> |
| 9472 InterfaceType rawType = isAsynchronous | 9471 InterfaceType rawType = isAsynchronous |
| 9473 ? typeProvider.streamDynamicType | 9472 ? typeProvider.streamDynamicType |
| 9474 : typeProvider.iterableDynamicType; | 9473 : typeProvider.iterableDynamicType; |
| 9475 // Match the types to instantiate the type arguments if possible | 9474 // Match the types to instantiate the type arguments if possible |
| 9476 List<DartType> typeArgs = | 9475 List<DartType> typeArgs = |
| 9477 inferenceContext.matchTypes(rawType, declaredType); | 9476 inferenceContext.matchTypes(rawType, declaredType); |
| 9478 return (typeArgs?.length == 1) ? typeArgs[0] : null; | 9477 return (typeArgs?.length == 1) ? typeArgs[0] : null; |
| 9479 } | 9478 } |
| 9480 // Must be asynchronous to reach here, so strip off any layers of Future | 9479 // Must be asynchronous to reach here, so strip off any layers of Future |
| 9481 return StaticTypeAnalyzer.flattenFutures(typeProvider, declaredType); | 9480 return declaredType.flattenFutures(typeSystem); |
| 9482 } | 9481 } |
| 9483 | 9482 |
| 9484 /** | 9483 /** |
| 9485 * The given expression is the expression used to compute the iterator for a | 9484 * The given expression is the expression used to compute the iterator for a |
| 9486 * for-each statement. Attempt to compute the type of objects that will be | 9485 * for-each statement. Attempt to compute the type of objects that will be |
| 9487 * assigned to the loop variable and return that type. Return `null` if the | 9486 * assigned to the loop variable and return that type. Return `null` if the |
| 9488 * type could not be determined. The [iteratorExpression] is the expression | 9487 * type could not be determined. The [iteratorExpression] is the expression |
| 9489 * that will return the Iterable being iterated over. | 9488 * that will return the Iterable being iterated over. |
| 9490 */ | 9489 */ |
| 9491 DartType _getIteratorElementType(Expression iteratorExpression) { | 9490 DartType _getIteratorElementType(Expression iteratorExpression) { |
| (...skipping 4111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13603 nonFields.add(node); | 13602 nonFields.add(node); |
| 13604 return null; | 13603 return null; |
| 13605 } | 13604 } |
| 13606 | 13605 |
| 13607 @override | 13606 @override |
| 13608 Object visitNode(AstNode node) => node.accept(TypeResolverVisitor_this); | 13607 Object visitNode(AstNode node) => node.accept(TypeResolverVisitor_this); |
| 13609 | 13608 |
| 13610 @override | 13609 @override |
| 13611 Object visitWithClause(WithClause node) => null; | 13610 Object visitWithClause(WithClause node) => null; |
| 13612 } | 13611 } |
| OLD | NEW |