| 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 engine.resolver.error_verifier; | 5 library engine.resolver.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/src/generated/static_type_analyzer.dart'; | 10 import 'package:analyzer/src/generated/static_type_analyzer.dart'; |
| (...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 852 _enclosingFunction = previousFunction; | 852 _enclosingFunction = previousFunction; |
| 853 _isInStaticMethod = false; | 853 _isInStaticMethod = false; |
| 854 } | 854 } |
| 855 } | 855 } |
| 856 | 856 |
| 857 @override | 857 @override |
| 858 Object visitMethodInvocation(MethodInvocation node) { | 858 Object visitMethodInvocation(MethodInvocation node) { |
| 859 Expression target = node.realTarget; | 859 Expression target = node.realTarget; |
| 860 SimpleIdentifier methodName = node.methodName; | 860 SimpleIdentifier methodName = node.methodName; |
| 861 if (target != null) { | 861 if (target != null) { |
| 862 bool isConditional = node.operator.type == sc.TokenType.QUESTION_PERIOD; | 862 ClassElement typeReference = ElementResolver.getTypeReference(target); |
| 863 ClassElement typeReference = | |
| 864 ElementResolver.getTypeReference(target, isConditional); | |
| 865 _checkForStaticAccessToInstanceMember(typeReference, methodName); | 863 _checkForStaticAccessToInstanceMember(typeReference, methodName); |
| 866 _checkForInstanceAccessToStaticMember(typeReference, methodName); | 864 _checkForInstanceAccessToStaticMember(typeReference, methodName); |
| 867 } else { | 865 } else { |
| 868 _checkForUnqualifiedReferenceToNonLocalStaticMember(methodName); | 866 _checkForUnqualifiedReferenceToNonLocalStaticMember(methodName); |
| 869 } | 867 } |
| 870 return super.visitMethodInvocation(node); | 868 return super.visitMethodInvocation(node); |
| 871 } | 869 } |
| 872 | 870 |
| 873 @override | 871 @override |
| 874 Object visitNativeClause(NativeClause node) { | 872 Object visitNativeClause(NativeClause node) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 891 Object visitPostfixExpression(PostfixExpression node) { | 889 Object visitPostfixExpression(PostfixExpression node) { |
| 892 _checkForAssignmentToFinal(node.operand); | 890 _checkForAssignmentToFinal(node.operand); |
| 893 _checkForIntNotAssignable(node.operand); | 891 _checkForIntNotAssignable(node.operand); |
| 894 return super.visitPostfixExpression(node); | 892 return super.visitPostfixExpression(node); |
| 895 } | 893 } |
| 896 | 894 |
| 897 @override | 895 @override |
| 898 Object visitPrefixedIdentifier(PrefixedIdentifier node) { | 896 Object visitPrefixedIdentifier(PrefixedIdentifier node) { |
| 899 if (node.parent is! Annotation) { | 897 if (node.parent is! Annotation) { |
| 900 ClassElement typeReference = | 898 ClassElement typeReference = |
| 901 ElementResolver.getTypeReference(node.prefix, false); | 899 ElementResolver.getTypeReference(node.prefix); |
| 902 SimpleIdentifier name = node.identifier; | 900 SimpleIdentifier name = node.identifier; |
| 903 _checkForStaticAccessToInstanceMember(typeReference, name); | 901 _checkForStaticAccessToInstanceMember(typeReference, name); |
| 904 _checkForInstanceAccessToStaticMember(typeReference, name); | 902 _checkForInstanceAccessToStaticMember(typeReference, name); |
| 905 } | 903 } |
| 906 return super.visitPrefixedIdentifier(node); | 904 return super.visitPrefixedIdentifier(node); |
| 907 } | 905 } |
| 908 | 906 |
| 909 @override | 907 @override |
| 910 Object visitPrefixExpression(PrefixExpression node) { | 908 Object visitPrefixExpression(PrefixExpression node) { |
| 911 sc.TokenType operatorType = node.operator.type; | 909 sc.TokenType operatorType = node.operator.type; |
| 912 Expression operand = node.operand; | 910 Expression operand = node.operand; |
| 913 if (operatorType == sc.TokenType.BANG) { | 911 if (operatorType == sc.TokenType.BANG) { |
| 914 _checkForNonBoolNegationExpression(operand); | 912 _checkForNonBoolNegationExpression(operand); |
| 915 } else if (operatorType.isIncrementOperator) { | 913 } else if (operatorType.isIncrementOperator) { |
| 916 _checkForAssignmentToFinal(operand); | 914 _checkForAssignmentToFinal(operand); |
| 917 } | 915 } |
| 918 _checkForIntNotAssignable(operand); | 916 _checkForIntNotAssignable(operand); |
| 919 return super.visitPrefixExpression(node); | 917 return super.visitPrefixExpression(node); |
| 920 } | 918 } |
| 921 | 919 |
| 922 @override | 920 @override |
| 923 Object visitPropertyAccess(PropertyAccess node) { | 921 Object visitPropertyAccess(PropertyAccess node) { |
| 924 bool isConditional = node.operator.type == sc.TokenType.QUESTION_PERIOD; | 922 bool isConditional = node.operator.type == sc.TokenType.QUESTION_PERIOD; |
| 925 ClassElement typeReference = | 923 ClassElement typeReference = |
| 926 ElementResolver.getTypeReference(node.realTarget, isConditional); | 924 ElementResolver.getTypeReference(node.realTarget); |
| 927 SimpleIdentifier propertyName = node.propertyName; | 925 SimpleIdentifier propertyName = node.propertyName; |
| 928 _checkForStaticAccessToInstanceMember(typeReference, propertyName); | 926 _checkForStaticAccessToInstanceMember(typeReference, propertyName); |
| 929 _checkForInstanceAccessToStaticMember(typeReference, propertyName); | 927 _checkForInstanceAccessToStaticMember(typeReference, propertyName); |
| 930 return super.visitPropertyAccess(node); | 928 return super.visitPropertyAccess(node); |
| 931 } | 929 } |
| 932 | 930 |
| 933 @override | 931 @override |
| 934 Object visitRedirectingConstructorInvocation( | 932 Object visitRedirectingConstructorInvocation( |
| 935 RedirectingConstructorInvocation node) { | 933 RedirectingConstructorInvocation node) { |
| 936 _isInConstructorInitializer = true; | 934 _isInConstructorInitializer = true; |
| (...skipping 5050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5987 toCheck.add(type.element); | 5985 toCheck.add(type.element); |
| 5988 // type arguments | 5986 // type arguments |
| 5989 if (type is InterfaceType) { | 5987 if (type is InterfaceType) { |
| 5990 InterfaceType interfaceType = type; | 5988 InterfaceType interfaceType = type; |
| 5991 for (DartType typeArgument in interfaceType.typeArguments) { | 5989 for (DartType typeArgument in interfaceType.typeArguments) { |
| 5992 _addTypeToCheck(typeArgument); | 5990 _addTypeToCheck(typeArgument); |
| 5993 } | 5991 } |
| 5994 } | 5992 } |
| 5995 } | 5993 } |
| 5996 } | 5994 } |
| OLD | NEW |