Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: pkg/analyzer/lib/src/generated/error_verifier.dart

Issue 1609093003: fixes #25482, flatten Futures in strong mode so Future.then works (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.error_verifier; 5 library analyzer.src.generated.error_verifier;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import "dart:math" as math; 8 import "dart:math" as math;
9 9
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
11 import 'package:analyzer/dart/ast/visitor.dart'; 11 import 'package:analyzer/dart/ast/visitor.dart';
12 import 'package:analyzer/dart/element/element.dart'; 12 import 'package:analyzer/dart/element/element.dart';
13 import 'package:analyzer/dart/element/type.dart'; 13 import 'package:analyzer/dart/element/type.dart';
14 import 'package:analyzer/dart/element/visitor.dart'; 14 import 'package:analyzer/dart/element/visitor.dart';
15 import 'package:analyzer/src/dart/element/element.dart'; 15 import 'package:analyzer/src/dart/element/element.dart';
16 import 'package:analyzer/src/dart/element/member.dart'; 16 import 'package:analyzer/src/dart/element/member.dart';
17 import 'package:analyzer/src/dart/element/type.dart'; 17 import 'package:analyzer/src/dart/element/type.dart';
18 import 'package:analyzer/src/generated/constant.dart'; 18 import 'package:analyzer/src/generated/constant.dart';
19 import 'package:analyzer/src/generated/element_resolver.dart'; 19 import 'package:analyzer/src/generated/element_resolver.dart';
20 import 'package:analyzer/src/generated/error.dart'; 20 import 'package:analyzer/src/generated/error.dart';
21 import 'package:analyzer/src/generated/java_engine.dart'; 21 import 'package:analyzer/src/generated/java_engine.dart';
22 import 'package:analyzer/src/generated/parser.dart' 22 import 'package:analyzer/src/generated/parser.dart'
23 show Parser, ParserErrorCode; 23 show Parser, ParserErrorCode;
24 import 'package:analyzer/src/generated/resolver.dart'; 24 import 'package:analyzer/src/generated/resolver.dart';
25 import 'package:analyzer/src/generated/scanner.dart' as sc; 25 import 'package:analyzer/src/generated/scanner.dart' as sc;
26 import 'package:analyzer/src/generated/sdk.dart' show DartSdk, SdkLibrary; 26 import 'package:analyzer/src/generated/sdk.dart' show DartSdk, SdkLibrary;
27 import 'package:analyzer/src/generated/static_type_analyzer.dart';
28 import 'package:analyzer/src/generated/utilities_dart.dart'; 27 import 'package:analyzer/src/generated/utilities_dart.dart';
29 28
30 /** 29 /**
31 * A visitor used to traverse an AST structure looking for additional errors and 30 * A visitor used to traverse an AST structure looking for additional errors and
32 * warnings not covered by the parser and resolver. 31 * warnings not covered by the parser and resolver.
33 */ 32 */
34 class ErrorVerifier extends RecursiveAstVisitor<Object> { 33 class ErrorVerifier extends RecursiveAstVisitor<Object> {
35 /** 34 /**
36 * Static final string with value `"getter "` used in the construction of the 35 * Static final string with value `"getter "` used in the construction of the
37 * [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE], and 36 * [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE], and
(...skipping 5727 matching lines...) Expand 10 before | Expand all | Expand 10 after
5765 assert(!_inGenerator); 5764 assert(!_inGenerator);
5766 if (returnExpression == null) { 5765 if (returnExpression == null) {
5767 if (_enclosingFunction.isAsynchronous) { 5766 if (_enclosingFunction.isAsynchronous) {
5768 return _typeProvider.futureNullType; 5767 return _typeProvider.futureNullType;
5769 } else { 5768 } else {
5770 return VoidTypeImpl.instance; 5769 return VoidTypeImpl.instance;
5771 } 5770 }
5772 } 5771 }
5773 DartType staticReturnType = getStaticType(returnExpression); 5772 DartType staticReturnType = getStaticType(returnExpression);
5774 if (staticReturnType != null && _enclosingFunction.isAsynchronous) { 5773 if (staticReturnType != null && _enclosingFunction.isAsynchronous) {
5775 return _typeProvider.futureType.substitute4(<DartType>[ 5774 return _typeProvider.futureType.substitute4(
5776 StaticTypeAnalyzer.flattenFutures(_typeProvider, staticReturnType) 5775 <DartType>[staticReturnType.flattenFutures(_typeSystem)]);
5777 ]);
5778 } 5776 }
5779 return staticReturnType; 5777 return staticReturnType;
5780 } 5778 }
5781 5779
5782 /** 5780 /**
5783 * Return the error code that should be used when the given class [element] 5781 * Return the error code that should be used when the given class [element]
5784 * references itself directly. 5782 * references itself directly.
5785 */ 5783 */
5786 ErrorCode _getBaseCaseErrorCode(ClassElement element) { 5784 ErrorCode _getBaseCaseErrorCode(ClassElement element) {
5787 InterfaceType supertype = element.supertype; 5785 InterfaceType supertype = element.supertype;
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
6205 toCheck.add(type.element); 6203 toCheck.add(type.element);
6206 // type arguments 6204 // type arguments
6207 if (type is InterfaceType) { 6205 if (type is InterfaceType) {
6208 InterfaceType interfaceType = type; 6206 InterfaceType interfaceType = type;
6209 for (DartType typeArgument in interfaceType.typeArguments) { 6207 for (DartType typeArgument in interfaceType.typeArguments) {
6210 _addTypeToCheck(typeArgument); 6208 _addTypeToCheck(typeArgument);
6211 } 6209 }
6212 } 6210 }
6213 } 6211 }
6214 } 6212 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698