| 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'; |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 _checkForConflictingInstanceGetterAndSuperclassMember(); | 485 _checkForConflictingInstanceGetterAndSuperclassMember(); |
| 486 _checkImplementsSuperClass(node); | 486 _checkImplementsSuperClass(node); |
| 487 _checkImplementsFunctionWithoutCall(node); | 487 _checkImplementsFunctionWithoutCall(node); |
| 488 _checkForMixinHasNoConstructors(node); | 488 _checkForMixinHasNoConstructors(node); |
| 489 } | 489 } |
| 490 } | 490 } |
| 491 visitClassDeclarationIncrementally(node); | 491 visitClassDeclarationIncrementally(node); |
| 492 _checkForFinalNotInitializedInClass(node); | 492 _checkForFinalNotInitializedInClass(node); |
| 493 _checkForDuplicateDefinitionInheritance(); | 493 _checkForDuplicateDefinitionInheritance(); |
| 494 _checkForConflictingInstanceMethodSetter(node); | 494 _checkForConflictingInstanceMethodSetter(node); |
| 495 _checkForBadFunctionUse(node); |
| 495 return super.visitClassDeclaration(node); | 496 return super.visitClassDeclaration(node); |
| 496 } finally { | 497 } finally { |
| 497 _isInNativeClass = false; | 498 _isInNativeClass = false; |
| 498 _initialFieldElementsMap = null; | 499 _initialFieldElementsMap = null; |
| 499 _enclosingClass = outerClass; | 500 _enclosingClass = outerClass; |
| 500 } | 501 } |
| 501 } | 502 } |
| 502 | 503 |
| 503 /** | 504 /** |
| 504 * Implementation of this method should be synchronized with | 505 * Implementation of this method should be synchronized with |
| (...skipping 2431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2936 memberHashMap["${name.name}="] = member; | 2937 memberHashMap["${name.name}="] = member; |
| 2937 } else { | 2938 } else { |
| 2938 memberHashMap[name.name] = member; | 2939 memberHashMap[name.name] = member; |
| 2939 } | 2940 } |
| 2940 } | 2941 } |
| 2941 } | 2942 } |
| 2942 } | 2943 } |
| 2943 } | 2944 } |
| 2944 | 2945 |
| 2945 /** | 2946 /** |
| 2947 * Verifies that the class is not named `Function` and that it doesn't |
| 2948 * extends/implements/mixes in `Function`. |
| 2949 */ |
| 2950 void _checkForBadFunctionUse(ClassDeclaration node) { |
| 2951 ExtendsClause extendsClause = node.extendsClause; |
| 2952 ImplementsClause implementsClause = node.implementsClause; |
| 2953 WithClause withClause = node.withClause; |
| 2954 |
| 2955 if (node.name.name == "Function") { |
| 2956 _errorReporter.reportErrorForNode( |
| 2957 HintCode.DEPRECATED_FUNCTION_CLASS_DECLARATION, node.name); |
| 2958 } |
| 2959 |
| 2960 if (extendsClause != null) { |
| 2961 InterfaceType superclassType = _enclosingClass.supertype; |
| 2962 ClassElement superclassElement = superclassType?.element; |
| 2963 if (superclassElement != null && superclassElement.name == "Function") { |
| 2964 _errorReporter.reportErrorForNode( |
| 2965 HintCode.DEPRECATED_EXTENDS_FUNCTION, extendsClause.superclass); |
| 2966 } |
| 2967 } |
| 2968 |
| 2969 if (withClause != null) { |
| 2970 for (TypeName type in withClause.mixinTypes) { |
| 2971 Element mixinElement = type.name.staticElement; |
| 2972 if (mixinElement != null && mixinElement.name == "Function") { |
| 2973 _errorReporter.reportErrorForNode( |
| 2974 HintCode.DEPRECATED_MIXIN_FUNCTION, type); |
| 2975 } |
| 2976 } |
| 2977 } |
| 2978 } |
| 2979 |
| 2980 /** |
| 2946 * Verify that the enclosing class does not have an instance member with the | 2981 * Verify that the enclosing class does not have an instance member with the |
| 2947 * same name as the given static [method] declaration. | 2982 * same name as the given static [method] declaration. |
| 2948 * | 2983 * |
| 2949 * See [StaticWarningCode.CONFLICTING_STATIC_GETTER_AND_INSTANCE_SETTER]. | 2984 * See [StaticWarningCode.CONFLICTING_STATIC_GETTER_AND_INSTANCE_SETTER]. |
| 2950 */ | 2985 */ |
| 2951 void _checkForConflictingStaticGetterAndInstanceSetter( | 2986 void _checkForConflictingStaticGetterAndInstanceSetter( |
| 2952 MethodDeclaration method) { | 2987 MethodDeclaration method) { |
| 2953 if (!method.isStatic) { | 2988 if (!method.isStatic) { |
| 2954 return; | 2989 return; |
| 2955 } | 2990 } |
| (...skipping 4103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7059 class _InvocationCollector extends RecursiveAstVisitor { | 7094 class _InvocationCollector extends RecursiveAstVisitor { |
| 7060 final List<String> superCalls = <String>[]; | 7095 final List<String> superCalls = <String>[]; |
| 7061 | 7096 |
| 7062 @override | 7097 @override |
| 7063 visitMethodInvocation(MethodInvocation node) { | 7098 visitMethodInvocation(MethodInvocation node) { |
| 7064 if (node.target is SuperExpression) { | 7099 if (node.target is SuperExpression) { |
| 7065 superCalls.add(node.methodName.name); | 7100 superCalls.add(node.methodName.name); |
| 7066 } | 7101 } |
| 7067 } | 7102 } |
| 7068 } | 7103 } |
| OLD | NEW |