| Index: pkg/analyzer/lib/src/generated/error_verifier.dart
|
| diff --git a/pkg/analyzer/lib/src/generated/error_verifier.dart b/pkg/analyzer/lib/src/generated/error_verifier.dart
|
| index 0e15b058dcfbc56d01ba1aabaf5d835bf7730732..50513f74be7c9b4b34d9a864b80799d318001ad6 100644
|
| --- a/pkg/analyzer/lib/src/generated/error_verifier.dart
|
| +++ b/pkg/analyzer/lib/src/generated/error_verifier.dart
|
| @@ -1205,7 +1205,8 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| SimpleIdentifier nameNode = node.name;
|
| Expression initializerNode = node.initializer;
|
| // do checks
|
| - _checkForInvalidAssignment(nameNode, initializerNode);
|
| + _checkForInvalidAssignment(nameNode, initializerNode,
|
| + isDeclarationCast: true);
|
| _checkForImplicitDynamicIdentifier(node, nameNode);
|
| // visit name
|
| nameNode.accept(this);
|
| @@ -2504,20 +2505,24 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| }
|
|
|
| bool _checkForAssignableExpression(
|
| - Expression expression, DartType expectedStaticType, ErrorCode errorCode) {
|
| + Expression expression, DartType expectedStaticType, ErrorCode errorCode,
|
| + {bool isDeclarationCast = false}) {
|
| DartType actualStaticType = getStaticType(expression);
|
| return actualStaticType != null &&
|
| _checkForAssignableExpressionAtType(
|
| - expression, actualStaticType, expectedStaticType, errorCode);
|
| + expression, actualStaticType, expectedStaticType, errorCode,
|
| + isDeclarationCast: isDeclarationCast);
|
| }
|
|
|
| bool _checkForAssignableExpressionAtType(
|
| Expression expression,
|
| DartType actualStaticType,
|
| DartType expectedStaticType,
|
| - ErrorCode errorCode) {
|
| + ErrorCode errorCode,
|
| + {bool isDeclarationCast = false}) {
|
| if (!_expressionIsAssignableAtType(
|
| - expression, actualStaticType, expectedStaticType)) {
|
| + expression, actualStaticType, expectedStaticType,
|
| + isDeclarationCast: isDeclarationCast)) {
|
| _errorReporter.reportTypeErrorForNode(
|
| errorCode, expression, [actualStaticType, expectedStaticType]);
|
| return false;
|
| @@ -4272,7 +4277,8 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| StaticTypeWarningCode.FOR_IN_OF_INVALID_TYPE,
|
| node.iterable,
|
| [iterableType, loopTypeName]);
|
| - } else if (!_typeSystem.isAssignableTo(bestIterableType, variableType)) {
|
| + } else if (!_typeSystem.isAssignableTo(bestIterableType, variableType,
|
| + isDeclarationCast: true)) {
|
| _errorReporter.reportTypeErrorForNode(
|
| StaticTypeWarningCode.FOR_IN_OF_INVALID_ELEMENT_TYPE,
|
| node.iterable,
|
| @@ -4426,7 +4432,8 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| *
|
| * See [StaticTypeWarningCode.INVALID_ASSIGNMENT].
|
| */
|
| - void _checkForInvalidAssignment(Expression lhs, Expression rhs) {
|
| + void _checkForInvalidAssignment(Expression lhs, Expression rhs,
|
| + {bool isDeclarationCast = false}) {
|
| if (lhs == null || rhs == null) {
|
| return;
|
| }
|
| @@ -4435,7 +4442,8 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| ? getStaticType(lhs)
|
| : leftVariableElement.type;
|
| _checkForAssignableExpression(
|
| - rhs, leftType, StaticTypeWarningCode.INVALID_ASSIGNMENT);
|
| + rhs, leftType, StaticTypeWarningCode.INVALID_ASSIGNMENT,
|
| + isDeclarationCast: isDeclarationCast);
|
| }
|
|
|
| /**
|
| @@ -6318,13 +6326,15 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| }
|
|
|
| bool _expressionIsAssignableAtType(Expression expression,
|
| - DartType actualStaticType, DartType expectedStaticType) {
|
| + DartType actualStaticType, DartType expectedStaticType,
|
| + {isDeclarationCast: false}) {
|
| bool concrete = _options.strongMode && checker.hasStrictArrow(expression);
|
| if (concrete && actualStaticType is FunctionType) {
|
| actualStaticType =
|
| _typeSystem.functionTypeToConcreteType(actualStaticType);
|
| }
|
| - return _typeSystem.isAssignableTo(actualStaticType, expectedStaticType);
|
| + return _typeSystem.isAssignableTo(actualStaticType, expectedStaticType,
|
| + isDeclarationCast: isDeclarationCast);
|
| }
|
|
|
| MethodElement _findOverriddenMemberThatMustCallSuper(MethodDeclaration node) {
|
|
|