Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(219)

Side by Side Diff: pkg/analyzer/lib/src/generated/error_verifier.dart

Issue 2643073002: Deprecate the use of `Function` as a class. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 2429 matching lines...) Expand 10 before | Expand all | Expand 10 after
2934 memberHashMap["${name.name}="] = member; 2935 memberHashMap["${name.name}="] = member;
2935 } else { 2936 } else {
2936 memberHashMap[name.name] = member; 2937 memberHashMap[name.name] = member;
2937 } 2938 }
2938 } 2939 }
2939 } 2940 }
2940 } 2941 }
2941 } 2942 }
2942 2943
2943 /** 2944 /**
2945 * Verifies that the class is not named `Function` and that it doesn't
2946 * extends/implements/mixes in `Function`.
2947 */
2948 void _checkForBadFunctionUse(ClassDeclaration node) {
2949 ExtendsClause extendsClause = node.extendsClause;
2950 ImplementsClause implementsClause = node.implementsClause;
2951 WithClause withClause = node.withClause;
2952
2953 if (node.name.name == "Function") {
2954 _errorReporter.reportErrorForNode(
2955 HintCode.DEPRECATED_FUNCTION_CLASS_DECLARATION, node.name);
2956 }
2957
2958 if (extendsClause != null) {
2959 InterfaceType superclassType = _enclosingClass.supertype;
2960 ClassElement superclassElement = superclassType?.element;
2961 if (superclassElement != null && superclassElement.name == "Function") {
2962 _errorReporter.reportErrorForNode(
2963 HintCode.DEPRECATED_EXTENDS_FUNCTION, extendsClause);
Brian Wilkerson 2017/01/19 18:16:05 'extendsClause' --> 'extendsClause.superclass'
floitsch 2017/01/19 18:22:49 Done.
2964 }
2965 }
2966
2967 if (implementsClause != null) {
2968 for (TypeName type in implementsClause.interfaces) {
2969 ClassElement implementsElement = type.name.staticElement;
2970 if (implementsElement != null && implementsElement.name == "Function") {
2971 _errorReporter.reportErrorForNode(
2972 HintCode.DEPRECATED_IMPLEMENTS_FUNCTION, type);
2973 }
2974 }
2975 }
2976
2977 if (withClause != null) {
2978 for (TypeName type in withClause.mixinTypes) {
2979 ClassElement mixinElement = type.name.staticElement;
2980 if (mixinElement != null && mixinElement.name == "Function") {
2981 _errorReporter.reportErrorForNode(
2982 HintCode.DEPRECATED_MIXIN_FUNCTION, type);
2983 }
2984 }
2985 }
2986 }
2987
2988 /**
2944 * Verify that the enclosing class does not have an instance member with the 2989 * Verify that the enclosing class does not have an instance member with the
2945 * same name as the given static [method] declaration. 2990 * same name as the given static [method] declaration.
2946 * 2991 *
2947 * See [StaticWarningCode.CONFLICTING_STATIC_GETTER_AND_INSTANCE_SETTER]. 2992 * See [StaticWarningCode.CONFLICTING_STATIC_GETTER_AND_INSTANCE_SETTER].
2948 */ 2993 */
2949 void _checkForConflictingStaticGetterAndInstanceSetter( 2994 void _checkForConflictingStaticGetterAndInstanceSetter(
2950 MethodDeclaration method) { 2995 MethodDeclaration method) {
2951 if (!method.isStatic) { 2996 if (!method.isStatic) {
2952 return; 2997 return;
2953 } 2998 }
(...skipping 4066 matching lines...) Expand 10 before | Expand all | Expand 10 after
7020 class _InvocationCollector extends RecursiveAstVisitor { 7065 class _InvocationCollector extends RecursiveAstVisitor {
7021 final List<String> superCalls = <String>[]; 7066 final List<String> superCalls = <String>[];
7022 7067
7023 @override 7068 @override
7024 visitMethodInvocation(MethodInvocation node) { 7069 visitMethodInvocation(MethodInvocation node) {
7025 if (node.target is SuperExpression) { 7070 if (node.target is SuperExpression) {
7026 superCalls.add(node.methodName.name); 7071 superCalls.add(node.methodName.name);
7027 } 7072 }
7028 } 7073 }
7029 } 7074 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698