| 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 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
| 6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
| 7 | 7 |
| 8 library engine.resolver; | 8 library engine.resolver; |
| 9 | 9 |
| 10 import 'dart:collection'; | 10 import 'dart:collection'; |
| (...skipping 2248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2259 /** | 2259 /** |
| 2260 * Create a new instance of the [BestPracticesVerifier]. | 2260 * Create a new instance of the [BestPracticesVerifier]. |
| 2261 * | 2261 * |
| 2262 * @param errorReporter the error reporter | 2262 * @param errorReporter the error reporter |
| 2263 */ | 2263 */ |
| 2264 BestPracticesVerifier(ErrorReporter errorReporter) { | 2264 BestPracticesVerifier(ErrorReporter errorReporter) { |
| 2265 this._errorReporter = errorReporter; | 2265 this._errorReporter = errorReporter; |
| 2266 } | 2266 } |
| 2267 | 2267 |
| 2268 @override | 2268 @override |
| 2269 Object visitArgumentList(ArgumentList node) { |
| 2270 _checkForArgumentTypesNotAssignableInList(node); |
| 2271 return super.visitArgumentList(node); |
| 2272 } |
| 2273 |
| 2274 @override |
| 2269 Object visitAsExpression(AsExpression node) { | 2275 Object visitAsExpression(AsExpression node) { |
| 2270 _checkForUnnecessaryCast(node); | 2276 _checkForUnnecessaryCast(node); |
| 2271 return super.visitAsExpression(node); | 2277 return super.visitAsExpression(node); |
| 2272 } | 2278 } |
| 2273 | 2279 |
| 2274 @override | 2280 @override |
| 2275 Object visitAssignmentExpression(AssignmentExpression node) { | 2281 Object visitAssignmentExpression(AssignmentExpression node) { |
| 2276 sc.TokenType operatorType = node.operator.type; | 2282 sc.TokenType operatorType = node.operator.type; |
| 2277 if (operatorType != sc.TokenType.EQ) { | 2283 if (operatorType != sc.TokenType.EQ) { |
| 2278 _checkForDeprecatedMemberUse(node.bestElement, node); | 2284 _checkForDeprecatedMemberUse(node.bestElement, node); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2434 // the is not case | 2440 // the is not case |
| 2435 _errorReporter.reportErrorForNode(HintCode.TYPE_CHECK_IS_NOT_NULL, nod
e, []); | 2441 _errorReporter.reportErrorForNode(HintCode.TYPE_CHECK_IS_NOT_NULL, nod
e, []); |
| 2436 } | 2442 } |
| 2437 return true; | 2443 return true; |
| 2438 } | 2444 } |
| 2439 } | 2445 } |
| 2440 return false; | 2446 return false; |
| 2441 } | 2447 } |
| 2442 | 2448 |
| 2443 /** | 2449 /** |
| 2450 * This verifies that the passed expression can be assigned to its correspondi
ng parameters. |
| 2451 * |
| 2452 * This method corresponds to ErrorVerifier.checkForArgumentTypeNotAssignable. |
| 2453 * |
| 2454 * TODO (jwren) In the ErrorVerifier there are other warnings that we could ha
ve a corresponding |
| 2455 * hint for: see other callers of ErrorVerifier.checkForArgumentTypeNotAssigna
ble(..). |
| 2456 * |
| 2457 * @param expression the expression to evaluate |
| 2458 * @param expectedStaticType the expected static type of the parameter |
| 2459 * @param actualStaticType the actual static type of the argument |
| 2460 * @param expectedPropagatedType the expected propagated type of the parameter
, may be |
| 2461 * `null` |
| 2462 * @param actualPropagatedType the expected propagated type of the parameter,
may be `null` |
| 2463 * @return `true` if and only if an hint code is generated on the passed node |
| 2464 * @see HintCode#ARGUMENT_TYPE_NOT_ASSIGNABLE |
| 2465 */ |
| 2466 bool _checkForArgumentTypeNotAssignable(Expression expression, DartType expect
edStaticType, DartType actualStaticType, DartType expectedPropagatedType, DartTy
pe actualPropagatedType, ErrorCode hintCode) { |
| 2467 // |
| 2468 // Warning case: test static type information |
| 2469 // |
| 2470 if (actualStaticType != null && expectedStaticType != null) { |
| 2471 if (!actualStaticType.isAssignableTo(expectedStaticType)) { |
| 2472 // A warning was created in the ErrorVerifier, return false, don't creat
e a hint when a |
| 2473 // warning has already been created. |
| 2474 return false; |
| 2475 } |
| 2476 } |
| 2477 // |
| 2478 // Hint case: test propagated type information |
| 2479 // |
| 2480 // Compute the best types to use. |
| 2481 DartType expectedBestType = expectedPropagatedType != null ? expectedPropaga
tedType : expectedStaticType; |
| 2482 DartType actualBestType = actualPropagatedType != null ? actualPropagatedTyp
e : actualStaticType; |
| 2483 if (actualBestType != null && expectedBestType != null) { |
| 2484 if (!actualBestType.isAssignableTo(expectedBestType)) { |
| 2485 _errorReporter.reportErrorForNode(hintCode, expression, [actualBestType.
displayName, expectedBestType.displayName]); |
| 2486 return true; |
| 2487 } |
| 2488 } |
| 2489 return false; |
| 2490 } |
| 2491 |
| 2492 /** |
| 2493 * This verifies that the passed argument can be assigned to its corresponding
parameter. |
| 2494 * |
| 2495 * This method corresponds to ErrorCode.checkForArgumentTypeNotAssignableForAr
gument. |
| 2496 * |
| 2497 * @param argument the argument to evaluate |
| 2498 * @return `true` if and only if an hint code is generated on the passed node |
| 2499 * @see HintCode#ARGUMENT_TYPE_NOT_ASSIGNABLE |
| 2500 */ |
| 2501 bool _checkForArgumentTypeNotAssignableForArgument(Expression argument) { |
| 2502 if (argument == null) { |
| 2503 return false; |
| 2504 } |
| 2505 ParameterElement staticParameterElement = argument.staticParameterElement; |
| 2506 DartType staticParameterType = staticParameterElement == null ? null : stati
cParameterElement.type; |
| 2507 ParameterElement propagatedParameterElement = argument.propagatedParameterEl
ement; |
| 2508 DartType propagatedParameterType = propagatedParameterElement == null ? null
: propagatedParameterElement.type; |
| 2509 return _checkForArgumentTypeNotAssignableWithExpectedTypes(argument, staticP
arameterType, propagatedParameterType, HintCode.ARGUMENT_TYPE_NOT_ASSIGNABLE); |
| 2510 } |
| 2511 |
| 2512 /** |
| 2513 * This verifies that the passed expression can be assigned to its correspondi
ng parameters. |
| 2514 * |
| 2515 * This method corresponds to ErrorCode.checkForArgumentTypeNotAssignableWithE
xpectedTypes. |
| 2516 * |
| 2517 * @param expression the expression to evaluate |
| 2518 * @param expectedStaticType the expected static type |
| 2519 * @param expectedPropagatedType the expected propagated type, may be `null` |
| 2520 * @return `true` if and only if an hint code is generated on the passed node |
| 2521 * @see HintCode#ARGUMENT_TYPE_NOT_ASSIGNABLE |
| 2522 */ |
| 2523 bool _checkForArgumentTypeNotAssignableWithExpectedTypes(Expression expression
, DartType expectedStaticType, DartType expectedPropagatedType, ErrorCode errorC
ode) => _checkForArgumentTypeNotAssignable(expression, expectedStaticType, expre
ssion.staticType, expectedPropagatedType, expression.propagatedType, errorCode); |
| 2524 |
| 2525 /** |
| 2526 * This verifies that the passed arguments can be assigned to their correspond
ing parameters. |
| 2527 * |
| 2528 * This method corresponds to ErrorCode.checkForArgumentTypesNotAssignableInLi
st. |
| 2529 * |
| 2530 * @param node the arguments to evaluate |
| 2531 * @return `true` if and only if an hint code is generated on the passed node |
| 2532 * @see HintCode#ARGUMENT_TYPE_NOT_ASSIGNABLE |
| 2533 */ |
| 2534 bool _checkForArgumentTypesNotAssignableInList(ArgumentList argumentList) { |
| 2535 if (argumentList == null) { |
| 2536 return false; |
| 2537 } |
| 2538 bool problemReported = false; |
| 2539 for (Expression argument in argumentList.arguments) { |
| 2540 problemReported = javaBooleanOr(problemReported, _checkForArgumentTypeNotA
ssignableForArgument(argument)); |
| 2541 } |
| 2542 return problemReported; |
| 2543 } |
| 2544 |
| 2545 /** |
| 2444 * Given some [Element], look at the associated metadata and report the use of
the member if | 2546 * Given some [Element], look at the associated metadata and report the use of
the member if |
| 2445 * it is declared as deprecated. | 2547 * it is declared as deprecated. |
| 2446 * | 2548 * |
| 2447 * @param element some element to check for deprecated use of | 2549 * @param element some element to check for deprecated use of |
| 2448 * @param node the node use for the location of the error | 2550 * @param node the node use for the location of the error |
| 2449 * @return `true` if and only if a hint code is generated on the passed node | 2551 * @return `true` if and only if a hint code is generated on the passed node |
| 2450 * @see HintCode#DEPRECATED_MEMBER_USE | 2552 * @see HintCode#DEPRECATED_MEMBER_USE |
| 2451 */ | 2553 */ |
| 2452 bool _checkForDeprecatedMemberUse(Element element, AstNode node) { | 2554 bool _checkForDeprecatedMemberUse(Element element, AstNode node) { |
| 2453 if (element != null && element.isDeprecated) { | 2555 if (element != null && element.isDeprecated) { |
| (...skipping 9415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11869 | 11971 |
| 11870 /** | 11972 /** |
| 11871 * The given expression is the expression used to compute the iterator for a f
or-each statement. | 11973 * The given expression is the expression used to compute the iterator for a f
or-each statement. |
| 11872 * Attempt to compute the type of objects that will be assigned to the loop va
riable and return | 11974 * Attempt to compute the type of objects that will be assigned to the loop va
riable and return |
| 11873 * that type. Return `null` if the type could not be determined. | 11975 * that type. Return `null` if the type could not be determined. |
| 11874 * | 11976 * |
| 11875 * @param iterator the iterator for a for-each statement | 11977 * @param iterator the iterator for a for-each statement |
| 11876 * @return the type of objects that will be assigned to the loop variable | 11978 * @return the type of objects that will be assigned to the loop variable |
| 11877 */ | 11979 */ |
| 11878 DartType _getIteratorElementType(Expression iteratorExpression) { | 11980 DartType _getIteratorElementType(Expression iteratorExpression) { |
| 11879 DartType expressionType = iteratorExpression.staticType; | 11981 DartType expressionType = iteratorExpression.bestType; |
| 11880 if (expressionType is InterfaceType) { | 11982 if (expressionType is InterfaceType) { |
| 11881 InterfaceType interfaceType = expressionType; | 11983 InterfaceType interfaceType = expressionType; |
| 11882 FunctionType iteratorFunction = _inheritanceManager.lookupMemberType(inter
faceType, "iterator"); | 11984 FunctionType iteratorFunction = _inheritanceManager.lookupMemberType(inter
faceType, "iterator"); |
| 11883 if (iteratorFunction == null) { | 11985 if (iteratorFunction == null) { |
| 11884 // TODO(brianwilkerson) Should we report this error? | 11986 // TODO(brianwilkerson) Should we report this error? |
| 11885 return null; | 11987 return null; |
| 11886 } | 11988 } |
| 11887 DartType iteratorType = iteratorFunction.returnType; | 11989 DartType iteratorType = iteratorFunction.returnType; |
| 11888 if (iteratorType is InterfaceType) { | 11990 if (iteratorType is InterfaceType) { |
| 11889 InterfaceType iteratorInterfaceType = iteratorType; | 11991 InterfaceType iteratorInterfaceType = iteratorType; |
| (...skipping 7667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19557 } else { | 19659 } else { |
| 19558 _exportedElements[name] = element; | 19660 _exportedElements[name] = element; |
| 19559 } | 19661 } |
| 19560 } | 19662 } |
| 19561 return false; | 19663 return false; |
| 19562 } | 19664 } |
| 19563 | 19665 |
| 19564 /** | 19666 /** |
| 19565 * This verifies that the passed expression can be assigned to its correspondi
ng parameters. | 19667 * This verifies that the passed expression can be assigned to its correspondi
ng parameters. |
| 19566 * | 19668 * |
| 19669 * This method corresponds to BestPracticesVerifier.checkForArgumentTypeNotAss
ignable. |
| 19670 * |
| 19567 * @param expression the expression to evaluate | 19671 * @param expression the expression to evaluate |
| 19568 * @param expectedStaticType the expected static type of the parameter | 19672 * @param expectedStaticType the expected static type of the parameter |
| 19569 * @param actualStaticType the actual static type of the argument | 19673 * @param actualStaticType the actual static type of the argument |
| 19570 * @param expectedPropagatedType the expected propagated type of the parameter
, may be | 19674 * @param expectedPropagatedType the expected propagated type of the parameter
, may be |
| 19571 * `null` | 19675 * `null` |
| 19572 * @param actualPropagatedType the expected propagated type of the parameter,
may be `null` | 19676 * @param actualPropagatedType the expected propagated type of the parameter,
may be `null` |
| 19573 * @return `true` if and only if an error code is generated on the passed node | 19677 * @return `true` if and only if an error code is generated on the passed node |
| 19574 * @see StaticWarningCode#ARGUMENT_TYPE_NOT_ASSIGNABLE | 19678 * @see StaticWarningCode#ARGUMENT_TYPE_NOT_ASSIGNABLE |
| 19679 * @see CompileTimeErrorCode#LIST_ELEMENT_TYPE_NOT_ASSIGNABLE |
| 19680 * @see StaticWarningCode#LIST_ELEMENT_TYPE_NOT_ASSIGNABLE |
| 19681 * @see CompileTimeErrorCode#MAP_KEY_TYPE_NOT_ASSIGNABLE |
| 19682 * @see CompileTimeErrorCode#MAP_VALUE_TYPE_NOT_ASSIGNABLE |
| 19683 * @see StaticWarningCode#MAP_KEY_TYPE_NOT_ASSIGNABLE |
| 19684 * @see StaticWarningCode#MAP_VALUE_TYPE_NOT_ASSIGNABLE |
| 19575 */ | 19685 */ |
| 19576 bool _checkForArgumentTypeNotAssignable(Expression expression, DartType expect
edStaticType, DartType actualStaticType, DartType expectedPropagatedType, DartTy
pe actualPropagatedType, ErrorCode errorCode) { | 19686 bool _checkForArgumentTypeNotAssignable(Expression expression, DartType expect
edStaticType, DartType actualStaticType, ErrorCode errorCode) { |
| 19577 // | 19687 // |
| 19578 // Test static type information | 19688 // Warning case: test static type information |
| 19579 // | 19689 // |
| 19580 if (actualStaticType == null || expectedStaticType == null) { | 19690 if (actualStaticType != null && expectedStaticType != null) { |
| 19581 return false; | 19691 if (!actualStaticType.isAssignableTo(expectedStaticType)) { |
| 19692 _errorReporter.reportErrorForNode(errorCode, expression, [ |
| 19693 actualStaticType.displayName, |
| 19694 expectedStaticType.displayName]); |
| 19695 return true; |
| 19696 } |
| 19582 } | 19697 } |
| 19583 if (actualStaticType.isAssignableTo(expectedStaticType)) { | 19698 return false; |
| 19584 return false; | |
| 19585 } | |
| 19586 _errorReporter.reportErrorForNode(errorCode, expression, [ | |
| 19587 actualStaticType.displayName, | |
| 19588 expectedStaticType.displayName]); | |
| 19589 return true; | |
| 19590 } | 19699 } |
| 19591 | 19700 |
| 19592 /** | 19701 /** |
| 19593 * This verifies that the passed argument can be assigned to its corresponding
parameter. | 19702 * This verifies that the passed argument can be assigned to its corresponding
parameter. |
| 19594 * | 19703 * |
| 19704 * This method corresponds to BestPracticesVerifier.checkForArgumentTypeNotAss
ignableForArgument. |
| 19705 * |
| 19595 * @param argument the argument to evaluate | 19706 * @param argument the argument to evaluate |
| 19596 * @return `true` if and only if an error code is generated on the passed node | 19707 * @return `true` if and only if an error code is generated on the passed node |
| 19597 * @see StaticWarningCode#ARGUMENT_TYPE_NOT_ASSIGNABLE | 19708 * @see StaticWarningCode#ARGUMENT_TYPE_NOT_ASSIGNABLE |
| 19598 */ | 19709 */ |
| 19599 bool _checkForArgumentTypeNotAssignableForArgument(Expression argument) { | 19710 bool _checkForArgumentTypeNotAssignableForArgument(Expression argument) { |
| 19600 if (argument == null) { | 19711 if (argument == null) { |
| 19601 return false; | 19712 return false; |
| 19602 } | 19713 } |
| 19603 ParameterElement staticParameterElement = argument.staticParameterElement; | 19714 ParameterElement staticParameterElement = argument.staticParameterElement; |
| 19604 DartType staticParameterType = staticParameterElement == null ? null : stati
cParameterElement.type; | 19715 DartType staticParameterType = staticParameterElement == null ? null : stati
cParameterElement.type; |
| 19605 ParameterElement propagatedParameterElement = argument.propagatedParameterEl
ement; | 19716 return _checkForArgumentTypeNotAssignableWithExpectedTypes(argument, staticP
arameterType, StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE); |
| 19606 DartType propagatedParameterType = propagatedParameterElement == null ? null
: propagatedParameterElement.type; | |
| 19607 return _checkForArgumentTypeNotAssignableWithExpectedTypes(argument, staticP
arameterType, propagatedParameterType, StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIG
NABLE); | |
| 19608 } | 19717 } |
| 19609 | 19718 |
| 19610 /** | 19719 /** |
| 19611 * This verifies that the passed expression can be assigned to its correspondi
ng parameters. | 19720 * This verifies that the passed expression can be assigned to its correspondi
ng parameters. |
| 19612 * | 19721 * |
| 19722 * This method corresponds to |
| 19723 * BestPracticesVerifier.checkForArgumentTypeNotAssignableWithExpectedTypes. |
| 19724 * |
| 19613 * @param expression the expression to evaluate | 19725 * @param expression the expression to evaluate |
| 19614 * @param expectedStaticType the expected static type | 19726 * @param expectedStaticType the expected static type |
| 19615 * @param expectedPropagatedType the expected propagated type, may be `null` | 19727 * @param expectedPropagatedType the expected propagated type, may be `null` |
| 19616 * @return `true` if and only if an error code is generated on the passed node | 19728 * @return `true` if and only if an error code is generated on the passed node |
| 19617 * @see StaticWarningCode#ARGUMENT_TYPE_NOT_ASSIGNABLE | 19729 * @see StaticWarningCode#ARGUMENT_TYPE_NOT_ASSIGNABLE |
| 19730 * @see CompileTimeErrorCode#LIST_ELEMENT_TYPE_NOT_ASSIGNABLE |
| 19731 * @see StaticWarningCode#LIST_ELEMENT_TYPE_NOT_ASSIGNABLE |
| 19732 * @see CompileTimeErrorCode#MAP_KEY_TYPE_NOT_ASSIGNABLE |
| 19733 * @see CompileTimeErrorCode#MAP_VALUE_TYPE_NOT_ASSIGNABLE |
| 19734 * @see StaticWarningCode#MAP_KEY_TYPE_NOT_ASSIGNABLE |
| 19735 * @see StaticWarningCode#MAP_VALUE_TYPE_NOT_ASSIGNABLE |
| 19618 */ | 19736 */ |
| 19619 bool _checkForArgumentTypeNotAssignableWithExpectedTypes(Expression expression
, DartType expectedStaticType, DartType expectedPropagatedType, ErrorCode errorC
ode) => _checkForArgumentTypeNotAssignable(expression, expectedStaticType, _getS
taticType(expression), expectedPropagatedType, expression.propagatedType, errorC
ode); | 19737 bool _checkForArgumentTypeNotAssignableWithExpectedTypes(Expression expression
, DartType expectedStaticType, ErrorCode errorCode) => _checkForArgumentTypeNotA
ssignable(expression, expectedStaticType, _getStaticType(expression), errorCode)
; |
| 19620 | 19738 |
| 19621 /** | 19739 /** |
| 19622 * This verifies that the passed arguments can be assigned to their correspond
ing parameters. | 19740 * This verifies that the passed arguments can be assigned to their correspond
ing parameters. |
| 19623 * | 19741 * |
| 19742 * This method corresponds to BestPracticesVerifier.checkForArgumentTypesNotAs
signableInList. |
| 19743 * |
| 19624 * @param node the arguments to evaluate | 19744 * @param node the arguments to evaluate |
| 19625 * @return `true` if and only if an error code is generated on the passed node | 19745 * @return `true` if and only if an error code is generated on the passed node |
| 19626 * @see StaticWarningCode#ARGUMENT_TYPE_NOT_ASSIGNABLE | 19746 * @see StaticWarningCode#ARGUMENT_TYPE_NOT_ASSIGNABLE |
| 19627 */ | 19747 */ |
| 19628 bool _checkForArgumentTypesNotAssignableInList(ArgumentList argumentList) { | 19748 bool _checkForArgumentTypesNotAssignableInList(ArgumentList argumentList) { |
| 19629 if (argumentList == null) { | 19749 if (argumentList == null) { |
| 19630 return false; | 19750 return false; |
| 19631 } | 19751 } |
| 19632 bool problemReported = false; | 19752 bool problemReported = false; |
| 19633 for (Expression argument in argumentList.arguments) { | 19753 for (Expression argument in argumentList.arguments) { |
| 19634 problemReported = javaBooleanOr(problemReported, _checkForArgumentTypeNotA
ssignableForArgument(argument)); | 19754 problemReported = javaBooleanOr(problemReported, _checkForArgumentTypeNotA
ssignableForArgument(argument)); |
| 19635 } | 19755 } |
| 19636 // done | |
| 19637 return problemReported; | 19756 return problemReported; |
| 19638 } | 19757 } |
| 19639 | 19758 |
| 19640 /** | 19759 /** |
| 19641 * This verifies that the passed expression is not final. | 19760 * This verifies that the passed expression is not final. |
| 19642 * | 19761 * |
| 19643 * @param node the expression to evaluate | 19762 * @param node the expression to evaluate |
| 19644 * @return `true` if and only if an error code is generated on the passed node | 19763 * @return `true` if and only if an error code is generated on the passed node |
| 19645 * @see StaticWarningCode#ASSIGNMENT_TO_CONST | 19764 * @see StaticWarningCode#ASSIGNMENT_TO_CONST |
| 19646 * @see StaticWarningCode#ASSIGNMENT_TO_FINAL | 19765 * @see StaticWarningCode#ASSIGNMENT_TO_FINAL |
| (...skipping 1401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 21048 * @param argument the expression to which the operator is being applied | 21167 * @param argument the expression to which the operator is being applied |
| 21049 * @return `true` if and only if an error code is generated on the passed node | 21168 * @return `true` if and only if an error code is generated on the passed node |
| 21050 * @see StaticWarningCode#ARGUMENT_TYPE_NOT_ASSIGNABLE | 21169 * @see StaticWarningCode#ARGUMENT_TYPE_NOT_ASSIGNABLE |
| 21051 */ | 21170 */ |
| 21052 bool _checkForIntNotAssignable(Expression argument) { | 21171 bool _checkForIntNotAssignable(Expression argument) { |
| 21053 if (argument == null) { | 21172 if (argument == null) { |
| 21054 return false; | 21173 return false; |
| 21055 } | 21174 } |
| 21056 ParameterElement staticParameterElement = argument.staticParameterElement; | 21175 ParameterElement staticParameterElement = argument.staticParameterElement; |
| 21057 DartType staticParameterType = staticParameterElement == null ? null : stati
cParameterElement.type; | 21176 DartType staticParameterType = staticParameterElement == null ? null : stati
cParameterElement.type; |
| 21058 ParameterElement propagatedParameterElement = argument.propagatedParameterEl
ement; | 21177 return _checkForArgumentTypeNotAssignable(argument, staticParameterType, _in
tType, StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE); |
| 21059 DartType propagatedParameterType = propagatedParameterElement == null ? null
: propagatedParameterElement.type; | |
| 21060 return _checkForArgumentTypeNotAssignable(argument, staticParameterType, _in
tType, propagatedParameterType, _intType, StaticWarningCode.ARGUMENT_TYPE_NOT_AS
SIGNABLE); | |
| 21061 } | 21178 } |
| 21062 | 21179 |
| 21063 /** | 21180 /** |
| 21064 * This verifies that the passed left hand side and right hand side represent
a valid assignment. | 21181 * This verifies that the passed left hand side and right hand side represent
a valid assignment. |
| 21065 * | 21182 * |
| 21066 * @param lhs the left hand side expression | 21183 * @param lhs the left hand side expression |
| 21067 * @param rhs the right hand side expression | 21184 * @param rhs the right hand side expression |
| 21068 * @return `true` if and only if an error code is generated on the passed node | 21185 * @return `true` if and only if an error code is generated on the passed node |
| 21069 * @see StaticTypeWarningCode#INVALID_ASSIGNMENT | 21186 * @see StaticTypeWarningCode#INVALID_ASSIGNMENT |
| 21070 */ | 21187 */ |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 21216 // Prepare problem to report. | 21333 // Prepare problem to report. |
| 21217 ErrorCode errorCode; | 21334 ErrorCode errorCode; |
| 21218 if (node.constKeyword != null) { | 21335 if (node.constKeyword != null) { |
| 21219 errorCode = CompileTimeErrorCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE; | 21336 errorCode = CompileTimeErrorCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE; |
| 21220 } else { | 21337 } else { |
| 21221 errorCode = StaticWarningCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE; | 21338 errorCode = StaticWarningCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE; |
| 21222 } | 21339 } |
| 21223 // Check every list element. | 21340 // Check every list element. |
| 21224 bool hasProblems = false; | 21341 bool hasProblems = false; |
| 21225 for (Expression element in node.elements) { | 21342 for (Expression element in node.elements) { |
| 21226 hasProblems = javaBooleanOr(hasProblems, _checkForArgumentTypeNotAssignabl
eWithExpectedTypes(element, listElementType, null, errorCode)); | 21343 hasProblems = javaBooleanOr(hasProblems, _checkForArgumentTypeNotAssignabl
eWithExpectedTypes(element, listElementType, errorCode)); |
| 21227 } | 21344 } |
| 21228 return hasProblems; | 21345 return hasProblems; |
| 21229 } | 21346 } |
| 21230 | 21347 |
| 21231 /** | 21348 /** |
| 21232 * This verifies that the key/value of entries of the given [MapLiteral] are s
ubtypes of the | 21349 * This verifies that the key/value of entries of the given [MapLiteral] are s
ubtypes of the |
| 21233 * key/value types specified in the type arguments. | 21350 * key/value types specified in the type arguments. |
| 21234 * | 21351 * |
| 21235 * @param node the map literal to evaluate | 21352 * @param node the map literal to evaluate |
| 21236 * @return `true` if and only if an error code is generated on the passed node | 21353 * @return `true` if and only if an error code is generated on the passed node |
| (...skipping 23 matching lines...) Expand all Loading... |
| 21260 } else { | 21377 } else { |
| 21261 keyErrorCode = StaticWarningCode.MAP_KEY_TYPE_NOT_ASSIGNABLE; | 21378 keyErrorCode = StaticWarningCode.MAP_KEY_TYPE_NOT_ASSIGNABLE; |
| 21262 valueErrorCode = StaticWarningCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE; | 21379 valueErrorCode = StaticWarningCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE; |
| 21263 } | 21380 } |
| 21264 // Check every map entry. | 21381 // Check every map entry. |
| 21265 bool hasProblems = false; | 21382 bool hasProblems = false; |
| 21266 NodeList<MapLiteralEntry> entries = node.entries; | 21383 NodeList<MapLiteralEntry> entries = node.entries; |
| 21267 for (MapLiteralEntry entry in entries) { | 21384 for (MapLiteralEntry entry in entries) { |
| 21268 Expression key = entry.key; | 21385 Expression key = entry.key; |
| 21269 Expression value = entry.value; | 21386 Expression value = entry.value; |
| 21270 hasProblems = javaBooleanOr(hasProblems, _checkForArgumentTypeNotAssignabl
eWithExpectedTypes(key, keyType, null, keyErrorCode)); | 21387 hasProblems = javaBooleanOr(hasProblems, _checkForArgumentTypeNotAssignabl
eWithExpectedTypes(key, keyType, keyErrorCode)); |
| 21271 hasProblems = javaBooleanOr(hasProblems, _checkForArgumentTypeNotAssignabl
eWithExpectedTypes(value, valueType, null, valueErrorCode)); | 21388 hasProblems = javaBooleanOr(hasProblems, _checkForArgumentTypeNotAssignabl
eWithExpectedTypes(value, valueType, valueErrorCode)); |
| 21272 } | 21389 } |
| 21273 return hasProblems; | 21390 return hasProblems; |
| 21274 } | 21391 } |
| 21275 | 21392 |
| 21276 /** | 21393 /** |
| 21277 * This verifies that the [enclosingClass] does not define members with the sa
me name as | 21394 * This verifies that the [enclosingClass] does not define members with the sa
me name as |
| 21278 * the enclosing class. | 21395 * the enclosing class. |
| 21279 * | 21396 * |
| 21280 * @return `true` if and only if an error code is generated on the passed node | 21397 * @return `true` if and only if an error code is generated on the passed node |
| 21281 * @see CompileTimeErrorCode#MEMBER_WITH_CLASS_NAME | 21398 * @see CompileTimeErrorCode#MEMBER_WITH_CLASS_NAME |
| (...skipping 1763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 23045 this.message = message; | 23162 this.message = message; |
| 23046 this.correction9 = correction; | 23163 this.correction9 = correction; |
| 23047 } | 23164 } |
| 23048 | 23165 |
| 23049 @override | 23166 @override |
| 23050 String get correction => correction9; | 23167 String get correction => correction9; |
| 23051 | 23168 |
| 23052 @override | 23169 @override |
| 23053 ErrorSeverity get errorSeverity => type.severity; | 23170 ErrorSeverity get errorSeverity => type.severity; |
| 23054 } | 23171 } |
| OLD | NEW |