| 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/token.dart'; | 10 import 'package:analyzer/dart/ast/token.dart'; |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 _checkForMissingReturn(node.returnType, node.body); | 276 _checkForMissingReturn(node.returnType, node.body); |
| 277 _checkForUnnecessaryNoSuchMethod(node); | 277 _checkForUnnecessaryNoSuchMethod(node); |
| 278 return super.visitMethodDeclaration(node); | 278 return super.visitMethodDeclaration(node); |
| 279 } finally { | 279 } finally { |
| 280 inDeprecatedMember = wasInDeprecatedMember; | 280 inDeprecatedMember = wasInDeprecatedMember; |
| 281 } | 281 } |
| 282 } | 282 } |
| 283 | 283 |
| 284 @override | 284 @override |
| 285 Object visitMethodInvocation(MethodInvocation node) { | 285 Object visitMethodInvocation(MethodInvocation node) { |
| 286 Expression realTarget = node.realTarget; |
| 287 _checkForAbstractSuperMemberReference(realTarget, node.methodName); |
| 286 _checkForCanBeNullAfterNullAware( | 288 _checkForCanBeNullAfterNullAware( |
| 287 node.realTarget, node.operator, null, node.methodName); | 289 realTarget, node.operator, null, node.methodName); |
| 288 DartType staticInvokeType = node.staticInvokeType; | 290 DartType staticInvokeType = node.staticInvokeType; |
| 289 if (staticInvokeType is InterfaceType) { | 291 if (staticInvokeType is InterfaceType) { |
| 290 MethodElement methodElement = staticInvokeType.lookUpMethod( | 292 MethodElement methodElement = staticInvokeType.lookUpMethod( |
| 291 FunctionElement.CALL_METHOD_NAME, _currentLibrary); | 293 FunctionElement.CALL_METHOD_NAME, _currentLibrary); |
| 292 _checkForDeprecatedMemberUse(methodElement, node); | 294 _checkForDeprecatedMemberUse(methodElement, node); |
| 293 } | 295 } |
| 294 return super.visitMethodInvocation(node); | 296 return super.visitMethodInvocation(node); |
| 295 } | 297 } |
| 296 | 298 |
| 297 @override | 299 @override |
| 298 Object visitPostfixExpression(PostfixExpression node) { | 300 Object visitPostfixExpression(PostfixExpression node) { |
| 299 _checkForDeprecatedMemberUse(node.bestElement, node); | 301 _checkForDeprecatedMemberUse(node.bestElement, node); |
| 300 return super.visitPostfixExpression(node); | 302 return super.visitPostfixExpression(node); |
| 301 } | 303 } |
| 302 | 304 |
| 303 @override | 305 @override |
| 304 Object visitPrefixExpression(PrefixExpression node) { | 306 Object visitPrefixExpression(PrefixExpression node) { |
| 305 _checkForDeprecatedMemberUse(node.bestElement, node); | 307 _checkForDeprecatedMemberUse(node.bestElement, node); |
| 306 return super.visitPrefixExpression(node); | 308 return super.visitPrefixExpression(node); |
| 307 } | 309 } |
| 308 | 310 |
| 309 @override | 311 @override |
| 310 Object visitPropertyAccess(PropertyAccess node) { | 312 Object visitPropertyAccess(PropertyAccess node) { |
| 313 Expression realTarget = node.realTarget; |
| 314 _checkForAbstractSuperMemberReference(realTarget, node.propertyName); |
| 311 _checkForCanBeNullAfterNullAware( | 315 _checkForCanBeNullAfterNullAware( |
| 312 node.realTarget, node.operator, node.propertyName, null); | 316 realTarget, node.operator, node.propertyName, null); |
| 313 return super.visitPropertyAccess(node); | 317 return super.visitPropertyAccess(node); |
| 314 } | 318 } |
| 315 | 319 |
| 316 @override | 320 @override |
| 317 Object visitRedirectingConstructorInvocation( | 321 Object visitRedirectingConstructorInvocation( |
| 318 RedirectingConstructorInvocation node) { | 322 RedirectingConstructorInvocation node) { |
| 319 _checkForDeprecatedMemberUse(node.staticElement, node); | 323 _checkForDeprecatedMemberUse(node.staticElement, node); |
| 320 return super.visitRedirectingConstructorInvocation(node); | 324 return super.visitRedirectingConstructorInvocation(node); |
| 321 } | 325 } |
| 322 | 326 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 // the is not case | 406 // the is not case |
| 403 _errorReporter.reportErrorForNode( | 407 _errorReporter.reportErrorForNode( |
| 404 HintCode.TYPE_CHECK_IS_NOT_NULL, node); | 408 HintCode.TYPE_CHECK_IS_NOT_NULL, node); |
| 405 } | 409 } |
| 406 return true; | 410 return true; |
| 407 } | 411 } |
| 408 } | 412 } |
| 409 return false; | 413 return false; |
| 410 } | 414 } |
| 411 | 415 |
| 416 void _checkForAbstractSuperMemberReference( |
| 417 Expression target, SimpleIdentifier name) { |
| 418 if (target is SuperExpression) { |
| 419 Element element = name.staticElement; |
| 420 if (element is ExecutableElement && element.isAbstract) { |
| 421 _errorReporter.reportTypeErrorForNode( |
| 422 HintCode.ABSTRACT_SUPER_MEMBER_REFERENCE, |
| 423 name, |
| 424 [element.kind.displayName, name.name]); |
| 425 } |
| 426 } |
| 427 } |
| 428 |
| 412 /** | 429 /** |
| 413 * This verifies that the passed expression can be assigned to its correspondi
ng parameters. | 430 * This verifies that the passed expression can be assigned to its correspondi
ng parameters. |
| 414 * | 431 * |
| 415 * This method corresponds to ErrorVerifier.checkForArgumentTypeNotAssignable. | 432 * This method corresponds to ErrorVerifier.checkForArgumentTypeNotAssignable. |
| 416 * | 433 * |
| 417 * TODO (jwren) In the ErrorVerifier there are other warnings that we could ha
ve a corresponding | 434 * TODO (jwren) In the ErrorVerifier there are other warnings that we could ha
ve a corresponding |
| 418 * hint for: see other callers of ErrorVerifier.checkForArgumentTypeNotAssigna
ble(..). | 435 * hint for: see other callers of ErrorVerifier.checkForArgumentTypeNotAssigna
ble(..). |
| 419 * | 436 * |
| 420 * @param expression the expression to evaluate | 437 * @param expression the expression to evaluate |
| 421 * @param expectedStaticType the expected static type of the parameter | 438 * @param expectedStaticType the expected static type of the parameter |
| (...skipping 6854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7276 DartType contextType = node.staticInvokeType; | 7293 DartType contextType = node.staticInvokeType; |
| 7277 if (contextType is FunctionType) { | 7294 if (contextType is FunctionType) { |
| 7278 DartType originalType = node.function.staticType; | 7295 DartType originalType = node.function.staticType; |
| 7279 DartType returnContextType = InferenceContext.getContext(node); | 7296 DartType returnContextType = InferenceContext.getContext(node); |
| 7280 TypeSystem ts = typeSystem; | 7297 TypeSystem ts = typeSystem; |
| 7281 if (returnContextType != null && | 7298 if (returnContextType != null && |
| 7282 node.typeArguments == null && | 7299 node.typeArguments == null && |
| 7283 originalType is FunctionType && | 7300 originalType is FunctionType && |
| 7284 originalType.typeFormals.isNotEmpty && | 7301 originalType.typeFormals.isNotEmpty && |
| 7285 ts is StrongTypeSystemImpl) { | 7302 ts is StrongTypeSystemImpl) { |
| 7286 contextType = ts.inferGenericFunctionCall(typeProvider, originalType, | 7303 contextType = ts.inferGenericFunctionCall( |
| 7287 DartType.EMPTY_LIST, DartType.EMPTY_LIST, originalType.returnType, r
eturnContextType); | 7304 typeProvider, |
| 7305 originalType, |
| 7306 DartType.EMPTY_LIST, |
| 7307 DartType.EMPTY_LIST, |
| 7308 originalType.returnType, |
| 7309 returnContextType); |
| 7288 } | 7310 } |
| 7289 | 7311 |
| 7290 InferenceContext.setType(node.argumentList, contextType); | 7312 InferenceContext.setType(node.argumentList, contextType); |
| 7291 } | 7313 } |
| 7292 } | 7314 } |
| 7293 | 7315 |
| 7294 void _inferFormalParameterList(FormalParameterList node, DartType type) { | 7316 void _inferFormalParameterList(FormalParameterList node, DartType type) { |
| 7295 if (typeAnalyzer.inferFormalParameterList(node, type)) { | 7317 if (typeAnalyzer.inferFormalParameterList(node, type)) { |
| 7296 // TODO(leafp): This gets dropped on the floor if we're in the field | 7318 // TODO(leafp): This gets dropped on the floor if we're in the field |
| 7297 // inference task. We should probably keep these infos. | 7319 // inference task. We should probably keep these infos. |
| (...skipping 3894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11192 return null; | 11214 return null; |
| 11193 } | 11215 } |
| 11194 if (identical(node.staticElement, variable)) { | 11216 if (identical(node.staticElement, variable)) { |
| 11195 if (node.inSetterContext()) { | 11217 if (node.inSetterContext()) { |
| 11196 result = true; | 11218 result = true; |
| 11197 } | 11219 } |
| 11198 } | 11220 } |
| 11199 return null; | 11221 return null; |
| 11200 } | 11222 } |
| 11201 } | 11223 } |
| OLD | NEW |