| 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.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/token.dart'; | 11 import 'package:analyzer/dart/ast/token.dart'; |
| 12 import 'package:analyzer/dart/ast/visitor.dart'; | 12 import 'package:analyzer/dart/ast/visitor.dart'; |
| 13 import 'package:analyzer/dart/element/element.dart'; | 13 import 'package:analyzer/dart/element/element.dart'; |
| 14 import 'package:analyzer/dart/element/type.dart'; | 14 import 'package:analyzer/dart/element/type.dart'; |
| 15 import 'package:analyzer/dart/element/visitor.dart'; | 15 import 'package:analyzer/dart/element/visitor.dart'; |
| 16 import 'package:analyzer/src/dart/ast/token.dart'; | 16 import 'package:analyzer/src/dart/ast/token.dart'; |
| 17 import 'package:analyzer/src/dart/ast/utilities.dart'; | 17 import 'package:analyzer/src/dart/ast/utilities.dart'; |
| 18 import 'package:analyzer/src/dart/element/element.dart'; | 18 import 'package:analyzer/src/dart/element/element.dart'; |
| 19 import 'package:analyzer/src/dart/element/member.dart'; | 19 import 'package:analyzer/src/dart/element/member.dart'; |
| 20 import 'package:analyzer/src/dart/element/type.dart'; | 20 import 'package:analyzer/src/dart/element/type.dart'; |
| 21 import 'package:analyzer/src/generated/constant.dart'; | 21 import 'package:analyzer/src/generated/constant.dart'; |
| 22 import 'package:analyzer/src/generated/element_resolver.dart'; | 22 import 'package:analyzer/src/generated/element_resolver.dart'; |
| 23 import 'package:analyzer/src/generated/engine.dart'; |
| 23 import 'package:analyzer/src/generated/error.dart'; | 24 import 'package:analyzer/src/generated/error.dart'; |
| 24 import 'package:analyzer/src/generated/java_engine.dart'; | 25 import 'package:analyzer/src/generated/java_engine.dart'; |
| 25 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; | 26 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; |
| 26 import 'package:analyzer/src/generated/resolver.dart'; | 27 import 'package:analyzer/src/generated/resolver.dart'; |
| 27 import 'package:analyzer/src/generated/sdk.dart' show DartSdk, SdkLibrary; | 28 import 'package:analyzer/src/generated/sdk.dart' show DartSdk, SdkLibrary; |
| 28 import 'package:analyzer/src/generated/utilities_dart.dart'; | 29 import 'package:analyzer/src/generated/utilities_dart.dart'; |
| 30 import 'package:analyzer/src/task/strong/info.dart' show StaticInfo; |
| 29 | 31 |
| 30 /** | 32 /** |
| 31 * A visitor used to traverse an AST structure looking for additional errors and | 33 * A visitor used to traverse an AST structure looking for additional errors and |
| 32 * warnings not covered by the parser and resolver. | 34 * warnings not covered by the parser and resolver. |
| 33 */ | 35 */ |
| 34 class ErrorVerifier extends RecursiveAstVisitor<Object> { | 36 class ErrorVerifier extends RecursiveAstVisitor<Object> { |
| 35 /** | 37 /** |
| 36 * Static final string with value `"getter "` used in the construction of the | 38 * Static final string with value `"getter "` used in the construction of the |
| 37 * [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE], and | 39 * [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE], and |
| 38 * similar, error code messages. | 40 * similar, error code messages. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 64 * The type representing the type 'bool'. | 66 * The type representing the type 'bool'. |
| 65 */ | 67 */ |
| 66 InterfaceType _boolType; | 68 InterfaceType _boolType; |
| 67 | 69 |
| 68 /** | 70 /** |
| 69 * The type representing the type 'int'. | 71 * The type representing the type 'int'. |
| 70 */ | 72 */ |
| 71 InterfaceType _intType; | 73 InterfaceType _intType; |
| 72 | 74 |
| 73 /** | 75 /** |
| 76 * The options for verification. |
| 77 */ |
| 78 AnalysisOptions _options; |
| 79 |
| 80 /** |
| 74 * The object providing access to the types defined by the language. | 81 * The object providing access to the types defined by the language. |
| 75 */ | 82 */ |
| 76 final TypeProvider _typeProvider; | 83 final TypeProvider _typeProvider; |
| 77 | 84 |
| 78 /** | 85 /** |
| 79 * The type system primitives | 86 * The type system primitives |
| 80 */ | 87 */ |
| 81 TypeSystem _typeSystem; | 88 TypeSystem _typeSystem; |
| 82 | 89 |
| 83 /** | 90 /** |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 _isInCatchClause = false; | 300 _isInCatchClause = false; |
| 294 _isInStaticVariableDeclaration = false; | 301 _isInStaticVariableDeclaration = false; |
| 295 _isInInstanceVariableDeclaration = false; | 302 _isInInstanceVariableDeclaration = false; |
| 296 _isInInstanceVariableInitializer = false; | 303 _isInInstanceVariableInitializer = false; |
| 297 _isInConstructorInitializer = false; | 304 _isInConstructorInitializer = false; |
| 298 _isInStaticMethod = false; | 305 _isInStaticMethod = false; |
| 299 _boolType = _typeProvider.boolType; | 306 _boolType = _typeProvider.boolType; |
| 300 _intType = _typeProvider.intType; | 307 _intType = _typeProvider.intType; |
| 301 _DISALLOWED_TYPES_TO_EXTEND_OR_IMPLEMENT = _typeProvider.nonSubtypableTypes; | 308 _DISALLOWED_TYPES_TO_EXTEND_OR_IMPLEMENT = _typeProvider.nonSubtypableTypes; |
| 302 _typeSystem = _currentLibrary.context.typeSystem; | 309 _typeSystem = _currentLibrary.context.typeSystem; |
| 310 _options = _currentLibrary.context.analysisOptions; |
| 303 } | 311 } |
| 304 | 312 |
| 305 @override | 313 @override |
| 306 Object visitAnnotation(Annotation node) { | 314 Object visitAnnotation(Annotation node) { |
| 307 _checkForInvalidAnnotationFromDeferredLibrary(node); | 315 _checkForInvalidAnnotationFromDeferredLibrary(node); |
| 308 _checkForMissingJSLibAnnotation(node); | 316 _checkForMissingJSLibAnnotation(node); |
| 309 return super.visitAnnotation(node); | 317 return super.visitAnnotation(node); |
| 310 } | 318 } |
| 311 | 319 |
| 312 @override | 320 @override |
| (...skipping 1687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2000 * [CompileTimeErrorCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE], | 2008 * [CompileTimeErrorCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE], |
| 2001 * [StaticWarningCode.MAP_KEY_TYPE_NOT_ASSIGNABLE], and | 2009 * [StaticWarningCode.MAP_KEY_TYPE_NOT_ASSIGNABLE], and |
| 2002 * [StaticWarningCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE]. | 2010 * [StaticWarningCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE]. |
| 2003 */ | 2011 */ |
| 2004 void _checkForArgumentTypeNotAssignable( | 2012 void _checkForArgumentTypeNotAssignable( |
| 2005 Expression expression, | 2013 Expression expression, |
| 2006 DartType expectedStaticType, | 2014 DartType expectedStaticType, |
| 2007 DartType actualStaticType, | 2015 DartType actualStaticType, |
| 2008 ErrorCode errorCode) { | 2016 ErrorCode errorCode) { |
| 2009 // Warning case: test static type information | 2017 // Warning case: test static type information |
| 2010 if (actualStaticType != null && | 2018 if (actualStaticType != null && expectedStaticType != null) { |
| 2011 expectedStaticType != null && | 2019 _checkForAssignableExpressionAtType( |
| 2012 !_typeSystem.isAssignableTo(actualStaticType, expectedStaticType)) { | 2020 expression, actualStaticType, expectedStaticType, errorCode); |
| 2013 _errorReporter.reportTypeErrorForNode( | |
| 2014 errorCode, expression, [actualStaticType, expectedStaticType]); | |
| 2015 } | 2021 } |
| 2016 } | 2022 } |
| 2017 | 2023 |
| 2018 /** | 2024 /** |
| 2019 * Verify that the given [argument] can be assigned to its corresponding | 2025 * Verify that the given [argument] can be assigned to its corresponding |
| 2020 * parameter. | 2026 * parameter. |
| 2021 * | 2027 * |
| 2022 * This method corresponds to | 2028 * This method corresponds to |
| 2023 * [BestPracticesVerifier.checkForArgumentTypeNotAssignableForArgument]. | 2029 * [BestPracticesVerifier.checkForArgumentTypeNotAssignableForArgument]. |
| 2024 * | 2030 * |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2084 */ | 2090 */ |
| 2085 void _checkForAssignability(Expression expression, InterfaceType type, | 2091 void _checkForAssignability(Expression expression, InterfaceType type, |
| 2086 ErrorCode errorCode, List<Object> arguments) { | 2092 ErrorCode errorCode, List<Object> arguments) { |
| 2087 if (expression == null) { | 2093 if (expression == null) { |
| 2088 return; | 2094 return; |
| 2089 } | 2095 } |
| 2090 DartType expressionType = expression.staticType; | 2096 DartType expressionType = expression.staticType; |
| 2091 if (expressionType == null) { | 2097 if (expressionType == null) { |
| 2092 return; | 2098 return; |
| 2093 } | 2099 } |
| 2094 if (_typeSystem.isAssignableTo(expressionType, type)) { | 2100 if (_expressionIsAssignableAtType(expression, expressionType, type)) { |
| 2095 return; | 2101 return; |
| 2096 } | 2102 } |
| 2097 _errorReporter.reportErrorForNode(errorCode, expression, arguments); | 2103 _errorReporter.reportErrorForNode(errorCode, expression, arguments); |
| 2098 } | 2104 } |
| 2099 | 2105 |
| 2106 bool _checkForAssignableExpression( |
| 2107 Expression expression, DartType expectedStaticType, ErrorCode errorCode) { |
| 2108 DartType actualStaticType = getStaticType(expression); |
| 2109 return actualStaticType != null && |
| 2110 _checkForAssignableExpressionAtType( |
| 2111 expression, actualStaticType, expectedStaticType, errorCode); |
| 2112 } |
| 2113 |
| 2114 bool _checkForAssignableExpressionAtType( |
| 2115 Expression expression, |
| 2116 DartType actualStaticType, |
| 2117 DartType expectedStaticType, |
| 2118 ErrorCode errorCode) { |
| 2119 // TODO(leafp): Move the Downcast functionality here. |
| 2120 // TODO(leafp): Support strict downcasts |
| 2121 if (!_expressionIsAssignableAtType( |
| 2122 expression, actualStaticType, expectedStaticType)) { |
| 2123 _errorReporter.reportTypeErrorForNode( |
| 2124 errorCode, expression, [actualStaticType, expectedStaticType]); |
| 2125 return false; |
| 2126 } |
| 2127 return true; |
| 2128 } |
| 2129 |
| 2100 /** | 2130 /** |
| 2101 * Verify that the given [expression] is not final. | 2131 * Verify that the given [expression] is not final. |
| 2102 * | 2132 * |
| 2103 * See [StaticWarningCode.ASSIGNMENT_TO_CONST], | 2133 * See [StaticWarningCode.ASSIGNMENT_TO_CONST], |
| 2104 * [StaticWarningCode.ASSIGNMENT_TO_FINAL], and | 2134 * [StaticWarningCode.ASSIGNMENT_TO_FINAL], and |
| 2105 * [StaticWarningCode.ASSIGNMENT_TO_METHOD]. | 2135 * [StaticWarningCode.ASSIGNMENT_TO_METHOD]. |
| 2106 */ | 2136 */ |
| 2107 void _checkForAssignmentToFinal(Expression expression) { | 2137 void _checkForAssignmentToFinal(Expression expression) { |
| 2108 // prepare element | 2138 // prepare element |
| 2109 Element element = null; | 2139 Element element = null; |
| (...skipping 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3276 // prepare expression type | 3306 // prepare expression type |
| 3277 Expression expression = initializer.expression; | 3307 Expression expression = initializer.expression; |
| 3278 if (expression == null) { | 3308 if (expression == null) { |
| 3279 return; | 3309 return; |
| 3280 } | 3310 } |
| 3281 // test the static type of the expression | 3311 // test the static type of the expression |
| 3282 DartType staticType = getStaticType(expression); | 3312 DartType staticType = getStaticType(expression); |
| 3283 if (staticType == null) { | 3313 if (staticType == null) { |
| 3284 return; | 3314 return; |
| 3285 } | 3315 } |
| 3286 if (_typeSystem.isAssignableTo(staticType, fieldType)) { | 3316 if (_expressionIsAssignableAtType(expression, staticType, fieldType)) { |
| 3287 return; | 3317 return; |
| 3288 } | 3318 } |
| 3289 // report problem | 3319 // report problem |
| 3290 if (_isEnclosingConstructorConst) { | 3320 if (_isEnclosingConstructorConst) { |
| 3291 // TODO(paulberry): this error should be based on the actual type of the | 3321 // TODO(paulberry): this error should be based on the actual type of the |
| 3292 // constant, not the static type. See dartbug.com/21119. | 3322 // constant, not the static type. See dartbug.com/21119. |
| 3293 _errorReporter.reportTypeErrorForNode( | 3323 _errorReporter.reportTypeErrorForNode( |
| 3294 CheckedModeCompileTimeErrorCode | 3324 CheckedModeCompileTimeErrorCode |
| 3295 .CONST_FIELD_INITIALIZER_NOT_ASSIGNABLE, | 3325 .CONST_FIELD_INITIALIZER_NOT_ASSIGNABLE, |
| 3296 expression, | 3326 expression, |
| (...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3844 * See [StaticTypeWarningCode.INVALID_ASSIGNMENT]. | 3874 * See [StaticTypeWarningCode.INVALID_ASSIGNMENT]. |
| 3845 */ | 3875 */ |
| 3846 void _checkForInvalidAssignment(Expression lhs, Expression rhs) { | 3876 void _checkForInvalidAssignment(Expression lhs, Expression rhs) { |
| 3847 if (lhs == null || rhs == null) { | 3877 if (lhs == null || rhs == null) { |
| 3848 return; | 3878 return; |
| 3849 } | 3879 } |
| 3850 VariableElement leftVariableElement = getVariableElement(lhs); | 3880 VariableElement leftVariableElement = getVariableElement(lhs); |
| 3851 DartType leftType = (leftVariableElement == null) | 3881 DartType leftType = (leftVariableElement == null) |
| 3852 ? getStaticType(lhs) | 3882 ? getStaticType(lhs) |
| 3853 : leftVariableElement.type; | 3883 : leftVariableElement.type; |
| 3854 DartType staticRightType = getStaticType(rhs); | 3884 _checkForAssignableExpression( |
| 3855 if (!_typeSystem.isAssignableTo(staticRightType, leftType)) { | 3885 rhs, leftType, StaticTypeWarningCode.INVALID_ASSIGNMENT); |
| 3856 _errorReporter.reportTypeErrorForNode( | |
| 3857 StaticTypeWarningCode.INVALID_ASSIGNMENT, | |
| 3858 rhs, | |
| 3859 [staticRightType, leftType]); | |
| 3860 } | |
| 3861 } | 3886 } |
| 3862 | 3887 |
| 3863 /** | 3888 /** |
| 3864 * Given an [assignment] using a compound assignment operator, this verifies | 3889 * Given an [assignment] using a compound assignment operator, this verifies |
| 3865 * that the given assignment is valid. The [lhs] is the left hand side | 3890 * that the given assignment is valid. The [lhs] is the left hand side |
| 3866 * expression. The [rhs] is the right hand side expression. | 3891 * expression. The [rhs] is the right hand side expression. |
| 3867 * | 3892 * |
| 3868 * See [StaticTypeWarningCode.INVALID_ASSIGNMENT]. | 3893 * See [StaticTypeWarningCode.INVALID_ASSIGNMENT]. |
| 3869 */ | 3894 */ |
| 3870 void _checkForInvalidCompoundAssignment( | 3895 void _checkForInvalidCompoundAssignment( |
| (...skipping 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5052 return; | 5077 return; |
| 5053 } | 5078 } |
| 5054 _errorReporter.reportTypeErrorForNode( | 5079 _errorReporter.reportTypeErrorForNode( |
| 5055 StaticTypeWarningCode.RETURN_OF_INVALID_TYPE, returnExpression, [ | 5080 StaticTypeWarningCode.RETURN_OF_INVALID_TYPE, returnExpression, [ |
| 5056 staticReturnType, | 5081 staticReturnType, |
| 5057 expectedReturnType, | 5082 expectedReturnType, |
| 5058 _enclosingFunction.displayName | 5083 _enclosingFunction.displayName |
| 5059 ]); | 5084 ]); |
| 5060 return; | 5085 return; |
| 5061 } | 5086 } |
| 5062 if (_typeSystem.isAssignableTo(staticReturnType, expectedReturnType)) { | 5087 if (_expressionIsAssignableAtType( |
| 5088 returnExpression, staticReturnType, expectedReturnType)) { |
| 5063 return; | 5089 return; |
| 5064 } | 5090 } |
| 5065 _errorReporter.reportTypeErrorForNode( | 5091 _errorReporter.reportTypeErrorForNode( |
| 5066 StaticTypeWarningCode.RETURN_OF_INVALID_TYPE, | 5092 StaticTypeWarningCode.RETURN_OF_INVALID_TYPE, |
| 5067 returnExpression, | 5093 returnExpression, |
| 5068 [staticReturnType, expectedReturnType, _enclosingFunction.displayName]); | 5094 [staticReturnType, expectedReturnType, _enclosingFunction.displayName]); |
| 5069 | 5095 |
| 5070 // TODO(brianwilkerson) Define a hint corresponding to the warning and | 5096 // TODO(brianwilkerson) Define a hint corresponding to the warning and |
| 5071 // report it if appropriate. | 5097 // report it if appropriate. |
| 5072 // Type propagatedReturnType = returnExpression.getPropagatedType(); | 5098 // Type propagatedReturnType = returnExpression.getPropagatedType(); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5130 | 5156 |
| 5131 // compare with type of the first non-default 'case' | 5157 // compare with type of the first non-default 'case' |
| 5132 SwitchCase switchCase = statement.members | 5158 SwitchCase switchCase = statement.members |
| 5133 .firstWhere((member) => member is SwitchCase, orElse: () => null); | 5159 .firstWhere((member) => member is SwitchCase, orElse: () => null); |
| 5134 if (switchCase == null) { | 5160 if (switchCase == null) { |
| 5135 return; | 5161 return; |
| 5136 } | 5162 } |
| 5137 | 5163 |
| 5138 Expression caseExpression = switchCase.expression; | 5164 Expression caseExpression = switchCase.expression; |
| 5139 DartType caseType = getStaticType(caseExpression); | 5165 DartType caseType = getStaticType(caseExpression); |
| 5166 |
| 5140 // check types | 5167 // check types |
| 5141 if (!_typeSystem.isAssignableTo(expressionType, caseType)) { | 5168 if (!_expressionIsAssignableAtType(expression, expressionType, caseType)) { |
| 5142 _errorReporter.reportErrorForNode( | 5169 _errorReporter.reportErrorForNode( |
| 5143 StaticWarningCode.SWITCH_EXPRESSION_NOT_ASSIGNABLE, | 5170 StaticWarningCode.SWITCH_EXPRESSION_NOT_ASSIGNABLE, |
| 5144 expression, | 5171 expression, |
| 5145 [expressionType, caseType]); | 5172 [expressionType, caseType]); |
| 5146 } | 5173 } |
| 5147 } | 5174 } |
| 5148 | 5175 |
| 5149 /** | 5176 /** |
| 5150 * Verify that the given function type [alias] does not reference itself | 5177 * Verify that the given function type [alias] does not reference itself |
| 5151 * directly. | 5178 * directly. |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5537 DartType impliedReturnType; | 5564 DartType impliedReturnType; |
| 5538 if (isYieldEach) { | 5565 if (isYieldEach) { |
| 5539 impliedReturnType = staticYieldedType; | 5566 impliedReturnType = staticYieldedType; |
| 5540 } else if (_enclosingFunction.isAsynchronous) { | 5567 } else if (_enclosingFunction.isAsynchronous) { |
| 5541 impliedReturnType = | 5568 impliedReturnType = |
| 5542 _typeProvider.streamType.instantiate(<DartType>[staticYieldedType]); | 5569 _typeProvider.streamType.instantiate(<DartType>[staticYieldedType]); |
| 5543 } else { | 5570 } else { |
| 5544 impliedReturnType = | 5571 impliedReturnType = |
| 5545 _typeProvider.iterableType.instantiate(<DartType>[staticYieldedType]); | 5572 _typeProvider.iterableType.instantiate(<DartType>[staticYieldedType]); |
| 5546 } | 5573 } |
| 5547 if (!_typeSystem.isAssignableTo(impliedReturnType, declaredReturnType)) { | 5574 if (!_checkForAssignableExpressionAtType(yieldExpression, impliedReturnType, |
| 5548 _errorReporter.reportTypeErrorForNode( | 5575 declaredReturnType, StaticTypeWarningCode.YIELD_OF_INVALID_TYPE)) { |
| 5549 StaticTypeWarningCode.YIELD_OF_INVALID_TYPE, | |
| 5550 yieldExpression, | |
| 5551 [impliedReturnType, declaredReturnType]); | |
| 5552 return; | 5576 return; |
| 5553 } | 5577 } |
| 5554 if (isYieldEach) { | 5578 if (isYieldEach) { |
| 5555 // Since the declared return type might have been "dynamic", we need to | 5579 // Since the declared return type might have been "dynamic", we need to |
| 5556 // also check that the implied return type is assignable to generic | 5580 // also check that the implied return type is assignable to generic |
| 5557 // Stream/Iterable. | 5581 // Stream/Iterable. |
| 5558 DartType requiredReturnType; | 5582 DartType requiredReturnType; |
| 5559 if (_enclosingFunction.isAsynchronous) { | 5583 if (_enclosingFunction.isAsynchronous) { |
| 5560 requiredReturnType = _typeProvider.streamDynamicType; | 5584 requiredReturnType = _typeProvider.streamDynamicType; |
| 5561 } else { | 5585 } else { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5655 for (Expression expression in args.arguments) { | 5679 for (Expression expression in args.arguments) { |
| 5656 if (expression is NamedExpression) { | 5680 if (expression is NamedExpression) { |
| 5657 if (expression.name.label.name == name) { | 5681 if (expression.name.label.name == name) { |
| 5658 return true; | 5682 return true; |
| 5659 } | 5683 } |
| 5660 } | 5684 } |
| 5661 } | 5685 } |
| 5662 return false; | 5686 return false; |
| 5663 } | 5687 } |
| 5664 | 5688 |
| 5689 bool _expressionIsAssignable( |
| 5690 Expression expression, DartType expectedStaticType) { |
| 5691 return _expressionIsAssignableAtType( |
| 5692 expression, getStaticType(expression), expectedStaticType); |
| 5693 } |
| 5694 |
| 5695 bool _expressionIsAssignableAtType(Expression expression, |
| 5696 DartType actualStaticType, DartType expectedStaticType) { |
| 5697 bool concrete = |
| 5698 _options.strongMode && StaticInfo.isKnownFunction(expression); |
| 5699 if (concrete) { |
| 5700 actualStaticType = |
| 5701 _typeSystem.typeToConcreteType(_typeProvider, actualStaticType); |
| 5702 // TODO(leafp): Move the Downcast functionality here. |
| 5703 // TODO(leafp): Support strict downcasts |
| 5704 } |
| 5705 return _typeSystem.isAssignableTo(actualStaticType, expectedStaticType); |
| 5706 } |
| 5707 |
| 5665 MethodElement _findOverriddenMemberThatMustCallSuper(MethodDeclaration node) { | 5708 MethodElement _findOverriddenMemberThatMustCallSuper(MethodDeclaration node) { |
| 5666 ExecutableElement overriddenMember = _getOverriddenMember(node.element); | 5709 ExecutableElement overriddenMember = _getOverriddenMember(node.element); |
| 5667 List<ExecutableElement> seen = <ExecutableElement>[]; | 5710 List<ExecutableElement> seen = <ExecutableElement>[]; |
| 5668 while ( | 5711 while ( |
| 5669 overriddenMember is MethodElement && !seen.contains(overriddenMember)) { | 5712 overriddenMember is MethodElement && !seen.contains(overriddenMember)) { |
| 5670 for (ElementAnnotation annotation in overriddenMember.metadata) { | 5713 for (ElementAnnotation annotation in overriddenMember.metadata) { |
| 5671 if (annotation.isMustCallSuper) { | 5714 if (annotation.isMustCallSuper) { |
| 5672 return overriddenMember; | 5715 return overriddenMember; |
| 5673 } | 5716 } |
| 5674 } | 5717 } |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6114 class _InvocationCollector extends RecursiveAstVisitor { | 6157 class _InvocationCollector extends RecursiveAstVisitor { |
| 6115 final List<String> superCalls = <String>[]; | 6158 final List<String> superCalls = <String>[]; |
| 6116 | 6159 |
| 6117 @override | 6160 @override |
| 6118 visitMethodInvocation(MethodInvocation node) { | 6161 visitMethodInvocation(MethodInvocation node) { |
| 6119 if (node.target is SuperExpression) { | 6162 if (node.target is SuperExpression) { |
| 6120 superCalls.add(node.methodName.name); | 6163 superCalls.add(node.methodName.name); |
| 6121 } | 6164 } |
| 6122 } | 6165 } |
| 6123 } | 6166 } |
| OLD | NEW |